I want to set up Log::Dispatch with two outputs... "file" and "email". I'd like to use a callback function to do custom formatting of the message based on whether the output is going to a logfile or email.
I.E. a one line entry if sent to logfile and a verbose description, possibly including html, hyperlinks, etc if sent by email. I figured since the log method supports sending arbitrary named pairs to the callback function, all I needed to do was get the name of the Dispatch object doing the logging, and have the callback do the necessary formatting based on the destination, but getting the name of the Dispatch object is proving to be beyond my very measly perl programming skills! Any help would be greatly appreciated! Thanks, -Dan [EMAIL PROTECTED] (remove reverse("nospam") to reply via email.) Spambots are getting waaay too smart nowadays! ====================== Sample code follows: ====================== #!/usr/local/bin/perl -w use Log::Dispatch; use Log::Dispatch::Email::MailSend; use Log::Dispatch::File; use Data::Dumper; $sub = sub { my %p = @_; ############################################## # if $p{type} == "email" do some formatting on $p{message}; # else do something else... or maybe nothing ;-P ############################################## print Dumper(\%p); return $p{message}; }; $dispatcher = Log::Dispatch->new( callbacks => $sub); $dispatcher->add( Log::Dispatch::File->new( name => 'file1', min_level => 'debug', mode => 'append', filename => 'logfile' ) ); $dispatcher->add( Log::Dispatch::Email::MailSend->new( name => 'email', min_level => 'error', to => [ qw( [EMAIL PROTECTED] [EMAIL PROTECTED] ) ], subject => 'Oh no!!!!!!!!!!!') ); ################################################################# # Need to get "type" to reflect dispatcher->outputs->name... ################################################################# $dispatcher->log( level => 'error', message => "ERROR level logging test\n", type=>"???" ); print Dumper(\$dispatcher); #EOF -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>