Created
June 12, 2020 12:18
-
-
Save dmitryuk/45772705c3539b12ba8072f92e7a6aa5 to your computer and use it in GitHub Desktop.
Use native functions console.log, console.error, console.warn, console.info, console.debug with Winston nodejs on Typescript
This file contains hidden or 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
const logger = createLogger({ | |
transports: [ | |
new transports.Console({ level: 'silly' }), | |
], | |
}); | |
console.log = function(){ | |
logger.info.apply(logger, arguments as unknown as [object]); | |
}; | |
console.info = function(){ | |
logger.info.apply(logger,arguments as unknown as [object]); | |
}; | |
console.warn = function(){ | |
logger.warn.apply(logger, arguments as unknown as [object]); | |
}; | |
console.error = function(){ | |
logger.error.apply(logger, arguments as unknown as [object]); | |
}; | |
console.debug = function(){ | |
logger.debug.apply(logger, arguments as unknown as [object]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment