mirror of https://github.com/requarks/wiki
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
1.9 KiB
80 lines
1.9 KiB
8 years ago
|
'use strict'
|
||
|
|
||
7 years ago
|
/* global wiki */
|
||
|
|
||
|
module.exports = (processName) => {
|
||
8 years ago
|
let winston = require('winston')
|
||
8 years ago
|
|
||
8 years ago
|
if (typeof processName === 'undefined') {
|
||
|
processName = 'SERVER'
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
// Console
|
||
8 years ago
|
|
||
8 years ago
|
let logger = new (winston.Logger)({
|
||
7 years ago
|
level: (wiki.IS_DEBUG) ? 'debug' : 'info',
|
||
8 years ago
|
transports: [
|
||
|
new (winston.transports.Console)({
|
||
7 years ago
|
level: (wiki.IS_DEBUG) ? 'debug' : 'info',
|
||
8 years ago
|
prettyPrint: true,
|
||
|
colorize: true,
|
||
|
silent: false,
|
||
|
timestamp: true
|
||
|
})
|
||
|
]
|
||
|
})
|
||
|
|
||
|
logger.filters.push((level, msg) => {
|
||
|
return '[' + processName + '] ' + msg
|
||
8 years ago
|
})
|
||
|
|
||
|
// External services
|
||
|
|
||
7 years ago
|
if (wiki.config.externalLogging.bugsnag) {
|
||
8 years ago
|
const bugsnagTransport = require('./winston-transports/bugsnag')
|
||
8 years ago
|
logger.add(bugsnagTransport, {
|
||
8 years ago
|
level: 'warn',
|
||
7 years ago
|
key: wiki.config.externalLogging.bugsnag
|
||
8 years ago
|
})
|
||
|
}
|
||
|
|
||
7 years ago
|
if (wiki.config.externalLogging.loggly) {
|
||
8 years ago
|
require('winston-loggly-bulk')
|
||
8 years ago
|
logger.add(winston.transports.Loggly, {
|
||
7 years ago
|
token: wiki.config.externalLogging.loggly.token,
|
||
|
subdomain: wiki.config.externalLogging.loggly.subdomain,
|
||
8 years ago
|
tags: ['wiki-js'],
|
||
|
level: 'warn',
|
||
|
json: true
|
||
|
})
|
||
|
}
|
||
|
|
||
7 years ago
|
if (wiki.config.externalLogging.papertrail) {
|
||
8 years ago
|
require('winston-papertrail').Papertrail // eslint-disable-line no-unused-expressions
|
||
8 years ago
|
logger.add(winston.transports.Papertrail, {
|
||
7 years ago
|
host: wiki.config.externalLogging.papertrail.host,
|
||
|
port: wiki.config.externalLogging.papertrail.port,
|
||
8 years ago
|
level: 'warn',
|
||
|
program: 'wiki.js'
|
||
|
})
|
||
|
}
|
||
|
|
||
7 years ago
|
if (wiki.config.externalLogging.rollbar) {
|
||
8 years ago
|
const rollbarTransport = require('./winston-transports/rollbar')
|
||
8 years ago
|
logger.add(rollbarTransport, {
|
||
8 years ago
|
level: 'warn',
|
||
7 years ago
|
key: wiki.config.externalLogging.rollbar
|
||
8 years ago
|
})
|
||
|
}
|
||
|
|
||
7 years ago
|
if (wiki.config.externalLogging.sentry) {
|
||
8 years ago
|
const sentryTransport = require('./winston-transports/sentry')
|
||
8 years ago
|
logger.add(sentryTransport, {
|
||
8 years ago
|
level: 'warn',
|
||
7 years ago
|
key: wiki.config.externalLogging.sentry
|
||
8 years ago
|
})
|
||
|
}
|
||
|
|
||
8 years ago
|
return logger
|
||
8 years ago
|
}
|