From: Mark B. <md...@ji...> - 2003-01-29 00:24:03
|
[ widened to include Dave Rolsky; Dave feel free to join/ignore as you see fit ] >> On Tue, 28 Jan 2003 12:47:36 EST, >> Mschilli1 (M) wrote: M> In a message dated 1/28/03 7:52:16 AM Pacific Standard Time, M> md...@ji... writes: M> Is there a relatively simple way to insert the message severity M> into the Log::Dispatch::Email appender? M> For example, we want $log->debug("foo") to send an email with M> the subject line "$0: [DEBUG] log email", $log->warn("bar") to M> have the subject "$0: [WARN] log email", etc. M> That's all up to the appender to define. Unfortunately, the M> currently available ones (Log::Dispatch::Email::MailSend etc.) all M> define the "subject" line at appender initialization time but won't M> allow you to modify it dynamically with every log request. What M> you could do (and that's actually easier than it sounds like at M> first) is write your own mail appender -- basically just one method M> that sends out the mail, using something like Mail::Send, that's M> it. M> Does that sound reasonable? Any questions let me know. Yes, aside from one design issue: in the case of buffered objects, what should the subject line severity be? In Log::Dispatch::Email there are the methods, sub log_message { my $self = shift; my %p = @_; if ($self->{buffered}) { push @{ $self->{buffer} }, $p{message}; } else { $self->send_email(@_); } } and sub flush { my $self = shift; if ($self->{buffered} && @{ $self->{buffer} }) { my $message = join '', @{ $self->{buffer} }; $self->send_email( message => $message ); $self->{buffer} = []; } } I was thinking I could just make the buffer an array of arrays, e.g., push @{ $self->{buffer} }, [$p{log4p_level},$p{message}]; and then fix up flush() to match. But then what would one send to send_email()? $self->send_email( subject => undef, message => $message ); where the undefined subject above would need some indicator of the maximum level of the log message(s) contained in the body of the message. I'm beginning to see why Dave Rolsky may have left this unimplemented. Ideas? -- -mb- |