From: Kevin G. <ke...@go...> - 2003-01-28 16:40:16
|
Yes, but you have to use the current (soon-to-be-released) version of log4perl from our cvs. The problem is making the severity information available to the your email subclass at the time it's doing the logging. I was having the same problem implementing the DBI appender, so we added the feature: If your derived email class looks like this package Log::Dispatch::Email::MySender; use Log::Dispatch::Email; use base qw( Log::Dispatch::Email ); sub log { my $self = shift; my %args = @_; #save the level so we can get at it later $self->{log4p_level} = $args{log4p_level}; #continue processing as before $self->SUPER::log(@_); return; } sub send_email { my $self = shift; my %p = @_; my $prog = $0; $prog =~ s/"//g; #security!! print qq{sending mail: /bin/mail -s "$prog [$self->{log4p_level}] log email" @{$self->{to}}\n}; } Mark Borges wrote: > Is there a relatively simple way to insert the message severity into > the Log::Dispatch::Email appender? > > For example, we want $log->debug("foo") to send an email with the > subject line "$0: [DEBUG] log email", $log->warn("bar") to have the > subject "$0: [WARN] log email", etc. > > Currently, the recipient of the email is forced to read the body of > the message to learn its severity. > > Thanks. > > P.S. I know, suppressing the email of DEBUG and INFO messages via > threshold may be more desirable, but that is an ongoing debate > in our group. > > > > ------------------------------------------------------- > This SF.NET email is sponsored by: > SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! > http://www.vasoftware.com > _______________________________________________ > log4perl-devel mailing list > log...@li... > https://lists.sourceforge.net/lists/listinfo/log4perl-devel -- Happy Trails . . . Kevin M. Goess (and Anne and Frank) 904 Carmel Ave. Albany, CA 94706 (510) 525-5217 |