logger.js 982 B

1234567891011121314151617181920212223242526272829303132333435
  1. /**
  2. * @Author HonorLee (dev@honorlee.me)
  3. * @Version 1.0 (2018-05-04)
  4. * @License MIT
  5. */
  6. const colors = require('colors');
  7. var Logger = {
  8. log:function(msg){
  9. console.log('['+serverUID+'][LOG] '+msg);
  10. if(Config.write_log_file) this.out('log',msg);
  11. },
  12. info:function(msg){
  13. console.log(('['+serverUID+'][INF] '+msg).green);
  14. if(Config.write_log_file) this.out('info',msg);
  15. },
  16. debug:function(msg){
  17. if(Config.debug) console.log(('['+serverUID+'][DEBUG] '+msg).yellow);
  18. // if(Config.write_log_file) this.out('debug',msg);
  19. },
  20. warn:function(msg){
  21. console.log(('['+serverUID+'][WARN] '+msg).magenta);
  22. if(Config.write_error_file) this.out('warn',msg);
  23. },
  24. error:function(msg){
  25. console.log(('['+serverUID+'][ERR] '+msg).red);
  26. if(Config.write_error_file) this.out('error',msg);
  27. },
  28. out:function(level,msg){
  29. Tracer[level](msg);
  30. }
  31. };
  32. module.exports = Logger;