logger icon indicating copy to clipboard operation
logger copied to clipboard

[Feature] shimLog other console functions

Open svemat01 opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe. The shimLog feature allows us to overwrite console.log to a logger method, there are however many more methods in console that we should be able to override such as console.info, console.warn, and console.error

Describe the solution you'd like optionally pass an object into shimLog instead of a string for the logger method to use. the object would have optional for each one and would only replace those included in the object.

// Replaces `console.log` with `log.debug` !
shimLog(log, 'debug');

// Replaces `console.?` with `log.?` !
shimLog(log, {
    log: 'debug',
    info: 'info',
    warn: 'warn',
    error: 'error',
});

Describe alternatives you've considered Importing the normal logger everywhere

svemat01 avatar Feb 20 '22 11:02 svemat01

I am very much in favor of this proposed solution.

lucemans avatar Feb 20 '22 22:02 lucemans

Agree, but do keep in mind that console.error doesn't write to stdout but stderr

Antony1060 avatar Feb 20 '22 22:02 Antony1060

Research the purpose of outputting to stderr and potential reasons we would want such? Or potentially a way to customize output depending on logging method? Such that error goes to stderr ?

lucemans avatar Feb 21 '22 09:02 lucemans