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

Add Support for Cascading LogLevel Configuration #1

Open
jonnyreeves opened this issue Jan 4, 2013 · 1 comment
Open

Add Support for Cascading LogLevel Configuration #1

jonnyreeves opened this issue Jan 4, 2013 · 1 comment
Assignees

Comments

@jonnyreeves
Copy link
Owner

JSLogger should cascade the LogLevel configuration for named loggers based on their namespace, so for example:

var loggerA = Logger.get("parentNS.clientA");

// Configure the LogLevel of the parent namespace
Logger.get("parentNS").setLevel(Logger.WARN);

loggerA.info("Info Message"); // No output
loggerA.warn("Warning Message"): // Logs "Warning Message"

This feature would provide developers a way to express log levels for an entire group of clients without having to manually list them all out.

@ghost ghost assigned jonnyreeves Jan 4, 2013
@Download
Copy link

You could have a look at how debug does this.

Debug has no global logger, only named loggers. And it is basically just a list, there is no hierarchy.
But it can simulate hierarchy through naming conventions. They recommend using colon : to separate levels:

var debug = require('debug')
var log = require('my-app:my-module')
log('Hello!')

By default, this would not produce any output, but you can enable loggers using a pattern:

debug.enable('my-app:my-module') // enables only the one module
debug.enable('my-app:*') // enables every submodule of my-app

They translate the pattern and then use simple regex pattern matching on the name to determine if the logger is enabled or not. It works surprisingly well.

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