forked from DanKottke/midas
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Brandt Heisey
committed
Apr 8, 2015
1 parent
2b63e30
commit d1777f0
Showing
2 changed files
with
68 additions
and
25 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,29 +1,71 @@ | ||
console.log('Loading... ', __filename); | ||
|
||
var winston = require('winston'); | ||
/** | ||
* Logger configuration | ||
* | ||
* Configure the log level for your app, as well as the transport | ||
* (Underneath the covers, Sails uses Winston for logging, which | ||
* allows for some pretty neat custom transports/adapters for log messages) | ||
* | ||
* For more information on the Sails logger, check out: | ||
* http://sailsjs.org/#documentation | ||
*/ | ||
* Logger configuration | ||
* | ||
* Configure the log level for your app, as well as the transport | ||
* (Underneath the covers, Sails uses Winston for logging, which | ||
* allows for some pretty neat custom transports/adapters for log messages) | ||
* | ||
* For more information on the Sails logger, check out: | ||
* http://sailsjs.org/#documentation | ||
*/ | ||
/* | ||
Winston log levels are flipped from sails log levels, so using the log_level array makes it behave as expected in the sails documentation | ||
*/ | ||
|
||
var log_levels = { | ||
silent: 6, | ||
error: 5, | ||
warn: 4, | ||
debug: 3, | ||
info: 2, | ||
verbose: 1, | ||
silly: 0 | ||
}; | ||
|
||
module.exports = { | ||
var transports = [ | ||
new (winston.transports.File)( | ||
/*This Transport controls what is written to the log file*/ | ||
{ | ||
level: 'verbose', | ||
name: 'written.log', | ||
silent: false, | ||
colorize: false, | ||
timestamp: true, | ||
filename: "application.log", | ||
maxsize: 500000, | ||
maxFiles: 5, | ||
json: false, | ||
handleExceptions: false | ||
} | ||
), | ||
new (winston.transports.Console)( | ||
/*This Transport is required to get console output, regardless of sails log level | ||
* output will be the lesser of sails log level and the transport level if they aren't equal | ||
* accordingly, transport log level shoul always be equal or lower than sails log level for readability's sake | ||
*/ | ||
{ | ||
level: 'silly', | ||
name: 'console.log', | ||
silent: false, | ||
colorize: true, | ||
timestamp: true, | ||
json: false, | ||
handleExceptions: false | ||
} | ||
) | ||
]; | ||
|
||
// Valid `level` configs: | ||
// i.e. the minimum log level to capture with sails.log.*() | ||
// | ||
// 'error' : Display calls to `.error()` | ||
// 'warn' : Display calls from `.error()` to `.warn()` | ||
// 'debug' : Display calls from `.error()`, `.warn()` to `.debug()` | ||
// 'info' : Display calls from `.error()`, `.warn()`, `.debug()` to `.info()` | ||
// 'verbose': Display calls from `.error()`, `.warn()`, `.debug()`, `.info()` to `.verbose()` | ||
// | ||
log: { | ||
level: 'info' | ||
} | ||
var logger = new (winston.Logger)({ | ||
exitOnError: false, | ||
transports: transports, | ||
levels: log_levels | ||
}); | ||
|
||
}; | ||
/* Don't forget to set the sails logging level to a higher or equal level to what you want in the logs */ | ||
module.exports.log = { | ||
level: 'silly', | ||
colors: false, // To get clean logs without prefixes or color codings | ||
custom: logger | ||
}; |
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