Answer the question
In order to leave comments, you need to log in
How to remap console.log function in nodejs?
Good afternoon, colleagues.
I ran into such a difficulty, there is a very good library provided by the npm package for outputting trees, tables and other things (ascii) to the console, but unfortunately the logger that displays debug information about the server state cannot pull them up, since apparently inside this same library uses console.log.
My task is to reassign console.log to a method for outputting normal server logs with debugging information, etc.
In the code, it really is reassigned like this:
But for some reason npm packages do not suck it in and continue to output everything in the usual console.log.
console.log = (message) => logger.info(message)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question