Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: perlish way to 'tail -100 $logfile'

by isotope (Deacon)
on Dec 09, 2005 at 18:04 UTC ( [id://515613]=note: print w/replies, xml ) Need Help??


in reply to perlish way to 'tail -100 $logfile'

Does your log need to be a rolling log that always contains the most recent entries, or can it simply be restarted whenever it gets too big? This make a difference in your approach. Your tail example leans more toward the former, while something like logrotate that just periodically clobbers (or archives) the file if it's too large would accomplish the latter and be much simpler.
Update: To maintain a rolling logfile, if your program is persistent during a login session, you could simply maintain the most recent data internally (using an array of individual log entries, for example, push a new entry and shift the oldest one off), then dump the entire log to file each time it's updated. Not the best for maintaining logfile integrity, but the code would be very clean.


--isotope

Replies are listed 'Best First'.
Re^2: perlish way to 'tail -100 $logfile'
by gri6507 (Deacon) on Dec 09, 2005 at 19:12 UTC
    ideally, I would like to do a rolling log of 100 most recent entries, but I would not want to keep it in the memory because at any time during the customer's login session (during the program execution), they could want to take a look at the log file.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://515613]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-03-28 14:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found