This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const winston = require('winston'); | |
require('winston-loggly-bulk'); | |
winston.loggers.add('production', { | |
Loggly: { | |
token: 'YOUR_TOKEN', | |
subdomain: 'YOUR_SUBDOMAIN' | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const winston = require('winston'); | |
winston.loggers.add('development', { | |
console: { | |
level: 'silly', | |
colorize: 'true', | |
label: 'category one' | |
}, | |
file: { | |
filename: './somefile.log', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"level":"info","message":"Hello distributed log files!","timestamp":"2017-05-30T13:13:06.884Z"} | |
{"level":"info","message":"Hello again distributed log files!","timestamp":"2017-05-30T13:13:06.885Z"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const client = loggly.createClient({ | |
token: 'YOUR_APPLICATION_TOKEN', | |
subdomain: 'YOUR_SUBDOMAIN', | |
tags: ['first-tag', 'second-tag', 'third-tag'], | |
json: true | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Complex object definition | |
const complexObject = { | |
name: { | |
first: 'Matthew', | |
last: 'Setter' | |
}, | |
employment: 'Freelance Technical Writer', | |
country: 'Germany', | |
languages: [ | |
'PHP', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const client = loggly.createClient({ | |
token: 'YOUR_APPLICATION_TOKEN', | |
subdomain: 'YOUR_SUBDOMAIN', | |
json: true | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const shallowObject = { | |
fullname: "Matthew Setter", | |
employment: "Freelance Technical Writer", | |
country: "Germany", | |
languages: ['PHP', 'Node.js', 'Bash', 'Ruby', 'Python', 'Go'] | |
} | |
// use previously defined loggly client | |
client.log(shallowObject, function (err, result) { | |
// Do something once you've logged |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client.log('127.0.0.1 - There is no place like home', function(err, result) { | |
// Do something once you've logged | |
if (result && result.response && result.response.toLowerCase() === 'ok') { | |
console.log('Log message sent successfully') | |
} else if (err) { | |
console.log(err) | |
} else { | |
console.log('Log message not sent because response is not ok') | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client.log(`127.0.0.1 - There's no place like home`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/loggly/node-loggly-bulk#getting-started | |
const loggly = require('node-loggly-bulk'); | |
const client = loggly.createClient({ | |
token: 'YOUR_APPLICATION_TOKEN', | |
subdomain: 'YOUR_SUBDOMAIN' | |
}); |