Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions lib/winston-couchdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
*/

var winston = require('winston'),
common = require('winston/lib/winston/common'),
util = require('util'),
cycle = require('cycle'),
Stream = require('stream').Stream;
common = require('winston/lib/winston/common'),
util = require('util'),
cycle = require('cycle'),
Stream = require('stream').Stream;

//
// ### function Couchdb (options)
Expand All @@ -26,12 +26,13 @@ var Couchdb = exports.Couchdb = function (options) {

winston.Transport.call(this, options);

this.name = 'couchdb';
this.db = options.db || options.database || 'winston';
this.host = options.host || 'localhost';
this.port = options.port || 5984;
this.auth = options.auth;
this.name = 'couchdb';
this.db = options.db || options.database || 'winston';
this.host = options.host || 'localhost';
this.port = options.port || 5984;
this.auth = options.auth;
this.secure = /^https:/i.test(this.host) || !!(options.ssl || options.secure);
this.timestamp = options.timestamp || (function () { return new Date() })

// Legacy
if (options.user) {
Expand Down Expand Up @@ -78,7 +79,7 @@ Couchdb.prototype.log = function (level, msg, meta, callback) {
//
var params = common.clone(cycle.decycle(meta)) || {};
// RFC3339/ISO8601 format instead of common.timestamp()
params.timestamp = new Date();
params.timestamp = this.timestamp()
params.message = msg;
params.level = level;

Expand Down Expand Up @@ -114,7 +115,7 @@ Couchdb.prototype.log = function (level, msg, meta, callback) {
Couchdb.prototype._ensureView = function (callback) {
var self = this;

callback = callback || function(){};
callback = callback || function () { };

if (this._ensuredView) return callback();

Expand Down Expand Up @@ -193,7 +194,7 @@ Couchdb.prototype.query = function (options, callback) {
}

var self = this,
query = {};
query = {};

options = this.normalizeQuery(options);

Expand Down Expand Up @@ -244,19 +245,19 @@ Couchdb.prototype.query = function (options, callback) {
//
Couchdb.prototype.stream = function (options) {
var self = this,
stream = new Stream(),
feed;
stream = new Stream(),
feed;

options = options || {},

stream.destroy = function () {
this.destroyed = true;
try {
feed.stop();
} catch (e) {
;
}
};
stream.destroy = function () {
this.destroyed = true;
try {
feed.stop();
} catch (e) {
;
}
};

this.client.info(function (err, info) {
if (err) return stream.emit('error', err);
Expand Down