Coder Social home page Coder Social logo

winston-daily-rotate-file's People

Contributors

apollon77 avatar cbeliveau avatar chneil avatar dependabot[bot] avatar dreamerkumar avatar fdasfsafsa avatar garcia556 avatar gilly3 avatar henderxx avatar iliyazelenko avatar indexzero avatar jerome-benoit avatar krayzeekev avatar lacivert avatar maharjanraj avatar markjbyrne81 avatar mattberther avatar means88 avatar mtreerungroj avatar nyuno avatar oseau avatar pataiadam avatar patilms16 avatar perrin4869 avatar polunzh avatar shashankpaytm avatar slessi avatar troylatchman avatar wbt avatar wojtekmaj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

winston-daily-rotate-file's Issues

DailyRotateFile transport uses local time zone for rotation

Originally reported by @intraz at winstonjs/winston#456

The DailyRotateFile transport rotates based on the local time zone configured on the machine it is running on. Winston's default time stamps in the log lines are UTC (ISO string).

This means that when the local machine is set to a time zone other than UTC the log file for a given date (as set by DailyRotateFile) might include entries that seem to be from a day before or after (depending on the time zone) when actually they are just described in a different time zone (UTC).

Ideally it (and all other transports) should use the same mechanism used by Winston itself or at least have a standard configuration that makes this issue clear.

Asynchronous function without callback

(node:16486) DeprecationWarning: Calling an asynchronous function without callback is deprecated.
at makeCallback (fs.js:106:12)
at Object.fs.unlink (fs.js:1068:14)
at compressFile (/mnt/nas/code/projects/fsociety/MrNodeBot/node_modules/winston-daily-rotate-file/index.js:588:12)
at createAndFlush (/mnt/nas/code/projects/fsociety/MrNodeBot/node_modules/winston-daily-rotate-file/index.js:575:7)
at /mnt/nas/code/projects/fsociety/MrNodeBot/node_modules/winston-daily-rotate-file/index.js:598:16
at FSReqWrap.oncomplete (fs.js:114:15)

Timestamp option set to 'false' always overridden to 'true'

In DailyRotateFile, a provided option.timestamp set to false will always be overridden to true by the following logic:

this.timestamp = options.timestamp || true;

This assignment should be updated to allow an option.timestamp explicitly set to false to pass through to winston for users who do not wish to prepend log output with a timestamp.

winston should be a peerDependency

If I add this module, it means that I want to add it to the version of winston I am already using. It should not use winston from it's own node_modules directory.

order: 'desc' do not work with winston-daily-rotate-file

As described in title, it seems that descending order works fine as long as you use winston.transports.File. As soon as you switch to require('winston-daily-rotate-file') it acts as the old filetransport bug where sorting is done after the set number of rows has been retrieved in an ascending fascion.

Daily rotator transport doesn't seem to respect tailable

Originally reported by @alonisser at winstonjs/winston#589

The docs state that : "In addition to the options accepted by the File transport..." So I assumed it would respect tailable (meaning it would always log to the same file, and rotate with date the older/maxsized files). But I succeed in making it work (or locating in daily rotator transport code exactly where would it actually respect tailable.

Is there a way to make this work?

log file name changed since version 1.1.2

The name of the log files has changed since version 1.1.2.

var rollingFileLogger = new(WinstonDailyRotFile)({
timestamp: timeStamp,
filename: 'logs/development/log',
datePattern: '-yyyy-MM-dd.log'
});

Before: log-2016-06-06.log
After: log.-2016-06-06.log

set custom formatter function, but not work!!!

const LOGGER_FILE_MAX_SIZE = 1024 * 1024 * 20;//20MB
const dateFormat = function() {
return moment().format('YYYY-MM-DD HH:mm:ss.SSS');
};
const defaultLoggerTransport = new DailyRotateFile({
name: 'defaultLog',
filename: all.log,
timestamp: dateFormat,
level: 'info',
colorize: true,
maxsize: LOGGER_FILE_MAX_SIZE,
datePattern: '.yyyy-MM-dd',
formatter: function(options) {
// Return string will be passed to logger.
return options.timestamp() +' '+ options.level.toUpperCase() +' '+ (undefined !== options.message ? options.message : '') +
(options.meta && Object.keys(options.meta).length ? '\n\t'+ JSON.stringify(options.meta) : '' );
}
});

Adding header lines to logfiles in File and DailyRotateFile transport

Originally reported by @alinex at winstonjs/winston#691

I want to have a logfile header consisting of some comment lines explaining the used format (own formatter funtion).

I tried to use the open event but that is fired too late. I only don't know if it is fired on each file open (not as good) or if a new file is started (better),

My solution so far looks like (CoffeeScript);

trans = new winston.transports.DailyRotateFile  # or File
  level: 'info'
  filename: "#{__dirname}/log/#{filename}"
  formatter: myFormatter
trans.on 'open', ->
  trans._stream.write "# MY LOGFILE HEADER\n"
logger = new winston.Logger
  transports: [trans]

If I run this I will get:

INFO the real log entry
# MY LOGFILE HEADER
INFO another entry
INFO another entry

You see this comes one line too late.

Have you a better solution?

this._getTime is not a function error

I am using winston-daily-rotate-file and I get the following error.

I want to know exactly what the problem is.

The code used is shown below.

var winston = require('winston');
require('winston-daily-rotate-file');

var logger = new winston.Logger ({
    // level : 'debug',
    // 아래에서 설명할 여러개의 transport를 추가할 수 있다.
    transports: [
        winston.transports.DailyRotateFile ({
            level: process.env.ENV === 'development' ? 'debug' : 'info',
            filename: './inpokcet',
            datePattern: 'yyyy-MM-dd.',
            prepend: true
        })
    ]
});

I'll be waiting for the good news.

Custom level + Transports + Colorize

When I create a custom level using setLevels and addColors without adding DailyRotateFile, it works fine. But when using a Transport with colorize: true, I get the following error:

uncaughtException: Cannot read property 'match' of undefined
at /node_modules/winston-daily-rotate-file/node_modules/winston/lib/winston/config.js:30:28

I believe it's because the winston instance is different. The transport is not using the winston that has my custom level.

How to make that work? I believe DailyRotateFile should receive the winston instance as an option, like other transports does. (e.g: bithavoc/express-winston)

mangles file names

If you specify a file extension in options.filename it comes before the timestamp if options.prepend is false.

ie: {filename: 'output.log'} => output.log2016-09-08T18:58

a better solution would be to accept an extension argument or use path.extname to get it from the file name

ie: {filename: 'output.log'} => output2016-09-08T18:58.log
or: {filename: 'output', extension: 'log'} => output2016-09-08T18:58.log

See #54 for sample code

DailyRotateFile will write to the old file if it's been deleted

Originally reported by @cheolgook at winstonjs/winston#504

We're using DailyRotateFile transport and also have separate log archiving box. So after a few days, we move all the log files from app boxes to archive server to free up some space on app boxes, and here comes the problem.

So we have log files with very low traffic (like severe errors) that would have only couple of log entries per week, and the node.js app is running for months without restarting.

The app logged something to the file "20141125.log" which is a week ago, and the app is still running, that file "20141125.log" is already moved to the archive days ago, but the app is still pointing to that file. And today, the app is trying to log something more, and it'll write that log message to the old file "20141125.log" rather than "20141202.log". So it actually creates a file named "20141125.log" again and writes log entry in there.

add all parameter to the documentation

Only datePattern and prepend described as options, however there are more options, like localTime and prettyPrint. All options may included in the documentation

prepend option starts filename with '.'

The default date pattern starts with a '.' - i'm guessing for easy appending.

  this.datePattern = options.datePattern ? options.datePattern : '.yyyy-MM-dd';

When the prepend option is used, the filename winds up starting with .

in _getFilename, add the leading or trailing '.' there.

eg:

if (this.prepend) {
    return formattedDate + '.' + this._basename;
  }

  return this._basename + '.' + formattedDate;

or:

if (this.prepend) {
    return [formattedDate,this._basename].join('.');
  }

  return [this._basename,formattedDate].join('.');

Custom colors change does not work

It might be not an issue at all but currently it seems like I have to setup custom colors for every winston module installed in third-party transports.

For example if I use rotate file logger I need to get winston module used by winston-daily-rotate-file and amend it:

var winston = require("winston");
winston.addColors({ debug: "white" });

var winstonR = require("./node_modules/winston-daily-rotate-file/node_modules/winston/lib/winston")
winstonR.addColors({ debug: "white" });

Is there any way to overcome this?

having more than one transport crashes

It seems not to be possible to have several transports?
like this way:

var transport1 = new winston.transports.DailyRotateFile({
    filename: 'logs/-json.log',
    datePattern: 'yyyy-MM-dd.',
    prepend: true,
    level: process.env.ENV === 'development' ? 'debug' : 'info'
  });

var transport2 = new winston.transports.DailyRotateFile({
    filename: 'logs/-pretty.log',
    datePattern: 'yyyy-MM-dd.',
    json:false,
    prepend: true,
    level: process.env.ENV === 'development' ? 'debug' : 'info'
  });
  
  var logger = new (winston.Logger)({
    transports: [
      transport1,transport2
    ]
  });

this crashes my node.js. Is rotating only intented for one file?

ENOENT Exception from Daily Rotate File

Hello Winston community!

We have been using Winston version 0.7.3 for some time now, and the only major issue that comes up is an occasional ENOENT exception from DailyRotateFile. It occurs sometime after server startup, and a sample stacktrace is below. I didn't see any mention of this issue here and on the main Winston repo--we're planning on upgrading to a new version of Winston but we want to know if this problem has been encountered before and corrected after 0.7.3.

Configuration code:
var fileTransportOpts = {
filename: './server.log',
maxsize: 10000000,
maxFiles: 2,
json: false,
handleExceptions: (process.env.NODE_ENV === 'production')
};

var consoleTransportOpts = {
colorize: true,
timestamp :true,
prettyPrint: true
};

var fileTransport = new logger.transports.DailyRotateFile(fileTransportOpts);
var consoleTransport = new logger.transports.Console(consoleTransportOpts);
logger.remove(logger.transports.Console)
.add(logger.transports.Console, consoleTransportOpts)
.add(logger.transports.DailyRotateFile, fileTransportOpts);
expressWinston.requestWhitelist.splice(0, expressWinston.requestWhitelist.length);
expressWinston.requestWhitelist.push('method');
expressWinston.requestWhitelist.push('url');
expressWinston.requestWhitelist.push('query');

var expressWinstonLogger = expressWinston.logger(
{ transports: [fileTransport, consoleTransport]
, msg: message
, meta: false
})

Stack Trace:
016-04-26T21:09:12.754Z - error: uncaughtException: ENOENT, no such file or directory 'server.log.2016-04-26' date=Tue Apr 26 2016 21:09:12 GMT+0000 (UTC), pid=12373, uid=0, gid=0, cwd=/srv/www/, execPath=/usr/local/bin/node, version=v0.12.7, argv=[/usr/local/bin/node, /srv/www//server.js], rss=836734976, heapTotal=640713216, heapUsed=122086896, loadavg=[0.09423828125, 0.10400390625, 0.076171875], uptime=9469895, trace=[column=null, file=null, function=Error, line=null, method=null, native=true, column=18, file=fs.js, function=Object.fs.unlinkSync, line=883, method=fs.unlinkSync, native=false, column=12, file=/srv/www//node_modules/winston/lib/winston/transports/daily-rotate-file.js, function=DailyRotateFile._getFile, line=537, method=_getFile, native=false, column=31, file=/srv/www//node_modules/winston/lib/winston/transports/daily-rotate-file.js, function=null, line=499, method=null, native=false, column=15, file=fs.js, function=FSReqWrap.oncomplete, line=95, method=oncomplete, native=false], stack=[Error: ENOENT, no such file or directory 'server.log.2016-04-26', at Error (native), at Object.fs.unlinkSync (fs.js:883:18), at DailyRotateFile._getFile (/srv//node_modules/winston/lib/winston/transports/daily-rotate-file.js:537:12), at /srv/www//node_modules/winston/lib/winston/transports/daily-rotate-file.js:499:31, at FSReqWrap.oncomplete (fs.js:95:15)]

Need example how to use it

Hi,

I'm not familiar with winston logger, but know that this is great tools. Unfortunately this module winston-daily-rotate-file does not have documentation about variants how it can be used. I had to googling for tutorials for this.

const path = require('path');
const fs = require('fs');
const winston = require('winston');
require('winston-daily-rotate-file');

const tsFormat = () => (new Date()).toLocaleTimeString();

const logDirectory = path.join(__dirname, 'log');
fs.existsSync(logDirectory) || fs.mkdirSync(logDirectory);

const logger = new (winston.Logger)({
  transports: [
    // colorize the output to the console
    new (winston.transports.Console)({
      timestamp: tsFormat,
      colorize: true,
      level: 'info',
    }),
    new (winston.transports.DailyRotateFile)({
      filename: `${logDirectory}/log`,
      timestamp: tsFormat,
      datePattern: 'yyyy-MM-dd.',
      prepend: true,
      level: process.env.ENV === 'development' ? 'debug' : 'info',
    }),
  ],
});

logger.debug('Debugging info');
logger.verbose('Verbose info');
logger.info('Hello world');
logger.warn('Warning message');
logger.error('Error info');

Leave it here for the reference in case if someone will search it
parts from this http://thisdavej.com/using-winston-a-versatile-logging-library-for-node-js/

With maxfiles and maxsize options, older timestamped log files are not removed

When maxfiles option is set, for current timestapmed logfiles, it removes the oldfiles. For ex: if maxfiles=2 and pattern=.dd then on third rollover it will have logfile.01.log and logfile.01.log.1, Here it is deleting logfile.01.log and creating logfile.01.log.2

But if based on time rotation happens, it creates new timestamped log files say logfile.02.log, then it has no history of what files are there from previous timestamp. And it's not removing them.
Here in code
https://github.com/winstonjs/winston-daily-rotate-file/blob/master/index.js#L588
it removes only files having current timestamp in the name.

How should we proceed from here? Should we keep a list of all existing log files and remove one when creating new?

Find a new maintainer for this transport

THIS PROJECT IS NOW LOOKING FOR A NEW MAINTAINER. I will be continuing work on winston itself with gusto, but do not plan on spending cycles on this transport.

If you are interested please let me know.

Unable to publish new releases to NPM

@indexzero Im unable to publish new releases of winston-daily-rotate-file to npm. Will you please grant me permission to push new versions out there, or should I publish as a separate package?

Thanks!

Cannot launch container in production mode.

I have created an app using the following set of major modules:

yeoman generator-angular-fullstack (> 4.0.0)

and added in
"parse-server": "^2.2.18"

This parse server uses winston and winston-daily-rotate-file; and uses babel (es2015 preset).

During development everything goes fine but when I deploy over dokku (heroku-ish), I get the following error on the server (and the app fails to launch):

/app/node_modules/winston-daily-rotate-file/index.js:180
winston.transports.DailyRotateFile = DailyRotateFile;
^
TypeError: Cannot set property DailyRotateFile of # which has only a getter
at Object. (/app/node_modules/winston-daily-rotate-file/index.js:180:36)

Since dokku installs dependencies automatically, and I'm not an expert, I have no way of deploying the application with my currently known set of tools..

Any help?

log rotation feature crashes intermittently

Originally reported by @nikdunn here


I have no idea if it is related to the other crash issues I've seen documented, but I am seeing:

Error: ENOENT, open '/work/server/server.log'

Every once in a while. In the directory there is a server.log.gz that is 0 bytes along with other log files that have been successfully rotated.

The issue seems to happen when logging frequency and content is high.

I've handled the uncaught exception, but there's not really anything I can do about it since the logger blew chunks.

I'm doing:

winston.add(winston.transports.File, {
    filename: __dirname + '/server.log',
    json: false,
    colorize: true,
    timestamp: true,
    maxsize: 10000000,
    maxFiles: 50,
    showLevel: true,
    tailable: true,
    zippedArchive: true,
});
winston.remove(winston.transports.Console);

datePattern folder do not exist

Hello, please help to find a way to solve this problem
i want to separate log files by day in the folder

2017-02-15
 - errors.log
 - warning.log
 - etc...
2017-02-16
 - errors.log
 - warning.log
 - etc...

My date pattern loook like this
datePattern: '../yyyy-MM-dd/.log', createTree: true

But i get an error.code === 'ENOENT'

Where should i catch this error so my log wasn't lost and folder created ?

NPM-package differs from master branch

I installed winston-daily-rotate-file from NPM-registry. I tried to use the 'prepend' option but it did not work. The NPM-package differs from master branch since the NPM-package version does not contain the 'prepend' option while the github-version contains this option (I looked into both source codes).

Log files are rotated every minute even if datePattern specifies only daily rotation

Even if the pattern is '.yyyy-MM-dd', the log files are rotated based on minutes. The new stream (self._createStream()) are opened even when the log files are one minute older (this._minute < now.getUTCMinutes()). https://github.com/winstonjs/winston-daily-rotate-file/blob/master/index.js#L395 . Also attempt to open next appropriate file also called each one minute and self._created is set to 0 every minute. https://github.com/winstonjs/winston-daily-rotate-file/blob/master/index.js#L551

I think the new stream creation should happen based on given pattern.

Daily/chained checksum

Originally reported by @Slade-X at winstonjs/winston#517

It would be nice if it was possible to have an event when the Daily Rotate create a new file, i need to insert a sha1 / md5 of the previous file in the first line of the new log (and if this function can be added too as standard)

should create directory if it does not exist

if you specify a directory in options (options.dirname) that does not exist yet then no files will be created and no errors will be emitted (fails silently).

'use strict';

const winston = require('winston');
const FileRotator = require('winston-daily-rotate-file');
const path = require('path');

var logger = new(winston.Logger)();

logger.level = 'silly';

logger.add(FileRotator, {
  datePattern: 'yyyy-MM-ddTHH:mm',
  dirname: path.join(__dirname, 'logs'),
  filename: 'output.log',
  json: false,
  formatter: (options) => `foo, bar, baz: ${options.level} ${options.message}`
    // prepend: true
});

let i = 0;
setInterval(() => {
  logger.info(`floof: ${i++}`);
}, 1000);

Error with node 6.x ... can it be the strict mode?

I have my project build by travis-ci with different node versions and with node 6.x the following errr occurs:

winston.transports.DailyRotateFile = DailyRotateFile;
                                   ^
TypeError: Cannot set property DailyRotateFile of #<Object> which has only a getter
    at Object.<anonymous> (/home/travis/build/Apollon77/ioBroker.nut/node_modules/winston-daily-rotate-file/index.js:170:36)
    at Module._compile (module.js:541:32)
   at Object.Module._extensions..js (module.js:550:10)
   at Module.load (module.js:456:32)
   at tryModuleLoad (module.js:415:12)
    at Function.Module._load (module.js:407:3)
    at Module.require (module.js:466:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/travis/build/Apollon77/ioBroker.nut/tmp/node_modules/iobroker.js-controller/lib/logger.js:6:23)
    at Module._compile (module.js:541:32)

I found something comparabe in Winston issues on github and it was caused by "strict" mode there ... and this lib uses strict mode. Can this be the cause somehow?

The maxFile and maxsize property isn't working.

To test my code, I am rotating the log file every minute.

var logger = new (winston.Logger)({
  transports: [
    new (winston.transports.Console)({ json: true, timestamp: true, colorize: true }),
    new (require('winston-daily-rotate-file'))({ dirname: '/'+__dirname , filename: 'debug.log', datePattern: '.yyyy-MM-ddTHH-mm', maxFiles: 2, maxsize: 104857600 })
  ],
  exceptionHandlers: [
    new (winston.transports.Console)({ json: true, timestamp: true, colorize: true }),
    new winston.transports.File({ filename: __dirname + '/exceptions.log', json: true })
  ],
  exitOnError: false
});

My sample code for logging is here -

var recursive = function () {
  logger.debug('log to file');
  logger.info("127.0.0.1 - there's no place like home");
  logger.warn("127.0.0.1 - there's no place like home");
  logger.error("127.0.0.1 - there's no place like home");
  setTimeout(recursive,15000);
}
recursive();

Now at this setup, it creates one log file every minute without deleting the older ones. Am I doing anything wrong here?

File count rotate issue or requirement.

Originally reported by @geforcesong at winstonjs/winston#660

Hello Guys,

I am using Winston for logging in my project. There is a requirement for us I don't know how to implement or can you please kindly modify the package to have that feature for us.
The thing is as follows,
when use file rotation and set maxfiles and maxsize, it works but it will add new file count at the end of each log file, which is

when set maxfiles to 5,
access.log, access1.log, access2.log, access3.log, access4.log
then it will keep increasing to,
access1.log, access2.log, access3.log, access4.log, access5.log
then it will keep increasing to,
access2.log, access3.log, access4.log, access5.log, access6.log

This is current behavior, however what we want is that if reach the maxfiles, we should use the first file name instead of increasing the file count all the time.
that is it will always have these files,
access.log, access1.log, access2.log, access3.log, access4.log

when reach the access4.log, then delete the first access.log and create a new access log and log the data in this file.
BTW, i have set the zippedArchive to true, but i didn't see the files got zipped

Two issues if zippedArchive is true

There are two different issues I encountered with the file compression:

  1. The old file doesn't get compressed if there is only one log entry. The problem seems to be that the archive is not set when the stream is created.
  2. After the third file that is being generated, the new file gets the counter appended to the filename, even when the new filename is unique.

I wrote two tests to demonstrate the above mentioned problems:

describe('when zippedArchive is true', function () {
  var pattern = {
    pattern: '.m',
    start: 1861947160000, // GMT: Mon, 01 Jan 2029 07:32:50 GMT
    mid: 1861947240000, // GMT: Mon, 01 Jan 2029 07:34:00 GMT
    end: 1861947760000, // GMT: Mon, 01 Jan 2029 07:42:40 GMT
    oldfile: 'test-rotation.log.32',
    midfile: 'test-rotation.log.34',
    newfile: 'test-rotation.log.42'
  };

  var transport;
  var rotationLogPath = path.join(fixturesDir, 'rotations');
  beforeEach(function (done) {
    this.time = new Date(pattern.start);
    tk.travel(this.time);
    rimraf.sync(rotationLogPath);
    mkdirp.sync(rotationLogPath);
    transport = new DailyRotateFile({
      filename: path.join(rotationLogPath, 'test-rotation.log'),
      datePattern: pattern.pattern,
      zippedArchive: true
    });

    done();
  });

  afterEach(function () {
    tk.reset();
  });

  it('should compress logfile even if there is only one log message', function (done) {

    var self = this;

    transport.log('error', 'test message', {}, function (err) {
      if (err) {
        done(err);
      }

      var filesCreated = fs.readdirSync(rotationLogPath);
      expect(filesCreated.length).to.eql(1);
      expect(filesCreated).to.include(pattern.oldfile);
      self.time = new Date(pattern.end);
      tk.travel(self.time);
      transport.log('error', '2nd test message', {}, function (err) {
        if (err) {
          done(err);
        }

        filesCreated = fs.readdirSync(rotationLogPath);
        expect(filesCreated.length).to.eql(2);
        expect(filesCreated).to.include(pattern.newfile);
        expect(filesCreated).to.include(pattern.oldfile + '.gz');
        transport.close();

        done();
      });
    });
  });

  it('should compress logfile without adding count to file extension if there are no files with the same name', function (done) {

    var self = this;

    transport.log('error', 'test message', {}, function (err) {
      if (err) {
        done(err);
      }
      transport.log('error', 'test message', {}, function (err) {
        if (err) {
          done(err);
        }

        var filesCreated = fs.readdirSync(rotationLogPath);
        expect(filesCreated.length).to.eql(1);
        expect(filesCreated).to.include(pattern.oldfile);
        self.time = new Date(pattern.mid);
        tk.travel(self.time);
        transport.log('error', '2nd test message', {}, function (err) {
          if (err) {
            done(err);
          }
          transport.log('error', 'test message', {}, function (err) {
            if (err) {
              done(err);
            }

            filesCreated = fs.readdirSync(rotationLogPath);
            expect(filesCreated.length).to.eql(2);
            expect(filesCreated).to.include(pattern.oldfile + '.gz');
            expect(filesCreated).to.include(pattern.midfile);
            self.time = new Date(pattern.end);
            tk.travel(self.time);
            transport.log('error', '3rd test message', {}, function (err) {
              if (err) {
                done(err);
              }
              transport.log('error', 'test message', {}, function (err) {
                if (err) {
                  done(err);
                }

                filesCreated = fs.readdirSync(rotationLogPath);
                expect(filesCreated.length).to.eql(3);
                expect(filesCreated).to.not.include(pattern.newfile + '.1');
                expect(filesCreated).to.include(pattern.newfile);
                expect(filesCreated).to.include(pattern.midfile + '.gz');
                expect(filesCreated).to.include(pattern.oldfile + '.gz');
                transport.close();

                done();
              });
            });
          });
        });
      });
    });
  });
});`

Fails to log to file with DailyRotateFile

Originally reported by @Efreak at winstonjs/winston#468

I see that issue was supposedly fixed with the File transport, however I'm having it with DailyRotateFile transport. I'm testing functionality, and it's failing. There's a simple example listed below. For my actual use case, check this trigger for my node-steam-chat-bot.

obscured@obscured:~/old-chatbots$ node
> var winston = require('winston');
undefined
> var logger = new winston.Logger;
undefined
> var b = logger.add(winston.transports.DailyRotateFile, { //don't spam me!
... level: "warn",
... colorize: false,
... timestamp: false,
... filename:'bot.corny.log',
... datePattern:"yyyy-MM-dd-m",
... json:false
... });
undefined
> logger.info("test test");
undefined
> obscured@obscured:~/old-chatbots$ ls bot.corny*
ls: cannot access bot.corny*: No such file or directory
obscured@obscured:~/old-chatbots$

npm package?

DailyRotateFile removed from winston core, but winston-daily-rotate-file not yet registered on npm.
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.