aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/logger.ts27
1 files changed, 17 insertions, 10 deletions
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts
index 734523b01..8603dd761 100644
--- a/server/helpers/logger.ts
+++ b/server/helpers/logger.ts
@@ -2,6 +2,7 @@
2import { mkdirpSync } from 'fs-extra' 2import { mkdirpSync } from 'fs-extra'
3import * as path from 'path' 3import * as path from 'path'
4import * as winston from 'winston' 4import * as winston from 'winston'
5import { FileTransportOptions } from 'winston/lib/winston/transports'
5import { CONFIG } from '../initializers/config' 6import { CONFIG } from '../initializers/config'
6import { omit } from 'lodash' 7import { omit } from 'lodash'
7 8
@@ -45,6 +46,21 @@ const labelFormatter = winston.format.label({
45 label 46 label
46}) 47})
47 48
49const fileLoggerOptions: FileTransportOptions = {
50
51 filename: path.join(CONFIG.STORAGE.LOG_DIR, 'peertube.log'),
52 handleExceptions: true,
53 format: winston.format.combine(
54 winston.format.timestamp(),
55 jsonLoggerFormat
56 )
57}
58
59if (CONFIG.LOG.ROTATION) {
60 fileLoggerOptions.maxsize = 1024 * 1024 * 12
61 fileLoggerOptions.maxFiles = 20
62}
63
48const logger = winston.createLogger({ 64const logger = winston.createLogger({
49 level: CONFIG.LOG.LEVEL, 65 level: CONFIG.LOG.LEVEL,
50 format: winston.format.combine( 66 format: winston.format.combine(
@@ -52,16 +68,7 @@ const logger = winston.createLogger({
52 winston.format.splat() 68 winston.format.splat()
53 ), 69 ),
54 transports: [ 70 transports: [
55 new winston.transports.File({ 71 new winston.transports.File(fileLoggerOptions),
56 filename: path.join(CONFIG.STORAGE.LOG_DIR, 'peertube.log'),
57 handleExceptions: true,
58 maxsize: 1024 * 1024 * 12,
59 maxFiles: 20,
60 format: winston.format.combine(
61 winston.format.timestamp(),
62 jsonLoggerFormat
63 )
64 }),
65 new winston.transports.Console({ 72 new winston.transports.Console({
66 handleExceptions: true, 73 handleExceptions: true,
67 format: winston.format.combine( 74 format: winston.format.combine(