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

Should be able to redirect logging through custom external logging mechanisms #30

Closed
pimterry opened this issue Oct 10, 2013 · 6 comments

Comments

@pimterry
Copy link
Owner

See #29 (comment)

Loglevel is not going to gain appender-style functionality, with pluggable redirectors or similar because that's quite heavyweight and there are other big heavyweight logging projects which already do that (e.g. http://log4javascript.org/).

The current log method setup does internally use replaceLoggingMethods(logMethodFactory) though, with different factories depending on whether all logging is silent/fallback from missing consoles is required/log methods should be built bound to the console and with a little bit of tweaking it should be possible to add an API (something like log.setLogMethodFactory(f)), to which you can pass a function similar to those currently given to replaceLoggingMethods(). That would be a very small change to loglevel itself, to just expose optional override functionality, but allow people to implement their own appender functionality attached to loglevel if required.

@cowwoc
Copy link
Contributor

cowwoc commented Feb 12, 2014

For what it's worth: https://code.google.com/p/chromium/issues/detail?id=231007

I'm surprised no one has filed similar feature requests for other browsers.

@cowwoc
Copy link
Contributor

cowwoc commented Feb 12, 2014

@pimterry take a look at https://code.google.com/p/chromium/issues/detail?id=231007. We're actually getting some traction from the developers.

@cowwoc
Copy link
Contributor

cowwoc commented Feb 17, 2014

Good news! It looks like very soon this problem is going to go away (at least on Chrome). I'm hoping that Firefox and others will follow suit.

@pimterry
Copy link
Owner Author

I'm somewhat on the fence about dropping the current careful stacktrace-guarding setup, mostly to keep backward compatibility for at least a little while until this is more widespread, but if there were a backward compatible option to mark loglevel as skippable in logging traces then I'd be very happy to add that in, and with that and this story completed it'd be trivial to plug in your own formatter/appender/logging multiplexer setup without any downsides.

I can't actually see the doc Paul's linked, but I assume it's something like sourcemap comments, where you put in a specially formatted comment marking this as an external lib?

Long-term I'd certainly want to move to doing that fully, and then loglevel would be in a great position to start pulling in the most popular core extra features, preferably while keeping the lib tiny (as now), but I'm going to avoid that until there's proper support everywhere to make this work nicely.

@cowwoc
Copy link
Contributor

cowwoc commented Feb 17, 2014

The proposal is to allow users to add files to a blacklist. When console.log() or debugging is used, Chrome will automatically skip entries coming from blacklisted files.

I believe this will be configured like breakpoints. It will be configured globally across Chrome, and persisted across restarts. Your code wouldn't change at all because each user would need to blacklist the logger themselves.

@pimterry
Copy link
Owner Author

pimterry commented Oct 5, 2014

Loglevel now essentially supports this; there's a log.methodFactory property which can be changed or wrapped by plugins to optionally provide different behaviour, at the cost of breaking stacktraces in those cases. I think that solves this case.

Details at https://github.com/pimterry/loglevel#plugins

@pimterry pimterry closed this as completed Oct 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants