Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Issue #1410: Add 'timestamp' option to logger. #1411

Merged
merged 1 commit into from

3 participants

@russellsantos

Add winston's timestamp option to Sails logger.

@mikedevita

how would someone enable this feature? Is there documentation along with this change?

@russellsantos

One can enable this by putting the timestamp variable in the log config.

module.exports = {
  log: {
    level: 'info',
    timestamp: true
  }
}

There's no documentation right now, but I can add it in. I'm not sure where to put it though.

@mikedevita

:+1: checkout balderdashy/sails-docs there should be a file there for it.

Heres the file you should update.. https://github.com/balderdashy/sails-docs/blob/master/config.log.md

@russellsantos russellsantos referenced this pull request from a commit in russellsantos/sails-docs
@russellsantos russellsantos Documentation for balderdashy/sails#1411. Added timestamp config to l…
…ogger.
6a3c329
@russellsantos

Added the documentation to the v0.9 branch on sails-docs, as requested.

@mikermcneil
Owner

Hey @russellsantos, thanks! What would this look like for v0.10, in your opinion?

@russellsantos

@mikermcneil, it looks like in v0.10, Sails uses Captain's Log, which doesn't use Winston by default.
People can use Winston, by using a custom logger. And they can pass the timestamp option to the logger itself.

So we don't really need to change any code for people to be able to do this in v0.10. They just need to pass a custom Logger in the configuration.

@mikermcneil
Owner

@russellsantos thanks!

@mikermcneil mikermcneil merged commit e4598f1 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 17, 2014
  1. @russellsantos
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/logger.js
View
9 lib/logger.js
@@ -31,7 +31,8 @@ module.exports = function(sails) {
maxFiles: 10,
json: false,
colorize: true,
- level: 'info'
+ level: 'info',
+ timestamp: false
});
var winston = require('winston');
@@ -40,7 +41,8 @@ module.exports = function(sails) {
var transports = [
new(winston.transports.Console)({
level: 'debug',
- colorize: config.colorize
+ colorize: config.colorize,
+ timestamp: config.timestamp
})
];
@@ -53,7 +55,8 @@ module.exports = function(sails) {
maxFiles: config.maxFiles,
level: 'verbose',
json: config.json,
- colorize: config.colorize
+ colorize: config.colorize,
+ timestamp: config.timestamp
}));
}
Something went wrong with that request. Please try again.