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

FileLoggerAdapter.getLogs does not get the latest log messages #1563

Closed
blacha opened this issue Apr 20, 2016 · 2 comments
Closed

FileLoggerAdapter.getLogs does not get the latest log messages #1563

blacha opened this issue Apr 20, 2016 · 2 comments

Comments

@blacha
Copy link
Contributor

blacha commented Apr 20, 2016

When logging out a number of messages, when doing a query ordering by desc, will return the oldest messages then order them by time.

var fileLogger = new FileLoggerAdapter();
for (var i = 0; i < 10; i ++) {
    fileLogger.info(i);
}

// Wait for the logs to flush before querying 
setTimeout(function() {
    fileLogger.query({size:2, order: 'desc'})
        .then((res)=> {
            console.log(res)
        });
}, 100);

In this output res will be

[ { level: 'info',
    message: '1',
    timestamp: '2016-04-20T07:12:53.376Z' },
  { level: 'info',
    message: '0',
    timestamp: '2016-04-20T07:12:53.375Z' } ]

Its not until the size is expanded to all of the log messages that it gets them all in the right order.

Ideally this should return

[ { level: 'info',
    message: '9',
    timestamp: '2016-04-20T07:12:53.377Z' },
  { level: 'info',
    message: '8',
    timestamp: '2016-04-20T07:12:53.377Z' } ]
@blacha
Copy link
Contributor Author

blacha commented Apr 20, 2016

Looks like this is a problem with rotating file logger

https://github.com/winstonjs/winston-daily-rotate-file/blob/master/index.js#L305

Will break out of the query when the number of rows reach the limit, in my case two rows. Then it will reverse it in the close

https://github.com/winstonjs/winston-daily-rotate-file/blob/master/index.js#L288

@hramos
Copy link
Contributor

hramos commented Jul 27, 2016

We're closing this issue due to inactivity.

If this is a bug you care about that is not getting attention, consider opening a pull request with a fix.

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

2 participants