cantina-log
JSON-powered logging for Cantina applications. Extends jog with some Cantina-specific functionality.
Usage
Setting up your app:
var app = ; app;
Start logging...
// Perferred logging method:app // console.log-style logging.app; // dump an object.app; // Use levels:applog;applog;applog;applog;
Configuration
The following configuration (defaults shown) is supported.
{
log: {
trace: true,
req: {
enable: true,
exclude: /(\.js$)|(\.css$)|(\/images.*)|(favicon.ico)|(\.hbs$)/
}
}
}
- trace - Adds file and line number to all log entries. Should be turned OFF in production.
- req
- enable - Adds middleware that logs all requests.
- exclude - A regular expression identifying paths to exclude from the logs.
Overriding console
app.log.replaceConsole()
- Override console's logging methods with app.log variants.app.log.restoreConsole()
- Restore console to its orginal state.
Using a custom jog store
jog logs using a 'store'. The default is StdStore
which logs to stdout
and stderr. If you prefer to use a FileStore
, RedisStore
, or something
custom you can tell the app like so:
var app = jog = ; app;
Data serialization
You may find yourself logging simliar kinds of application object, such as 'user' models. You can log the raw user objects and implement a serializer to santize it for the logs.
app;
CLI
Now that your log output is in nice, parseable JSON, you may want to be able to read it on the command-line in a more human-friendly format. Joli is a CLI that helps you format newline-separated JSON object (like the ones cantina-log outputs).
Please see joli's README for full documentation.
Terra Eclipse
Developed byTerra Eclipse, Inc. is a nationally recognized political technology and strategy firm located in Santa Cruz, CA and Washington, D.C.