aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/helpers/logger.ts30
-rw-r--r--server/lib/emailer.ts4
2 files changed, 32 insertions, 2 deletions
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts
index e0b904950..7968b5ec9 100644
--- a/server/helpers/logger.ts
+++ b/server/helpers/logger.ts
@@ -73,11 +73,39 @@ const logger = new winston.createLogger({
73 exitOnError: true 73 exitOnError: true
74}) 74})
75 75
76function bunyanLogFactory (level: string) {
77 return function () {
78 let meta = null
79 let args = [].concat(arguments)
80
81 if (arguments[ 0 ] instanceof Error) {
82 meta = arguments[ 0 ].toString()
83 args = Array.prototype.slice.call(arguments, 1)
84 args.push(meta)
85 } else if (typeof (args[ 0 ]) !== 'string') {
86 meta = arguments[ 0 ]
87 args = Array.prototype.slice.call(arguments, 1)
88 args.push(meta)
89 }
90
91 logger[ level ].apply(logger, args)
92 }
93}
94const bunyanLogger = {
95 trace: bunyanLogFactory('debug'),
96 debug: bunyanLogFactory('debug'),
97 info: bunyanLogFactory('info'),
98 warn: bunyanLogFactory('warn'),
99 error: bunyanLogFactory('error'),
100 fatal: bunyanLogFactory('error')
101}
102
76// --------------------------------------------------------------------------- 103// ---------------------------------------------------------------------------
77 104
78export { 105export {
79 timestampFormatter, 106 timestampFormatter,
80 labelFormatter, 107 labelFormatter,
81 consoleLoggerFormat, 108 consoleLoggerFormat,
82 logger 109 logger,
110 bunyanLogger
83} 111}
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts
index bc0061c99..9c105a575 100644
--- a/server/lib/emailer.ts
+++ b/server/lib/emailer.ts
@@ -1,7 +1,7 @@
1import { createTransport, Transporter } from 'nodemailer' 1import { createTransport, Transporter } from 'nodemailer'
2import { UserRight } from '../../shared/models/users' 2import { UserRight } from '../../shared/models/users'
3import { isTestInstance } from '../helpers/core-utils' 3import { isTestInstance } from '../helpers/core-utils'
4import { logger } from '../helpers/logger' 4import { bunyanLogger, logger } from '../helpers/logger'
5import { CONFIG } from '../initializers' 5import { CONFIG } from '../initializers'
6import { UserModel } from '../models/account/user' 6import { UserModel } from '../models/account/user'
7import { VideoModel } from '../models/video/video' 7import { VideoModel } from '../models/video/video'
@@ -44,6 +44,8 @@ class Emailer {
44 host: CONFIG.SMTP.HOSTNAME, 44 host: CONFIG.SMTP.HOSTNAME,
45 port: CONFIG.SMTP.PORT, 45 port: CONFIG.SMTP.PORT,
46 secure: CONFIG.SMTP.TLS, 46 secure: CONFIG.SMTP.TLS,
47 debug: CONFIG.LOG.LEVEL === 'debug',
48 logger: bunyanLogger as any,
47 ignoreTLS: isTestInstance(), 49 ignoreTLS: isTestInstance(),
48 tls, 50 tls,
49 auth 51 auth