added option storeHost, if it is set to true adds 'hostname' field to mongodb entry with os.hostname()
This commit is contained in:
Родитель
52354051b8
Коммит
17bcb5678d
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
var util = require('util');
|
||||
var os = require('os');
|
||||
var mongodb = require('mongodb');
|
||||
var winston = require('winston');
|
||||
var common = require('winston/lib/winston/common');
|
||||
|
@ -39,6 +40,7 @@ var MongoDB = exports.MongoDB = function (options) {
|
|||
this.capped = options.capped;
|
||||
this.cappedSize = options.cappedSize || 10000000;
|
||||
this.nativeParser = options.nativeParser || false;
|
||||
this.storeHost = options.storeHost;
|
||||
// TODO: possibly go by docs (`max`) instead
|
||||
// this.length = options.length || 200;
|
||||
|
||||
|
@ -140,6 +142,9 @@ MongoDB.prototype.log = function (level, msg, meta, callback) {
|
|||
entry.timestamp = new Date;
|
||||
entry.level = level;
|
||||
entry.message = msg;
|
||||
if (self.storeHost) {
|
||||
entry.hostname = os.hostname();
|
||||
}
|
||||
|
||||
col.save(entry, { safe: self.safe }, function (err) {
|
||||
if (err) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче