strongloop / modern-syslog

modern-syslog
Other
49 stars 19 forks source link

Messages are not logged in order #30

Closed sapir1779 closed 5 years ago

sapir1779 commented 5 years ago

I'm using modern-syslog version 1.1.4, OS: Ubuntu 18.04.1 LTS.

The below program generates out-of-sync log messages:

const syslog = require('modern-syslog');
setInterval(function(){ 
    syslog.log(syslog.LOG_INFO, "1");
    syslog.log(syslog.LOG_INFO, "2");
    syslog.log(syslog.LOG_INFO, "3");
    syslog.log(syslog.LOG_INFO, "4");
}, 3000);

The expected sequence is NOT always "1, 2, 3, 4", but rather a permutation of 1,2,3,4 (e.g., "1,4,2,3"). [I'm looking at /var/log/syslog]

Perhaps I'm missing something and when you mentioned "async" in the description this is what you meant but otherwise this is major.

bnoordhuis commented 5 years ago

Yes, that's what async means. You're basically sending four log messages in parallel; first past the post wins, so to speak.

If you want to sequence them, use callbacks or promisify and async/await them.

bnoordhuis commented 5 years ago

I'm going to close this as answered. If there's reason to reopen, let me know.