Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
'use strict';
var winston = require('winston');
var Syslog = winston.transports.SyslogConsole = function (options) {
var Producer = require('glossy').Produce;
winston.Transport.call(this, options);
this.producer = new Producer({
appName: options.appName || 'winston',
host: options.host || require('os').hostname(),
facility: options.facility || 'local6'
});
this.appName = options.appName || 'winston';
this.name = 'syslog-shit';
this.level = options.level || 'emerg';
};
require('util').inherits(Syslog, winston.Transport);
Syslog.prototype.log = function(level, msg, meta, callback) {
var line;
var data = {};
data[this.appName] = meta;
line = this.producer.produce({
severity: level, // or a relevant string
host: this.host,
appName: this.appName,
date: new Date(Date()),
message: msg,
structuredData: data
});
if (!line) {
return callback(true);
}
process.stdout.write(line + '\n');
callback(null, true);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.