pn-logging
A common logging interface for pn projects.
Usage
var Log = require('@spanishdict/pn-logging').Log;
var logger = new Log(config);
logger.info('Message', meta);
logger.error('Error message', err);
logger.error('Error message', meta, err);
app.use(logger.middleware());
If error object is passed to logger's logging methods, e.g. error
, in addition to sending data to defined transporter (most likely Loggly), the error will also be sent to Sentry.
var Log = require('@spanishdict/pn-logging').Log;
var logger = new Log(config);
logger.error('Error message', {
tags: {key: 'value'}
}, err);
Refer to sentry docs.
tags
, fingerprint
, and level
properties of log meta object will be mapped to related sentry optional attributes. All other meta properties will become extra
property in sentry optional attributes.
Config
The config
object passed to Log
constructor should look like:
var config = {
transports: [
{
Console: {
level: 'info',
json: true,
prettyPrint: true,
silent: true
}
},
{
Loggly: {
level: 'warning',
json: true,
tag: 'APP_NAME',
subdomain: process.env.LOGGLY_SUBDOMAIN,
token: process.env.LOGGLY_TOKEN
}
}
],
sentry: {
dsn: 'https://*****@app.getsentry.com/xxxxx',
options: {}
}
};