Baphomet is the dedicated bot for nulloctet matrix
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.

36 lines
984 B

  1. let winston = require('winston');
  2. let logger = winston.createLogger({
  3. level: 'info',
  4. format: winston.format.combine(
  5. winston.format.timestamp(),
  6. winston.format.splat(),
  7. winston.format.json()
  8. ),
  9. defaultMeta: { service: 'baphomet-js' },
  10. transports: [
  11. new winston.transports.File({ filename: 'log/error.log', level: 'error' }),
  12. new winston.transports.File({ filename: 'log/combined.log' })
  13. ]
  14. });
  15. if (process.env.NODE_ENV !== 'production') {
  16. logger.add(new winston.transports.Console({
  17. format: winston.format.combine(
  18. winston.format.simple()
  19. )
  20. }));
  21. } else {
  22. logger.add(new winston.transports.Console({
  23. level: 'error',
  24. format: winston.format.combine(
  25. winston.format.simple()
  26. )
  27. }));
  28. }
  29. if ('LOG_LEVEL' in process.env) {
  30. logger.info('LOG_LEVEL: %s', process.env.LOG_LEVEL)
  31. logger.level = process.env.LOG_LEVEL
  32. }
  33. exports.logger = logger;