Skip to content

Commit

Permalink
ADDING Last known public release
Browse files Browse the repository at this point in the history
  • Loading branch information
wnoronha committed Jul 22, 2013
1 parent e8d3bb0 commit bbd32c4
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
50 changes: 50 additions & 0 deletions lib/winston-scribe.js
@@ -0,0 +1,50 @@
var util = require('util');
var winston = require('winston');
var scribe = require('scribe');
var os = require('os');

var Scribe = exports.Scribe = function (options) {
options = options || {};
options.host = options.host || 'localhost';
options.port = options.port || 1463;

this.name = 'scribe';
this.level = options.level || 'info';
this.category = options.category || 'winston';
this.client = new scribe.Scribe(options.host, options.port, {autoReconnect:true});
this.isReady = false;

var self = this;
this.client.open(function(err){
if(!err)
self.isReady = true;
});
};

util.inherits(Scribe, winston.Transport);
Scribe.prototype.log = function (level, msg, meta, callback) {

var entry = {
timestamp: (new Date()).toISOString(),
host: os.hostname(),
level: level,
message: msg,
};

if (meta) {
entry.meta = meta;
}

if (this.isReady){
this.emit('logged');
this.client.send(this.category, JSON.stringify(entry));
return callback(null, true);
}
else
{
this.emit('error', null);
return callback("Error: Scribe is not ready yet.",null)
}
};

winston.transports.Scribe = Scribe;
39 changes: 39 additions & 0 deletions package.json
@@ -0,0 +1,39 @@
{
"author": {
"name": "Warren Noronha",
"email": "warren.noronha@gmail.com"
},
"name": "winston-scribe",
"description": "A scribe transport for winston",
"keywords": [
"logging",
"sysadmin",
"tools",
"winston",
"scribe"
],
"version": "0.1.2",
"homepage": "https://github.com/chitika/winston-scribe",
"repository": {
"type": "git",
"url": "git://github.com/chitika/winston-scribe.git"
},
"main": "./lib/winston-scribe",
"dependencies": {
"scribe": "0.0.2"
},
"engines": {
"node": ">= 0.4.0"
},
"readme": "ERROR: No README data found!",
"readmeFilename": "README",
"bugs": {
"url": "https://github.com/chitika/winston-scribe/issues"
},
"_id": "winston-scribe@0.1.2",
"dist": {
"shasum": "ef0440ef7a1a3c6f3a767f7622bfcbf942ef2eda"
},
"_from": "winston-scribe@",
"_resolved": "https://registry.npmjs.org/winston-scribe/-/winston-scribe-0.1.2.tgz"
}

0 comments on commit bbd32c4

Please sign in to comment.