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...