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

Messages are not logged in order #30

Closed
sapir1779 opened this issue Dec 31, 2018 · 2 comments
Closed

Messages are not logged in order #30

sapir1779 opened this issue Dec 31, 2018 · 2 comments
Labels

Comments

@sapir1779
Copy link

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.

@sapir1779 sapir1779 changed the title Does not log messages in order Messages are not logged in order Dec 31, 2018
@bnoordhuis
Copy link
Member

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
Copy link
Member

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

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

No branches or pull requests

2 participants