{"size": 820, "ext": "js", "max_stars_repo_path": "src/common/Logger.js", "max_stars_repo_name": "Timson020/Node-Builder", "max_stars_repo_stars_event_min_datetime": "2018-08-01T06:39:31.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-06T06:05:33.000Z", "max_issues_repo_path": "src/common/Logger.js", "max_issues_repo_name": "Timson020/Node-Builder", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/common/Logger.js", "max_forks_repo_name": "Timson020/Node-Builder", "max_forks_repo_forks_event_min_datetime": "2021-03-06T06:05:35.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-06T06:05:35.000Z"}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 23.4285714286, "max_line_length": 102, "alphanum_fraction": 0.7256097561}
import path from 'path'
import winston from 'winston'
import DailyRotateFile from 'winston-daily-rotate-file'

import Constants from './Constants'

const consoleTransport = new winston.transports.Console({
	level: 'info',
	exitOnError: true,
})

const allTransport = new DailyRotateFile({
	dirname: Constants.isDev ? path.join(__dirname, '../logs') : './logs',
	filename: 'request-%DATE%.log',
	// datePattern: 'YYYY-MM-DD HH-mm-ss',
	datePattern: 'YYYY-MM-DD',
	zippedArchive: false,
	maxSize: '1g',
	maxFiles: '20d',
})

const transports = [allTransport]

const format = winston.format.combine(winston.format.printf(info => `${info.level}: ${info.message}`))

if (Constants.isDev) transports.push(consoleTransport)

const Logger = winston.createLogger({
	level: 'info',
	transports,
	format,
})

export default Logger
