-
Notifications
You must be signed in to change notification settings - Fork 944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to avoid the tedious initialization? #154
Comments
That is how the module is designed. Anyhow take a look to #156 |
I could be wrong, but you may be missing the point slightly; The power of However, to answer you question: I tend to use |
Hi @stablum, I've just replied to your stackoverflow question. If you are using Example: var log = require('debug-logger')('myapp');
log.trace("I'm a trace output");
log.debug("I'm a debug output");
log.log("I'm a log output");
log.info("I'm an info output");
log.warn("I'm a warn output");
log.error("I'm an error output"); would print: More info at the project page, |
I know this is a year later, but I just wrote this to help facilitate creating debug instances for stdout and stderr... const debug = require( 'debug' );
module.exports = function( namespace ) {
const
log = debug( `${ namespace }:log` ),
error = debug( `${ namespace }:error` );
log.log = console.log.bind( console );
return { log, error };
}; threw that in a const {
log,
error
} = require( '../utils/debug-helper' )( 'module-name' ); |
Closing this for now. Feel free to discuss further the V3 API RFC issue: #370 |
also posted here: http://stackoverflow.com/questions/26777433/node-js-debug-module-how-to-avoid-this-tedious-initialization
I am wondering if there is any way to prevent this tedious and overly redundant inizialization in each module:
As you can see it's redundant on two different levels: I need to "enable" the loggers before instantiating them, sending the same name twice as strings, and I need to write the module name. Is there any way to do this automagically?
The text was updated successfully, but these errors were encountered: