2017-03-29 00:19:01 +00:00
|
|
|
'use strict'
|
|
|
|
|
2017-07-23 03:56:46 +00:00
|
|
|
/* global wiki */
|
|
|
|
|
2017-07-29 04:11:22 +00:00
|
|
|
const cluster = require('cluster')
|
2017-03-29 00:19:01 +00:00
|
|
|
|
2017-07-29 21:33:08 +00:00
|
|
|
module.exports = {
|
|
|
|
init() {
|
|
|
|
let winston = require('winston')
|
2017-03-29 00:19:01 +00:00
|
|
|
|
2017-07-29 21:33:08 +00:00
|
|
|
// Console
|
2017-03-29 00:19:01 +00:00
|
|
|
|
2017-07-29 21:33:08 +00:00
|
|
|
let logger = new (winston.Logger)({
|
|
|
|
level: (wiki.IS_DEBUG) ? 'debug' : 'info',
|
|
|
|
transports: [
|
|
|
|
new (winston.transports.Console)({
|
|
|
|
level: (wiki.IS_DEBUG) ? 'debug' : 'info',
|
|
|
|
prettyPrint: true,
|
|
|
|
colorize: true,
|
|
|
|
silent: false,
|
|
|
|
timestamp: true
|
|
|
|
})
|
|
|
|
]
|
|
|
|
})
|
2017-04-28 22:46:27 +00:00
|
|
|
|
2017-07-29 21:33:08 +00:00
|
|
|
logger.filters.push((level, msg) => {
|
|
|
|
let processName = (cluster.isMaster) ? 'MASTER' : `WORKER-${cluster.worker.id}`
|
|
|
|
return '[' + processName + '] ' + msg
|
|
|
|
})
|
2017-03-29 00:19:01 +00:00
|
|
|
|
2017-07-29 21:33:08 +00:00
|
|
|
// External services
|
2017-03-29 00:19:01 +00:00
|
|
|
|
2017-07-29 21:33:08 +00:00
|
|
|
// if (wiki.config.externalLogging.bugsnag) {
|
|
|
|
// const bugsnagTransport = require('./winston-transports/bugsnag')
|
|
|
|
// logger.add(bugsnagTransport, {
|
|
|
|
// level: 'warn',
|
|
|
|
// key: wiki.config.externalLogging.bugsnag
|
|
|
|
// })
|
|
|
|
// }
|
2017-03-29 00:19:01 +00:00
|
|
|
|
2017-07-29 21:33:08 +00:00
|
|
|
// if (wiki.config.externalLogging.loggly) {
|
|
|
|
// require('winston-loggly-bulk')
|
|
|
|
// logger.add(winston.transports.Loggly, {
|
|
|
|
// token: wiki.config.externalLogging.loggly.token,
|
|
|
|
// subdomain: wiki.config.externalLogging.loggly.subdomain,
|
|
|
|
// tags: ['wiki-js'],
|
|
|
|
// level: 'warn',
|
|
|
|
// json: true
|
|
|
|
// })
|
|
|
|
// }
|
2017-03-29 00:19:01 +00:00
|
|
|
|
2017-07-29 21:33:08 +00:00
|
|
|
// if (wiki.config.externalLogging.papertrail) {
|
|
|
|
// require('winston-papertrail').Papertrail // eslint-disable-line no-unused-expressions
|
|
|
|
// logger.add(winston.transports.Papertrail, {
|
|
|
|
// host: wiki.config.externalLogging.papertrail.host,
|
|
|
|
// port: wiki.config.externalLogging.papertrail.port,
|
|
|
|
// level: 'warn',
|
|
|
|
// program: 'wiki.js'
|
|
|
|
// })
|
|
|
|
// }
|
2017-03-29 00:19:01 +00:00
|
|
|
|
2017-07-29 21:33:08 +00:00
|
|
|
// if (wiki.config.externalLogging.rollbar) {
|
|
|
|
// const rollbarTransport = require('./winston-transports/rollbar')
|
|
|
|
// logger.add(rollbarTransport, {
|
|
|
|
// level: 'warn',
|
|
|
|
// key: wiki.config.externalLogging.rollbar
|
|
|
|
// })
|
|
|
|
// }
|
2017-03-29 00:19:01 +00:00
|
|
|
|
2017-07-29 21:33:08 +00:00
|
|
|
// if (wiki.config.externalLogging.sentry) {
|
|
|
|
// const sentryTransport = require('./winston-transports/sentry')
|
|
|
|
// logger.add(sentryTransport, {
|
|
|
|
// level: 'warn',
|
|
|
|
// key: wiki.config.externalLogging.sentry
|
|
|
|
// })
|
|
|
|
// }
|
2017-03-30 01:49:30 +00:00
|
|
|
|
2017-07-29 21:33:08 +00:00
|
|
|
return logger
|
|
|
|
}
|
2017-03-29 00:19:01 +00:00
|
|
|
}
|