A logging framework for Node.js
npm install loggaahYes this is another logging framework, because the world can never have enough logging frameworks.
#### What makes this one so special or even different from others? Let's see:
* Written in ES6 (does not require --harmony flag)
* Extensible plugin architecture
* Simple configuration
* Modifiable at runtime
* Multiple configuration options: File, Rest, Web-Interface through plugins
* Configurable log levels
* Inspired by Log4j2/Logback in Java
* Flow interface
#### How do you use it? Easy:
``JavaScript`
var logs = require('loggaah');
Get your logger:
`JavaScript`
var log = logs.getLogger('myLogger');
Or let loggaah detect your logger:
`JavaScript`
var log = logs.getLogger(); // name = current.file
Log a message:
`JavaScript`
log.info('Hello World!');
Log an exception:
`JavaScript`
var ex = new Error("I'm an error");
log.warn('Oh no!', ex);
Log metadata:
`JavaScript`
var MDC = new logs.MDC({ key1: 'value1' });
MDC.set('key2', 'value2');
log.debug('Juicy Details', MDC);
Format your log message:
`JavaScript`
log.trace('to %s or not to %s, that is the question', 'be', 'bee');
Or do it all at once (Order doesn't matter, the first string is the message to be formatted):
`JavaScript`
log.error('Hope this', ex, MDC, 'helps');
Change where logs are sent to:
`JavaScript`
log.setAppender('default', {
type: 'Console',
color: true
});
Use a unique id to identify this message later
`JavaScript`
var hash = log.info('A message').param('a parameter').getId();
// #A18dnJ0l or other hash
npm install loggaah --save
Notice that if you don't install released versions from npm and use the master instead, that it is in active development
and might not be working. For help and questions you can always file an issue.
1. Loggers are your entry point into the logging system where you generate events (by calling log.info() for example)
2. Loggers can filter messages based on logging level
3. Loggers configure to which appender a message gets routed
4. Loggers are configured using regular expressions. Any log the regex matches, will have its rule applied.
All loggers have names, even if you don't set one the system will generate one for you (typically something based on the
file path). When you set a configuration you can specify a name that will match any logger with the same prefix or you
can define a regular expression. When you get a logger you need to fetch a specific one, so no regular expression there,
buddy.
You can also change a configuration of a logger directly on the instance programmatically, so that you can change the
appenders that receive messages for example.
_TODO_: Formatting Guide
You can just run `npm test` to see an output of all existing tests as well as coverage information.
I try to find all the bugs and have tests to cover all cases, but since I'm working on this project alone, it's easy to
miss something. Also I'm trying to think of new features to implement, but most of the time I add new features because
someone asked me for it. So please report any bugs or feature request to mallox@pyxzl.net or file an issue directly on
Github. Before submitting a bug report specific to your problem, try running
the same command and verbose mode -v` so that I have some additional information to work with.
Thanks!
Wow, apparently there are people who want to support me. If you're one of them you can do so via bitcoin over here:
mallox@coinbase