Created
February 5, 2014 22:18
-
-
Save jrgm/8834431 to your computer and use it in GitHub Desktop.
logging change diff v. rel 10.09
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
diff --git a/lib/configuration.js b/lib/configuration.js | |
index 5736fde..8456373 100644 | |
--- a/lib/configuration.js | |
+++ b/lib/configuration.js | |
@@ -294,7 +294,17 @@ var conf = module.exports = convict({ | |
forcible_issuers: { | |
doc: "Hostnames which this Persona instance will issue identies for. Used in b2g only.", | |
format: 'array { string }* = [ "fxos.login.persona.org"]', | |
- } | |
+ }, | |
+ winston_logging_maxsize: { | |
+ doc: "If greater than zero, max size in bytes of the logfile", | |
+ format: 'integer = 0', | |
+ env: 'WINSTON_LOGGING_MAXSIZE' | |
+ }, | |
+ winston_logging_maxfiles: { | |
+ doc: "Number of previous logfiles to retain", | |
+ format: 'integer = 10', | |
+ env: 'WINSTON_LOGGING_MAXFILES' | |
+ }, | |
}); | |
// At the time this file is required, we'll determine the "process name" for this proc | |
diff --git a/lib/logging.js b/lib/logging.js | |
index 2867a03..a206f83 100644 | |
--- a/lib/logging.js | |
+++ b/lib/logging.js | |
@@ -42,13 +42,20 @@ mkdir_p(log_path); | |
var filename = path.join(log_path, configuration.get('process_type') + ".log"); | |
+var fileOptions = { | |
+ timestamp: function () { return new Date().toISOString(); }, | |
+ filename: filename, | |
+ colorize: true, | |
+ handleExceptions: true | |
+}; | |
+ | |
+if (configuration.get('winston_logging_maxsize') >= 0) { | |
+ fileOptions.maxsize = configuration.get('winston_logging_maxsize'); | |
+ fileOptions.maxFiles = configuration.get('winston_logging_maxfiles'); | |
+} | |
+ | |
exports.logger = new (winston.Logger)({ | |
- transports: [new (winston.transports.File)({ | |
- timestamp: function () { return new Date().toISOString(); }, | |
- filename: filename, | |
- colorize: true, | |
- handleExceptions: true | |
- })] | |
+ transports: [new (winston.transports.File)(fileOptions)] | |
}); | |
exports.enableConsoleLogging = function() { | |
Also, this looks cool. Would you submit it as a PR?
Whoops. Yeah, I mean strictly greater than zero. Thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should line 39 be
instead?