winston was borked
This commit is contained in:
		
							parent
							
								
									047b0be769
								
							
						
					
					
						commit
						dc279467d5
					
				
					 2 changed files with 24 additions and 62 deletions
				
			
		
							
								
								
									
										9
									
								
								index.js
									
										
									
									
									
								
							
							
						
						
									
										9
									
								
								index.js
									
										
									
									
									
								
							| 
						 | 
					@ -3,6 +3,9 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
'use strict'
 | 
					'use strict'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// remove this after we uncomment sentry
 | 
				
			||||||
 | 
					/* eslint-disable no-unused-vars */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Check node.js version
 | 
					// Check node.js version
 | 
				
			||||||
if (Number(process.version.slice(1).split('.')[0]) < 12) {
 | 
					if (Number(process.version.slice(1).split('.')[0]) < 12) {
 | 
				
			||||||
  console.log('NodeJS 12.0.0 or higher is required. Please update NodeJS on your system.')
 | 
					  console.log('NodeJS 12.0.0 or higher is required. Please update NodeJS on your system.')
 | 
				
			||||||
| 
						 | 
					@ -58,9 +61,9 @@ const init = async () => {
 | 
				
			||||||
      if (!file.endsWith('.js')) {
 | 
					      if (!file.endsWith('.js')) {
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      const response = client.loadCommand(file)
 | 
					      const res = client.loadCommand(file)
 | 
				
			||||||
      if (response) {
 | 
					      if (res) {
 | 
				
			||||||
        client.logger.error(response)
 | 
					        client.logger.error(res)
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,65 +1,24 @@
 | 
				
			||||||
'use strict'
 | 
					'use strict'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const { createLogger, format, transports, addColors } = require('winston')
 | 
					const { colorConsole } = require('tracer')
 | 
				
			||||||
require('winston-daily-rotate-file')
 | 
					const colors = require('colors')
 | 
				
			||||||
const fs = require('fs')
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
if (!fs.existsSync('logs')) {
 | 
					const logger = colorConsole({
 | 
				
			||||||
  fs.mkdirSync('logs')
 | 
					  format: [
 | 
				
			||||||
}
 | 
					    '{{timestamp}} | {{title}} | {{file}} | {{message}}',
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
const dailyRotateFileTransport = new transports.DailyRotateFile({
 | 
					      debug: `{{timestamp}} | ${'{{title}}'.magenta} | {{file}} | {{message}}`,
 | 
				
			||||||
  filename: 'logs/%DATE%.log',
 | 
					      cmd: `{{timestamp}} | ${'{{title}}'.white} | {{file}} | {{message}}`,
 | 
				
			||||||
  datePattern: 'YYYY-MM-DD'
 | 
					      info: `{{timestamp}} | ${'{{title}}'.cyan} | {{file}} | {{message}}`,
 | 
				
			||||||
 | 
					      ready: `{{timestamp}} | ${'{{title}}'.green} | {{file}} | {{message}}`,
 | 
				
			||||||
 | 
					      warn: `{{timestamp}} | ${'{{title}}'.yellow} | {{file}} | {{message}}`,
 | 
				
			||||||
 | 
					      error: `{{timestamp}} | ${'{{title}}'.red} | {{file}} | {{message}}`,
 | 
				
			||||||
 | 
					      fatal: `{{timestamp}} | ${'{{title}}'.red.bold} | {{file}} | {{message}}`
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					  dateformat: 'yyyy-mm-dd"T"HH:MM:ss',
 | 
				
			||||||
 | 
					  methods: ['cmd', 'debug', 'info', 'ready', 'warn', 'error', 'fatal'],
 | 
				
			||||||
 | 
					  filters: [colors.white]
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const customLevels = {
 | 
					 | 
				
			||||||
  levels: {
 | 
					 | 
				
			||||||
    fatal: 0,
 | 
					 | 
				
			||||||
    error: 1,
 | 
					 | 
				
			||||||
    warn: 2,
 | 
					 | 
				
			||||||
    ready: 3,
 | 
					 | 
				
			||||||
    info: 4,
 | 
					 | 
				
			||||||
    cmd: 5,
 | 
					 | 
				
			||||||
    debug: 6
 | 
					 | 
				
			||||||
  },
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  colors: {
 | 
					 | 
				
			||||||
    fatal: 'bold red',
 | 
					 | 
				
			||||||
    error: 'red',
 | 
					 | 
				
			||||||
    warn: 'yellow',
 | 
					 | 
				
			||||||
    ready: 'green',
 | 
					 | 
				
			||||||
    info: 'cyan',
 | 
					 | 
				
			||||||
    cmd: 'white',
 | 
					 | 
				
			||||||
    debug: 'magenta'
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const logger = createLogger({
 | 
					 | 
				
			||||||
  level: 'info',
 | 
					 | 
				
			||||||
  levels: customLevels.levels,
 | 
					 | 
				
			||||||
  format: format.combine(
 | 
					 | 
				
			||||||
    format.timestamp({
 | 
					 | 
				
			||||||
      format: 'YYYY-MM-DD HH:mm:ss'
 | 
					 | 
				
			||||||
    }),
 | 
					 | 
				
			||||||
    format.printf(info => `${info.timestamp} ${info.level}: ${info.message}`)
 | 
					 | 
				
			||||||
  ),
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  transports: [
 | 
					 | 
				
			||||||
    new transports.Console({
 | 
					 | 
				
			||||||
      level: 'info',
 | 
					 | 
				
			||||||
      format: format.combine(
 | 
					 | 
				
			||||||
        format.colorize(),
 | 
					 | 
				
			||||||
        format.printf(
 | 
					 | 
				
			||||||
          info => `${info.timestamp} ${info.level}: ${info.message}`
 | 
					 | 
				
			||||||
        )
 | 
					 | 
				
			||||||
      )
 | 
					 | 
				
			||||||
    }),
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    dailyRotateFileTransport
 | 
					 | 
				
			||||||
  ]
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
addColors(customLevels.colors)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
module.exports = logger
 | 
					module.exports = logger
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue