flatiron/winston — pull request #273 by orcaman (2013-06-29 16:19:45+00:00)
Title: Adding rotationFormat prop to file.js

The goal of the rotation format property is to allow the user to pass a pointer to a function that will determine the format of the file name in case of a rotating logger (a logger with maxsize that generated files).

sample usage:
this will make the files created under "log" to be named:
run.log

so these would be files created today:

run20130629190056.log
run20130629190057.log
and so forth...

sample code:
winston.add(winston.transports.File, {
filename: 'log/run.log',
maxsize: 150,
rotationFormat: function() {
return getFormattedDate();
function getFormattedDate() {
var temp = new Date();
return dateStr = padStr(temp.getFullYear()) +
padStr(1 + temp.getMonth()) +
padStr(temp.getDate()) +
padStr(temp.getHours()) +
padStr(temp.getMinutes()) +
padStr(temp.getSeconds());
}
function padStr(i) {
return (i < 10) ? "0" + i : "" + i;
}
}
});