From: Kevin G. <ke...@go...> - 2003-01-21 17:16:20
|
> * Also, I thought that filter_message would be a code ref which could > be used to manipulate logger arguments? I think the appender should > be able to correct any log statement argument list (like limit it to > the number of arguments it expects etc.) Yes, it is, see Appender.pm line 135: #filter_message is defined and true }else{ $p->{message} = $self->{filter_message}->($p->{message}); #syntax ok for perl5? } But it still needs testing, documentation, and accessor methods in appender. I can do them unless you get around to it first. > * could you please add some comments to the "Changes" file (also > about the XML-DOM addition) Done, thanks for reminding me. Did I forget anything? * (kg) Split config bits into PropertyConfigurator and implemented DOMConfigurator for XML configs. * (kg) Adding appender.filter_message parameter as a help to DBI appender * (kg) Added NoopLayout to help DBI appender > * I've corrected Ceki's name in the DOMConfiguration docs with > umlauts, these crazy Europeans are so adamant about it :) I was wondering how to approach those. I'm don't think using character 0xFC for u-with-diaeresis will translate into systems using other non-ISO8859 character sets (like DOS using CP437 or Macs using MacRoman). But I didn't feel like rebooting into Windows just to check the file in EDIT, so that's cool. > Also, is there a URL to the original spec we could add? Not really, their only "spec" is the log4j DTD and I didn't want to write a link to that since it's buried in their site and could very well move around. When I finish implementing our additions, I'm going to circulate a log4perl DTD for comments and then include it in our distribution. But I did add a note to see t/038XML-DOM1.t for examples. > * in the DBI appender's docs, the sentence "You can mix up the order > the placeholders with %x specifiers as you see fit" seems to be > missing an "of" and I'm confused about what the %x specifier does in > this context. > * What happens in case PatternLayout is chosen instead of NoopLayout? > Probably needs to be documented. Oh, boy, that documentation was truly awful. Thanks for the proofread. I expanded/rewrote that section, it's checked in and listed below for your convenience. Any better? Any criticism welcome! ---------------------------------------------------------------- Normally a list of things in the logging statement gets concatenated into a single string, but setting C<filter_message> to 0 and using the NoopLayout means that in $logger->warn( 1234, 'warning message', 'bgates' ); the individual list values will still be available for the DBI appender later on. (If C<filter_message> is not set to 0, the default behavior is to join the list elements into a single string. If PatternLayout or SimpleLayout are used, their attempt to C<render()> your layout will result in something like "ARRAY(0x841d8dc)" in your logs. More information on C<filter_message> is in Log::Log4perl::Appender.) In your insert SQL you can mix up '?' placeholders with conversion specifiers (%c, %p, etc) as you see fit--the logger will match the question marks to params you've defined in the config file and populate the rest with values from your list. If there are more '?' placeholders than there are values in your message, it will use undef for the rest. For instance, log4j.appender.DBAppndr.sql = \ insert into log4perltest \ (loglevel, message, datestr, subpoena_id)\ values (?,?,?,?) log4j.appender.DBAppndr.params.1 = %p log4j.appender.DBAppndr.params.3 = %d log4j.appender.DBAppndr.filter_message=0 $logger->info('arrest him!', $subpoena_id); results in the first '?' placholder being bound to %p, the second to "arrest him!", the third to the date from "%d", and the fourth to your $subpoena_id. If you forget the $subpoena_id and just log $logger->info('arrest him!'); then you just get undef in the fourth column. msc...@ao... wrote: > In a message dated 1/20/2003 12:40:27 PM Eastern Standard Time, Kevin > Goess <ke...@go...> writes: > > >> The new stuff is checked in, all tests pass. > > > That's great news, thanks! Couple of notes: > > * in the DBI appender's docs, the sentence "You can mix up the order > the placeholders with %x specifiers as you see fit" seems to be > missing an "of" and I'm confused about what the %x specifier does in > this context. > > * What happens in case PatternLayout is chosen instead of NoopLayout? > Probably needs to be documented. > > * Also, I thought that filter_message would be a code ref which could > be used to manipulate logger arguments? I think the appender should > be able to correct any log statement argument list (like limit it to > the number of arguments it expects etc.) > > * could you please add some comments to the "Changes" file (also > about the XML-DOM addition) > > * I've corrected Ceki's name in the DOMConfiguration docs with > umlauts, these crazy Europeans are so adamant about it :) Also, is > there a URL to the original spec we could add? > > BTW, I'm gonna add a couple of test cases for the new { filter => > \&filter, value => $value} syntax. > > All test cases run fine on my box, too, looks good so far! > > -- Mike > > ############################ # Mike Schilli # # > log...@pe... # # http://perlmeister.com # # > log4perl.sourceforge.net # ############################ > -- Happy Trails . . . Kevin M. Goess (and Anne and Frank) 904 Carmel Ave. Albany, CA 94706 (510) 525-5217 |