-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added index creation; * added simple initialization errors longing; * dependecies were updated.
- Loading branch information
1 parent
d6ba0f9
commit 1552778
Showing
2 changed files
with
18 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/** | ||
* @module winston-mongodb | ||
* @fileoverview Transport for outputting to a MongoDB database | ||
* @fileoverview Winston transport for logging into MongoDB | ||
* @license MIT | ||
* @author [email protected] (Charlie Robbins) | ||
* @author [email protected] (Yurij Mikhalevich) | ||
|
@@ -83,7 +83,15 @@ var MongoDB = exports.MongoDB = function(options) { | |
|
||
function setupDatabaseAndEmptyQueue(db) { | ||
authorizeDb(db, function(err, db) { | ||
if (err) { | ||
console.error('winston-mongodb, initialization error: ', err); | ||
return; | ||
} | ||
createCollection(db, function(err, db) { | ||
if (err) { | ||
console.error('winston-mongodb, initialization error: ', err); | ||
return; | ||
} | ||
self.logDb = db; | ||
processOpQueue(); | ||
}); | ||
|
@@ -102,8 +110,14 @@ var MongoDB = exports.MongoDB = function(options) { | |
if (self.capped) { | ||
opts = {capped: true, size: self.cappedSize}; | ||
} | ||
db.createCollection(self.collection, opts, function() { | ||
cb(null, db); | ||
db.createCollection(self.collection, opts, function(err, col) { | ||
if (err) { | ||
cb(err); | ||
return; | ||
} | ||
col.createIndex({timestamp: -1}, function(err) { | ||
cb(err, db); | ||
}); | ||
}); | ||
} | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "winston-mongodb", | ||
"license": "MIT", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "A MongoDB transport for winston", | ||
"author": "Charlie Robbins <[email protected]>", | ||
"contributors": [ | ||
|