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

How can I determine when the file stream has finished writing? #373

Open
Hawley-hy opened this issue May 22, 2023 · 1 comment
Open

How can I determine when the file stream has finished writing? #373

Hawley-hy opened this issue May 22, 2023 · 1 comment

Comments

@Hawley-hy
Copy link

Hawley-hy commented May 22, 2023

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

const logger = winston.createLogger({
  transports: [
    new DailyRotateFile({
      dirname: 'logs',
      filename: 'log-%DATE%.log',
      datePattern: 'YYYY-MM-DD',
      zippedArchive: true,
    }),
  ],
});

logger.info('This is a log message.');

const currentDate = new Date().toISOString().slice(0, 10);

const logFileName = `log-${currentDate}.log`;

const logFileStream = logger.transports[0].stream;
logFileStream.on('finish', () => {
  console.log(`${logFileName}  stream done!`); // Not working ....
});

logFileStream.end();
@Hawley-hy Hawley-hy changed the title I want to upload the file to an S3 bucket every time the fileStream finishes writing. How can I determine when the file stream has finished writing? How can I determine when the file stream has finished writing? May 22, 2023
@Hawley-hy
Copy link
Author

please someone could help me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant