[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Re: Tail -f in lua, truncate aware?
- From: Sean Conner <sean@...>
- Date: Sat, 29 Jun 2013 06:01:51 -0400
It was thus said that the Great ms2008vip once stated:
> First please excuse my English, It's not my natural language, Sorry.
> Let's on-topic,
>
> I just want to emulate "tailf" or "tail -F" in lua, and I need that to
> monitor log files in order to see new messages as soon they are
> enqueued(follow the growth of a log file). Then I need to handle the
> output by line, format that or do something other. And I hope it will
> recognize when file that I tailing is been truncated, it also isn't need
> too much overhead(like tailf that does not access the file when it is not
> growing). I scoured the web, but wasn't able to find a precise answer.
>
> Does the above sounds familiar to someone? Any hints, tips or comments
> would be most gratefully received. Awaiting your reply.
Yes, but you need to answer the following question: are the log files you
wish to monitor generated by syslog (or rsyslog or syslog-ng)? If that is
not the case, then the quick answer is "that is not an easy thing to do."
It's not to say it can't be done, but it's not something that is easy to say
"do this, this and this."
If the log files *are* generated by syslog (or rsyslog or syslog-ng) then
the answer is "that is possible, but not by looking at the log files." I say
this because that is something I am doing, and it just so happens that I am
doing so with Lua. You can see the code here:
https://github.com/spc476/syslogintr
but it requires knowledge of syslog to use effectively (mainly because you
need to configure syslog (or rsyslog or syslog-ng) to forward its logs and
unfortunately, that is something beyond the scope of this list).
-spc