Skip to content

Instantly share code, notes, and snippets.

View mrister's full-sized avatar
🏠
Working from home

Mihovil Rister mrister

🏠
Working from home
View GitHub Profile
@mrister
mrister / loggly-winston-add-production-logger.js
Last active May 21, 2017 20:16
Loggly winston add a production logger
const winston = require('winston');
require('winston-loggly-bulk');
winston.loggers.add('production', {
Loggly: {
token: 'YOUR_TOKEN',
subdomain: 'YOUR_SUBDOMAIN'
}
});
@mrister
mrister / configure-winston-transports.js
Created May 12, 2017 07:28
Configure Winston transports
const winston = require('winston');
winston.loggers.add('development', {
console: {
level: 'silly',
colorize: 'true',
label: 'category one'
},
file: {
filename: './somefile.log',
@mrister
mrister / loggly-logfile.log
Created May 12, 2017 07:22
A sample Winston logfile
{"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"}
@mrister
mrister / loggly-client-create-with-json.js
Last active May 25, 2017 07:55
Loggly: Create a client with JSON enabled
const client = loggly.createClient({
token: 'YOUR_APPLICATION_TOKEN',
subdomain: 'YOUR_SUBDOMAIN',
tags: ['first-tag', 'second-tag', 'third-tag'],
json: true
});
@mrister
mrister / loggly-log-a-complex-object.js
Created May 11, 2017 07:59
Loggly log a complex object
// Complex object definition
const complexObject = {
name: {
first: 'Matthew',
last: 'Setter'
},
employment: 'Freelance Technical Writer',
country: 'Germany',
languages: [
'PHP',
@mrister
mrister / loggly-configure-client-to-log-json.js
Last active May 25, 2017 07:54
Loggly: configure client for logging an object as JSON
const client = loggly.createClient({
token: 'YOUR_APPLICATION_TOKEN',
subdomain: 'YOUR_SUBDOMAIN',
json: true
});
@mrister
mrister / loggly-log-a-shallow-object.js
Last active May 25, 2017 07:53
Loggly log a shallow object
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
@mrister
mrister / loggly-client-log-a-message-with-callback.js
Last active May 25, 2017 07:53
Perform action after logging a message to loggly
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')
}
});
@mrister
mrister / loggly-client-log-a-message.js
Last active May 25, 2017 07:51
Log a message to loggly in Node.js
client.log(`127.0.0.1 - There's no place like home`);
@mrister
mrister / loggly-client-create.js
Last active May 21, 2017 20:05
Create a loggly client in node.js
// 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'
});