logger.js 697 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. var logger = require('./logger');
  3. var msg = '';
  4. logger.error(msg);
  5. */
  6. 'use strict';
  7. /**
  8. * Module dependencies.
  9. */
  10. var formater = require('error-formater');
  11. var Logger = require('mini-logger');
  12. var C = require('../config');
  13. var isTEST = process.env.NODE_ENV === 'test';
  14. var categories = ['user_error', 'admin_error'];
  15. var logger = module.exports = Logger({
  16. categories: categories,
  17. dir: C.logdir,
  18. duration: '1d',
  19. format: '[{category}.]YYYY-MM-DD[.log]',
  20. stdout: C.debug && !isTEST,
  21. errorFormater: errorFormater
  22. });
  23. var to = [];
  24. for (var user in C.admins) {
  25. to.push(C.admins[user]);
  26. }
  27. function errorFormater(err) {
  28. var msg = formater.both(err);
  29. return msg.text;
  30. }