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
2.2 KiB

  1. 'use strict'
  2. /* global wiki */
  3. const cluster = require('cluster')
  4. module.exports = {
  5. init() {
  6. let winston = require('winston')
  7. // Console
  8. let logger = new (winston.Logger)({
  9. level: (wiki.IS_DEBUG) ? 'debug' : 'info',
  10. transports: [
  11. new (winston.transports.Console)({
  12. level: (wiki.IS_DEBUG) ? 'debug' : 'info',
  13. prettyPrint: true,
  14. colorize: true,
  15. silent: false,
  16. timestamp: true
  17. })
  18. ]
  19. })
  20. logger.filters.push((level, msg) => {
  21. let processName = (cluster.isMaster) ? 'MASTER' : `WORKER-${cluster.worker.id}`
  22. return '[' + processName + '] ' + msg
  23. })
  24. // External services
  25. // if (wiki.config.externalLogging.bugsnag) {
  26. // const bugsnagTransport = require('./winston-transports/bugsnag')
  27. // logger.add(bugsnagTransport, {
  28. // level: 'warn',
  29. // key: wiki.config.externalLogging.bugsnag
  30. // })
  31. // }
  32. // if (wiki.config.externalLogging.loggly) {
  33. // require('winston-loggly-bulk')
  34. // logger.add(winston.transports.Loggly, {
  35. // token: wiki.config.externalLogging.loggly.token,
  36. // subdomain: wiki.config.externalLogging.loggly.subdomain,
  37. // tags: ['wiki-js'],
  38. // level: 'warn',
  39. // json: true
  40. // })
  41. // }
  42. // if (wiki.config.externalLogging.papertrail) {
  43. // require('winston-papertrail').Papertrail // eslint-disable-line no-unused-expressions
  44. // logger.add(winston.transports.Papertrail, {
  45. // host: wiki.config.externalLogging.papertrail.host,
  46. // port: wiki.config.externalLogging.papertrail.port,
  47. // level: 'warn',
  48. // program: 'wiki.js'
  49. // })
  50. // }
  51. // if (wiki.config.externalLogging.rollbar) {
  52. // const rollbarTransport = require('./winston-transports/rollbar')
  53. // logger.add(rollbarTransport, {
  54. // level: 'warn',
  55. // key: wiki.config.externalLogging.rollbar
  56. // })
  57. // }
  58. // if (wiki.config.externalLogging.sentry) {
  59. // const sentryTransport = require('./winston-transports/sentry')
  60. // logger.add(sentryTransport, {
  61. // level: 'warn',
  62. // key: wiki.config.externalLogging.sentry
  63. // })
  64. // }
  65. return logger
  66. }
  67. }