Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    debugcallbackpublic

    debugcallback

    Help to debug missing callback calls.

    Synopsis

    var
    	debug = require('./index.js')(function(level, message, callback){
    		console.log('logging:', level, message);
    		if( callback ) {
    			callback();
    		}
    	});
    
    function wayWardFunction(callback){
    	debug.log('waywardFunction started');
    	callback = debug.callback('waywardFunction finished', callback);
    	setTimeout(callback, 1000);
    }
    
    wayWardFunction(function(){
    	console.log('callback actually called');
    });
    

    How to use

    Setup:

    The module exposes a function. Call with a filename to log to this file, or with a function to have that function called with the log message. The function exposed returns an object with 2 methods, log and callback

    The function to be provided should accept 3 arguments: level (string), message (string) and callback, and should call the callback once logging is done. Hint: winston's log function will do...

    Debugging:

    Call the log function for immediate logging, and callback to wrap a callback in a logging call.

    install

    npm i debugcallback

    Downloadsweekly downloads

    3

    version

    1.0.2

    license

    MIT License

    repository

    githubgithub

    last publish

    collaborators

    • avatar