Winston: Property "tailable: true" is not working as declared for winston File Transport

Created on 23 Aug 2018  路  6Comments  路  Source: winstonjs/winston

Environment:

  • _winston@3_
  • _node -v :_ v8.6.0 and v10.7.0
  • _Operating System_ : Windows
  • _Language_ ES6

Problem:
I am using File winston transport in this way:

const fileTransport = new transports.File({
        filename: 'log.out',
        level: 'debug',
        maxsize: 100*1024, // 10 MB
        maxFiles: 3,
        json: false,
        tailable: true
    });

const logger = winston.createLogger({
    level: 'debug',
    format: combine(formatFile),
    transports: fileTransport,
    handleExceptions: true
});

File 'log.out' is created in necessary directory, but after the maxsize reached, logging is stopped, it means no files created.
But in 'tailable' property description "If true, log files will be rolled based on maxsize and maxfiles, but in ascending order. The filename will always have the most recent log lines. The larger the appended number, the older the log file"

I think, problem is that code of creating new and renaming old log files is unreachable:
_from_
https://github.com/winstonjs/winston/blob/a32aa3c74859054f0351ac26b3079a5bc21f82b5/lib/winston/transports/file.js#L600

_till_
https://github.com/winstonjs/winston/blob/a32aa3c74859054f0351ac26b3079a5bc21f82b5/lib/winston/transports/file.js#L609

due to internal error in asyncSeries() function:
https://github.com/winstonjs/winston/blob/a32aa3c74859054f0351ac26b3079a5bc21f82b5/lib/winston/transports/file.js#L615
https://github.com/winstonjs/winston/blob/a32aa3c74859054f0351ac26b3079a5bc21f82b5/lib/winston/transports/file.js#L12

and this code is also unreachable:
https://github.com/winstonjs/winston/blob/a32aa3c74859054f0351ac26b3079a5bc21f82b5/lib/winston/transports/file.js#L617
(only in case "maxFiles: 1", then tasks array is empty)

Similiar Github issues:
https://github.com/winstonjs/winston/issues/589
https://github.com/winstonjs/winston-daily-rotate-file/issues/23 ("still doesn't work with [email protected]")
https://github.com/winstonjs/winston/issues/1264

Most helpful comment

Sweet. We will be publishing a 3.x update to npm very soon!

All 6 comments

This may have just been fixed via merging #1420. Any chance you could give this a try using master, and seeing whether this works for you now? Thanks!

I can confirm that tailable is broken in 3.0.0 and fixed in master.

Sweet. We will be publishing a 3.x update to npm very soon!

Hi everyone!
Thank you for your fix!

I tested this fix and I have some results:
+ tailable parameter works in the way it is declared. It creates log files in ascending mode.
- but during the logging some log entries are placed in wrong log files or missed at all, and I am planning to provide examples for this case and found place in code, where the error occurred.

That would be great. If you figure out how to fix any errors in the code, that would be especially appreciated (feel free to open a PR!). Probably best to open a new issue if you find different errors in the code. Thanks again!

Closing this one for now since we got v3.1.0 published!

Was this page helpful?
0 / 5 - 0 ratings