Skip to content

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

Closed
@blacha

Description

@blacha

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' } ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions