Skip to content

Instantly share code, notes, and snippets.

@mrister
Last active July 13, 2017 16:11
Show Gist options
  • Save mrister/56d643a1d4ef4109b90f1782211ab377 to your computer and use it in GitHub Desktop.
Save mrister/56d643a1d4ef4109b90f1782211ab377 to your computer and use it in GitHub Desktop.
Es6 example of logging to Loggly using Bunyan
const bunyan = require('bunyan');
const Bunyan2Loggly = require('bunyan-loggly');
const log = bunyan.createLogger({
name: 'logglylog',
streams: [
{
type: 'raw',
stream: new Bunyan2Loggly({
token: '<your token>',
subdomain: '<your subdomain>',
json: true
})
}
]
});
// utility function for sample logging
function logItems (name, ...args){
log.info([name, ...args]);
}
// log the object
logItems('test items', '1', '2', '3', 'done');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment