-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close #30: Add winston logging library with multiple log levels
- Loading branch information
Showing
15 changed files
with
223 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
var _ = require('lodash'), | ||
winston = require('winston'); | ||
|
||
module.exports = function (options) { | ||
var defaults = { | ||
level: 'info' | ||
}; | ||
|
||
options = _.defaults(options || {}, defaults); | ||
if (!options.transports) { | ||
options.transports = [ new (winston.transports.Console)({ level: options.level, timestamp: true }) ]; | ||
} | ||
|
||
return new (winston.Logger)(options); | ||
}; |
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
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,33 @@ | ||
'use strict'; | ||
|
||
var chai = require('chai'), | ||
expect = chai.expect, | ||
|
||
winston = require('winston'), | ||
Logger = require('../../../lib/Logger'); | ||
|
||
describe('Logger', function () { | ||
it('should use a default transport to console with log level info', function () { | ||
var logger = new Logger(); | ||
expect(logger.transports.console).to.be.ok; | ||
expect(logger.transports.console).to.be.an.instanceOf(winston.transports.Console); | ||
expect(logger.transports.console.level).to.equal('info'); | ||
}); | ||
|
||
it('should use a default transport to console with the specified log level', function () { | ||
var logger = new Logger({ level: 'debug' }); | ||
expect(logger.transports.console).to.be.ok; | ||
expect(logger.transports.console).to.be.an.instanceOf(winston.transports.Console); | ||
expect(logger.transports.console.level).to.equal('debug'); | ||
}); | ||
|
||
it('should use custom transports if specified', function () { | ||
var transport = { name: 'custom', log: function () {}, on: function () {} }, | ||
logger = new Logger({ | ||
transports: [ | ||
transport | ||
] | ||
}); | ||
expect(logger.transports.custom).to.be.ok; | ||
}); | ||
}); |
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
Oops, something went wrong.