Comments (16)
In which case, I'd say one should be defined either way.
For our particular use case we've written a tool to read stdout logs from a separate process to determine the current state in the process lifetime. On startup, the tool should read the current contents of the file to get the current state, and follow the log so that it can be updated with further developments. I'd argue that functionality to this is similar to what most people would expect, though without further input that's just conjecture. :)
If that's not the desired functionality, perhaps a option should be added to the constructor, "immediate: true" or the like, to determine whether it should return the existing contents immediately? Without this, one must find an alternative means to read in the current content.
In the meantime, I've made it trigger immediately like this (Somewhat hacky, but it works):
var tail = new Tail("log_filename", {
fromBeginning: true
});
tail.on("line", function (line) {
...
});
tail.watchEvent.call(tail, "change");
from node-tail.
+1 i'm using @nathankunicki 's workaround for now
from node-tail.
Created PR with potential fix of this issue @lucagrulla @nathankunicki
from node-tail.
You are right, the current implementation needs one change to the file to deliver the "historical" content.
Given that at this stage the specific timing of that first delivery is undefined I would say that there's no actual expected behaviour.
from node-tail.
Most of people will observe file updates pretty much straight after tailing the file so they will be fine.
I'll flag this as a feature request but I'm not expecting to go work on this anytime soon.
As you observed as well I can't see a clean way to eventually add it as a feature, only hacky ones.
PRs are welcome, but they have to be pretty neat solutions :-)
cheers
L.
from node-tail.
+1
from node-tail.
+1
from node-tail.
+1
from node-tail.
+1. Starting delivery immediately would be the path of least surprise.
from node-tail.
+1
from node-tail.
Can you merge pls?
from node-tail.
HUGE thanks to @nathankunicki
from node-tail.
+1 Was definitely my initial expectation. Thanks for the workaround.
from node-tail.
any progress?
from node-tail.
Not yet.
from node-tail.
Fixed with version 2.0.0
from node-tail.
Related Issues (20)
- Assess flushAtEOF flag
- From beginning option does not work in release 2.1.0 HOT 1
- Event occurs after unwatching file HOT 2
- Error README example exception £Configuration HOT 1
- Tail crashes is file is deleted HOT 1
- rename logic is incorrect on Linux HOT 1
- add JSDoc and native TS support
- "Cannot use 'in' operator to search for 'follow'"
- Problem with tailing textfile in Windows HOT 3
- if nLines > count of separators, no lines are displayed
- nLines not working HOT 4
- Uncatchable error HOT 3
- Unit tests failing HOT 1
- Regex HOT 1
- Support RxJS with TypeScript check HOT 2
- delete data after read? HOT 1
- Carriage Return (\r) is messing up Mac (not tail's fault) HOT 2
- Crashes when using `nLines` with large files HOT 1
- infinite loop when tailing empty files HOT 1
- Possible regression at 2.2.0?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-tail.