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

nLines not working #140

Closed
wesleymv opened this issue Jul 21, 2021 · 4 comments
Closed

nLines not working #140

wesleymv opened this issue Jul 21, 2021 · 4 comments

Comments

@wesleymv
Copy link

I am trying to use the nLines option, but it does not seem to work. When the file is modified, it brings more than one line.

Here is the code I am using:

Tail = require('tail').Tail;

tail = new Tail("C:/Users/pc/Desktop/watchfile/1.log", {nLines: 1});

tail.on("line", function(data) {
  console.log(data);
});

tail.on("error", function(error) {
  console.log('ERROR: ', error);
});

When it starts, it brings one line. But, brings many lines when file is modified.

I am sorry if this is just the wrong use of the library.

Thank you in advance

@lucagrulla
Copy link
Owner

lucagrulla commented Jul 21, 2021

Hello @wesleymv

nLines gives you the starting point. If more lines are appended to the file, they will be then emitted.

Are the multiple lines tailed when the file changes new lines?
Or are lines from the file before start tailing the file?

@wesleymv
Copy link
Author

wesleymv commented Jul 21, 2021

Hi @lucagrulla

The lines I get are in the old file. For example, 1.log contains:

1
2
3

when I add 4, this is the output:

31
2
3

if I remove the nLines and run the same steps (seems to omit last line):

1
2
3

@lucagrulla
Copy link
Owner

lucagrulla commented Jul 21, 2021 via email

@lucagrulla
Copy link
Owner

Fixed with v2.2.4

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