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

Fix: File Transport not flush buffers to file #1868

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

adoyle-h
Copy link
Contributor

fix #228 #1504

Test Case:

// ./test/helpers/scripts/logger-end-and-process-exit.js
'use strict';

const path = require('path');
const winston = require('../../../lib/winston');

var logger = winston.createLogger({
  transports: [
    new winston.transports.File({
      filename: path.join(__dirname, '..', '..', 'fixtures', 'logs', 'logger-end-and-process-exit.log')
    })
  ]
});

logger.on('finish', () => {
  process.exit(0);
});

logger.info('CHILL WINSTON!', { seriously: true });

logger.end();

*/
_waitStreamsCreatedButNotPiped(cb) {
if (this._destOpened) {
return cb();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially violates the @returns {undefined} docs as cb could return anything?

}

this.once('startPipe', () => {
this._dest.once('finish', () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arrow function not required?

this._dest.once('finish', cb);

cb();
});

this.close(() => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arrow function not required?

this.close(this._endStream);

@adoyle-h
Copy link
Contributor Author

@rheh Fixed. Please review again.

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

Successfully merging this pull request may close these issues.

Logging to file fails when calling process.exit(0)
2 participants