Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: [threads] Open a file in one thread and allow others to write to it

by roboticus (Chancellor)
on Nov 16, 2009 at 11:24 UTC ( [id://807416]=note: print w/replies, xml ) Need Help??


in reply to [threads] Open a file in one thread and allow others to write to it

Gangabass:

Not an answer to your question, but I tend to use time rather than log file size. I typically name my log files like "foolog.YYYYMMDD_HHMM" and then in the logging function if the log file is old enough, I close it & open a new one.

...roboticus
  • Comment on Re: [threads] Open a file in one thread and allow others to write to it

Replies are listed 'Best First'.
Re^2: [threads] Open a file in one thread and allow others to write to it
by Gangabass (Vicar) on Nov 16, 2009 at 11:38 UTC

    I call it log but this is just text file containing data parsed from Web page. And it's name format is defined by the user in the config file.

      Why not have a shared variable which you write the 'log' to, say an array which holds the information for each line entry, and a thread which keep an eye on the size of the shared array and dumps it out when it hits whatever size you want and resets it.

      This way you don't need to worry about shared filehandles, only a shared in-memory variable ( IPC::Sharable seems to be the usual way of doing this ), and you have separated the 'logging' function from the 'collection' function.

      Just a something something...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-24 01:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found