There may be other ways, here is mine (unified diff, you need to patch your program):

--- 504441.pl 2005-11-01 10:19:54.000000000 +0200 +++ 504441.pl-new 2005-11-01 10:19:36.000000000 +0200 @@ -64,11 +64,25 @@ # Handle log resets and errors the same way for each file.^M log_reset => \&generic_log_reset,^M log_error => \&generic_log_error,^M + alarm_reset => \&alarm_reset,^M }^M );^M ^M +sub alarm_reset{^M + print "ALARM!\n";^M + my ($kernel, $heap) = @_[KERNEL, HEAP];^M + if ( exists( $heap->{'alarm'} ) ){^M + delete $heap->{'services'};^M + delete $heap->{'watchers'};^M + $kernel->delay_add( "alarm_reset", 10 );^M + $kernel->yield('_start');^M + }else{^M + $kernel->delay( "alarm_reset", 10 );^M + }^M +}^M +^M sub begin_watchers {^M - my $heap = $_[HEAP];^M + my ($kernel, $heap) = @_[KERNEL, HEAP];^M ^M while ( my ( $service, $log_file ) = each %logs_to_watch ) {^M my $log_watcher = POE::Wheel::FollowTail->new^M @@ -81,6 +95,7 @@ $heap->{services}->{ $log_watcher->ID } = $service;^M $heap->{watchers}->{ $log_watcher->ID } = $log_watcher;^M }^M + $kernel->yield('alarm_reset');^M }^M ^M # Handle log resets the same way for each file. Simply recognize tha +t^M @@ -171,6 +186,8 @@ __DATA__^M # fullpath filter^M # ------------------------ ---------^M +/var/log/everything/current msg^M +/var/log/mail/current mail^M /var/log/cron cron^M /var/log/maillog mail^M /var/log/ppp.log ppp^M

Basically you need to receive an event when config file changes. You can setup an alarm to check this periodically, or any other means to be immediately notified.

Then, re-read your configuration file (you need to get rid of _DATA_ and use a procedure that returns you the hash), get the new files, delete your old FollowTail wheels, and create brand-new ones using begin_watchers.

I get advantage of the fact that you use %logs_to_watch like a "global", but I'd advise you to store all your "globals" to the HEAP.

Oh and a final note: the program doesn't change the log files, just shows you how to renew your wheels. And it isn't tested ;-)

Dodge This!

In reply to Re: Adding flexibility to Watching_Logs example in POE Cookbook by Ultra
in thread Adding flexibility to Watching_Logs example in POE Cookbook by shockers

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.