This repository has been archived by the owner on Aug 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated winston to 3, and reconfiguring logs + ignoring logs, etc
- Loading branch information
1 parent
98cb869
commit 3fbb851
Showing
6 changed files
with
974 additions
and
993 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#standard ignores | ||
node_modules/ | ||
logs/ | ||
*.sublime-project | ||
*.sublime-workspace | ||
npm-debug.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict' | ||
const fs = require( 'fs' ) | ||
const path = require( 'path' ) | ||
const { createLogger, format, transports } = require( 'winston' ) | ||
const drf = require( 'winston-daily-rotate-file' ) | ||
|
||
|
||
const env = process.env.NODE_ENV || 'dev' | ||
const logDir = 'logs' | ||
|
||
if ( !fs.existsSync( logDir ) ) { | ||
fs.mkdirSync( logDir ) | ||
} | ||
|
||
const drfTransport = new transports.DailyRotateFile( { | ||
filename: `${logDir}/%DATE%.log`, | ||
datePattern: `YYYY-MM-DD` | ||
} ) | ||
|
||
const logger = createLogger( { | ||
level: 'debug', | ||
format: format.combine( | ||
format.timestamp( { format: 'YYYY-MM-DD HH:mm:ss' } ), | ||
format.json( ) | ||
), | ||
transports: [ | ||
new transports.Console( { | ||
level: 'debug', | ||
format: format.combine( | ||
format.colorize( ), | ||
format.timestamp( { format: 'YYYY-MM-DD HH:mm:ss' } ), | ||
format.printf( info => `${info.timestamp} ${info.level}: ${info.message}` ), ) | ||
} ), | ||
drfTransport | ||
] | ||
} ) | ||
|
||
module.exports = logger |
Oops, something went wrong.