Skip to content
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

Plugin functionality not working #58

Closed
RyanHirsch opened this issue Oct 24, 2014 · 2 comments
Closed

Plugin functionality not working #58

RyanHirsch opened this issue Oct 24, 2014 · 2 comments

Comments

@RyanHirsch
Copy link

I've tried copying the 'Newsflash' example to this jsbin - http://jsbin.com/cupig/1/edit?html,js,console,output and it doesn't seem to be working.

var originalFactory = log.methodFactory;
log.methodFactory = function (methodName, logLevel) {

    console.log(methodName, ':', logLevel);
    var rawMethod = originalFactory(methodName, level);

    return function (message) {
        rawMethod("Newsflash: " + message);
    };
};

var msg = "Horray!";
log.setLevel("info");

log.trace(msg);
log.debug(msg);
log.info(msg);
log.warn(msg);
log.error(msg);

From what I can tell, the methodFactory is not being called at all.

@pimterry
Copy link
Owner

The plugin functionality is not yet released, and you're linking to /dist (the last official release), not /lib (the current state of the project), so it's not included.

I guess this is confusing because the docs on master are for the current tip of master, not for the last release; if you look at the docs at http://pimterry.github.io/loglevel/ or README.md at tag 1.1.0 (the last release), you'll get more accurate info.

On top of that, you did actually find a typo I'd made: 'level' should be 'logLevel' on line 5 there. Thanks for that! I've updated the README.

Anyway, http://jsbin.com/tipotutavu/1/edit?html,js,console does what you think it should do, using /lib instead of /dist. Alternatively there will be a new release coming shortly with all this, so you can just wait until then. In the meantime, I'm still playing around with this a little bit; if you've got any thoughts on how the plugin stuff works/doesn't work those would be very useful!

@RyanHirsch
Copy link
Author

Awesome thank you so much! I am going to try to see how we can get this implemented in our application today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants