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.

72 lines
1.9 KiB

  1. 'use strict'
  2. const winston = require('winston')
  3. module.exports = (isDebug) => {
  4. if (typeof PROCNAME === 'undefined') {
  5. const PROCNAME = 'SERVER' // eslint-disable-line no-unused-vars
  6. }
  7. // Console + File Logs
  8. winston.remove(winston.transports.Console)
  9. winston.add(winston.transports.Console, {
  10. level: (isDebug) ? 'debug' : 'info',
  11. prettyPrint: true,
  12. colorize: true,
  13. silent: false,
  14. timestamp: true,
  15. filters: [(level, msg, meta) => {
  16. return '[' + PROCNAME + '] ' + msg // eslint-disable-line no-undef
  17. }]
  18. })
  19. // External services
  20. if (appconfig.externalLogging.bugsnag) {
  21. const bugsnagTransport = require('./winston-transports/bugsnag')
  22. winston.add(bugsnagTransport, {
  23. level: 'warn',
  24. key: appconfig.externalLogging.bugsnag
  25. })
  26. }
  27. if (appconfig.externalLogging.loggly) {
  28. require('winston-loggly-bulk')
  29. winston.add(winston.transports.Loggly, {
  30. token: appconfig.externalLogging.loggly.token,
  31. subdomain: appconfig.externalLogging.loggly.subdomain,
  32. tags: ['wiki-js'],
  33. level: 'warn',
  34. json: true
  35. })
  36. }
  37. if (appconfig.externalLogging.papertrail) {
  38. require('winston-papertrail').Papertrail // eslint-disable-line no-unused-expressions
  39. winston.add(winston.transports.Papertrail, {
  40. host: appconfig.externalLogging.papertrail.host,
  41. port: appconfig.externalLogging.papertrail.port,
  42. level: 'warn',
  43. program: 'wiki.js'
  44. })
  45. }
  46. if (appconfig.externalLogging.rollbar) {
  47. const rollbarTransport = require('./winston-transports/rollbar')
  48. winston.add(rollbarTransport, {
  49. level: 'warn',
  50. key: appconfig.externalLogging.rollbar
  51. })
  52. }
  53. if (appconfig.externalLogging.sentry) {
  54. const sentryTransport = require('./winston-transports/sentry')
  55. winston.add(sentryTransport, {
  56. level: 'warn',
  57. key: appconfig.externalLogging.sentry
  58. })
  59. }
  60. return winston
  61. }