Coder Social home page Coder Social logo

Comments (16)

nathankellenicki avatar nathankellenicki commented on June 5, 2024 7

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.

geogeim avatar geogeim commented on June 5, 2024 2

+1 i'm using @nathankunicki 's workaround for now

from node-tail.

vnevgen avatar vnevgen commented on June 5, 2024 2

Created PR with potential fix of this issue @lucagrulla @nathankunicki

from node-tail.

lucagrulla avatar lucagrulla commented on June 5, 2024

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.

lucagrulla avatar lucagrulla commented on June 5, 2024

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.

 avatar commented on June 5, 2024

+1

from node-tail.

rohit-lakhanpal avatar rohit-lakhanpal commented on June 5, 2024

+1

from node-tail.

CiscoKidxx avatar CiscoKidxx commented on June 5, 2024

+1

from node-tail.

colbygk avatar colbygk commented on June 5, 2024

+1. Starting delivery immediately would be the path of least surprise.

from node-tail.

asvetin avatar asvetin commented on June 5, 2024

+1

from node-tail.

suculent avatar suculent commented on June 5, 2024

Can you merge pls?

from node-tail.

mojo2405 avatar mojo2405 commented on June 5, 2024

HUGE thanks to @nathankunicki

from node-tail.

peterg19 avatar peterg19 commented on June 5, 2024

+1 Was definitely my initial expectation. Thanks for the workaround.

from node-tail.

psi-4ward avatar psi-4ward commented on June 5, 2024

any progress?

from node-tail.

lucagrulla avatar lucagrulla commented on June 5, 2024

Not yet.

from node-tail.

lucagrulla avatar lucagrulla commented on June 5, 2024

Fixed with version 2.0.0

from node-tail.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.