[log4perl-devel] suggested patch for Log::Log4perl::Appender::DBI
Hi,
In the Appender::DBI man page, we see the following sentence,
"If there are more '?' placeholders than there are values in
your message, it will use undef for the rest." However, I was
unable to observe this behaviour with my configuration.
I used the following tiny patch to Appender::DBI.pm to get
the described behaviour and it may be of general interest.
It does rely on the DBI statement handle attribute NUM_OF_PARAMS
which is driver dependent, however I can't currently see any other
way of achieving this.
--- ./original/Log/Log4perl/Appender/DBI.pm 2007-03-15
07:53:47.0 +
+++ ./patched/Log/Log4perl/Appender/DBI.pm 2007-12-13
15:00:48.0 +
@@ -134,6 +134,13 @@
for my $attempt (0..$self->{reconnect_attempts}) {
#warn "Exe: @qmarks"; # TODO
+
+# if we're short of bind variables, fill in the remainder
with undef
+if( $sth->{NUM_OF_PARAMS}-1 > $#qmarks ){
+# use the old "assign past the end of array to
extend it" thing.
+undef $qmarks[$sth->{NUM_OF_PARAMS}-1];
+}
+
if(! $sth->execute(@qmarks)) {
# Exe failed
# warn "Log4perl: DBI->execute failed $DBI::errstr,
\n".
- Mark
-
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
log4perl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel
Re: [log4perl-devel] suggested patch for Log::Log4perl::Appender::DBI
Mark Blackman wrote:
> In the Appender::DBI man page, we see the following sentence,
> "If there are more '?' placeholders than there are values in
> your message, it will use undef for the rest." However, I was
> unable to observe this behaviour with my configuration.
Odd, it looks like it's working to me. What was the behavior you *did*
obverve? Can you send a test case to demonstrate the problem?
Here's the part of the existing code that handles the case, it looks ok
to me:
#here handle cases where we ran out of message bits
#before we ran out of bind_value_layouts, just keep going
}elsif (ref $p->{message} eq 'ARRAY'){
$msg = undef;
$p->{message} = undef;
I just added test cases to the unit test to demonstrate the behavior and
it looks ok. Could you download this guy and see if it runs for you?
(You'll need to 'mkdir -p t/tmp/')
http://log4perl.cvs.sourceforge.net/*checkout*/log4perl/Log-Log4perl/t/034DBI.t?revision=1.15&content-type=text%2Fplain
-
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
log4perl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel
