-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add logging service with winston
- Loading branch information
1 parent
d54fc1f
commit 2bc3c30
Showing
4 changed files
with
824 additions
and
643 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
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,16 @@ | ||
import { format, transports } from 'winston'; | ||
const isProduction = process.env.APP_ENV === 'production'; | ||
export const loggerConfig = { | ||
format: format.combine( | ||
format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), | ||
format.printf(({ level, message, timestamp }) => { | ||
return `${timestamp} [${level}]: ${message}`; | ||
}), | ||
), | ||
transports: isProduction | ||
? [ | ||
new transports.File({ filename: 'logs/errors.log', level: 'error' }), | ||
new transports.File({ filename: 'logs/all.log' }), | ||
] | ||
: [new transports.Console({ format: format.combine(format.colorize({ all: true })) })], | ||
}; |
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
Oops, something went wrong.