forked from winstonjs/winston-loggly
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from loggly/3.x
Use winston 3.x by default
- Loading branch information
Showing
5 changed files
with
160 additions
and
41 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
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
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
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
const winston = require('winston'); | ||
module.exports.testLevels = function (transport, assertMsg, assertFn) { | ||
var tests = {}; | ||
const levels = winston.config.npm.levels; | ||
|
||
Object.keys(levels).forEach(function (level) { | ||
var test = { | ||
topic: function () { | ||
transport.log(level, 'test message', {}, this.callback.bind(this, null)); | ||
} | ||
}; | ||
|
||
test[assertMsg] = assertFn; | ||
tests['with the ' + level + ' level'] = test; | ||
}); | ||
|
||
var metadatatest = { | ||
topic: function () { | ||
transport.log('info', 'test message', { metadata: true }, this.callback.bind(this, null)); | ||
} | ||
}; | ||
|
||
metadatatest[assertMsg] = assertFn; | ||
tests['when passed metadata'] = metadatatest; | ||
|
||
var primmetadatatest = { | ||
topic: function () { | ||
transport.log('info', 'test message', 'metadata', this.callback.bind(this, null)); | ||
} | ||
}; | ||
|
||
primmetadatatest[assertMsg] = assertFn; | ||
tests['when passed primitive metadata'] = primmetadatatest; | ||
|
||
var nummetadatatest = { | ||
topic: function () { | ||
transport.log('info', 'test message', 123456789, this.callback.bind(this, null)); | ||
} | ||
}; | ||
|
||
nummetadatatest[assertMsg] = assertFn; | ||
tests['when passed numeric metadata'] = nummetadatatest; | ||
|
||
// circular references aren't supportded by regular JSON, and it's not supported | ||
// by node-loggly-bulk. I'm omitting it for now. If it wants to be fixed, then | ||
// node-loggly-bulk needs an update. | ||
/* | ||
var circmetadata = { }; | ||
circmetadata['metadata'] = circmetadata; | ||
var circmetadatatest = { | ||
topic: function () { | ||
transport.log('info', 'circular message', circmetadata, this.callback.bind(this, null)); | ||
} | ||
}; | ||
circmetadatatest[assertMsg] = assertFn; | ||
tests['when passed circular metadata'] = circmetadatatest; | ||
var circerror = new Error("message!"); | ||
var foo = {}; | ||
var circerrordatatest; | ||
foo.bar = foo; | ||
circerror.foo = foo; | ||
circerror.stack = 'Some stacktrace'; | ||
circerrordatatest = { | ||
topic: function () { | ||
transport.log('info', 'circular error', circerror, this.callback.bind(this, null)); | ||
} | ||
}; | ||
circerrordatatest[assertMsg] = assertFn; | ||
tests['when passed circular error as metadata'] = circerrordatatest; | ||
*/ | ||
|
||
return tests; | ||
}; |
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