Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding rotationFormat prop to file.js #273

Merged
merged 1 commit into from
Dec 30, 2014
Merged

Commits on Jun 29, 2013

  1. 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<yyyyMMddhhmmss>.log
    
    ex:
    run20130629190056.log
    run20130629190057.log
    and so forth...
    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;
    	}
      }
    });
    orcaman committed Jun 29, 2013
    Configuration menu
    Copy the full SHA
    a87a876 View commit details
    Browse the repository at this point in the history