Skip to content

Instantly share code, notes, and snippets.

@jrgm
Created February 5, 2014 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrgm/8834431 to your computer and use it in GitHub Desktop.
Save jrgm/8834431 to your computer and use it in GitHub Desktop.
logging change diff v. rel 10.09
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() {
@gene1wood
Copy link

Should line 39 be

+if (configuration.get('winston_logging_maxsize') > 0) {

instead?

@gene1wood
Copy link

Also, this looks cool. Would you submit it as a PR?

@jrgm
Copy link
Author

jrgm commented Feb 6, 2014

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