Logger.js 625 B

12345678910111213141516171819202122
  1. /** Logger **/
  2. const tracer = require('tracer').dailyfile({root:LOGPATH,format : "{{timestamp}} <{{title}}> {{file}}:{{line}} {{message}}", dateformat : "HH:MM:ss.L"});
  3. var Logger = {
  4. log:function(msg,toFile){
  5. console.log('[LOG]',msg);
  6. if(toFile) this.out(msg);
  7. },
  8. error:function(msg,toFile){
  9. console.log('\x1B[31m[ERROR]',msg,'\x1B[39m');
  10. if(toFile) this.out(msg);
  11. },
  12. info:function(msg,toFile){
  13. console.log('\x1B[32m[INFO]',msg,'\x1B[39m');
  14. if(toFile) this.out(msg);
  15. },
  16. out:function(msg){
  17. tracer.log(msg);
  18. }
  19. }
  20. module.exports = Logger;