rotating-file-stream
rotating-file-stream copied to clipboard
[bug] File not rotating when using a generator function
Hey there, I'm trying to use you package for my pino logger like so:
import { Logger as PinoLogger } from './logger.package';
const rfsa = require('rotating-file-stream');
const pad = (num: number) => (num > 9 ? "" : "0") + num;
const generator = () => {
const time = new Date();
const year = time.getFullYear();
const month = pad(time.getMonth() + 1);
const day = pad(time.getDate());
const hour = pad(time.getHours());
return `application-${year}-${month}-${day}-${hour}.log`;
}
const stream = rfsa.createStream(generator, {
interval: '15s',
compress: true,
path: 'logs'
})
const logger = new PinoLogger(stream);
export { logger };
export type { ILogger } from './libs/interfaces/interfaces';
This doesn't rotate the file. But when I provide a filename directly like so, it does:
const stream = rfsa.createStrearm('sample.log', { interval: '15s', compress: true, path: 'logs' })