Dear perlmonks,
I use TimingBotDBI in a daemon, but otherwise in a very similar fashion as in the example. In the article it says that a commit is only necessary if Mysql AutoCommit is off. I make a connection with the Mysql database in another module like so:
my $dbh = DBI->connect($dsn,$user,$pass,{RaiseError => 0, AutoCommit = +> 1, $driver eq 'mysql' ? (mysql_enable_utf8 => 1) : (), });
So, AutoCommit is on.
I pass the database handler around as a reference and part of a larger session object, so the log handler and database handler are easy accessible everywhere.
I noticed that I have to call a commit to the TimingBotDBI object or otherwise nothing gets saved in the database. I think it's the DBI modules that throws this warning:
commit ineffective with AutoCommit enabled at /usr/local/share/perl/5.10.0/XML/RSS/TimingBotDBI.pm line 83.This is because the commit function in TimingBot does a commit on the database handler. Of course this is not a big problem. But I'm curious: Could I do this in a more elegant way and avoid this warning?
And I have a second question. I use Log4perl. The warning is printed to the command line. Is it possible to print it to my log handler? Or is this impossible as ikegami suggests in his final paragraph here: http://www.perlmonks.org/?node_id=688741#688764
I create my log like this as a method of my session. I attempt to print to the log when the code is run as a daemon and to the command line when it's run on the command line, like so:
sub log { my $self = shift; my $output = shift; unless ( exists $self->{ _log } ) { Log::Log4perl->init( $self->getRoot( "/etc/log.conf" ) ); my $log = Log::Log4perl->get_logger( $0 ); if ( defined $log ) { $self->{ _log } = $log; } } unless( $self->{ _daemonize } ) { my $log2cmdline = Slurper::Log->new(); $self->{ _log } = $log2cmdline; } return $self->{ _log }; }
And I tried to redirect the STDERR like so:
open STDERR, '>>', $session->log->debug;Any insight as into how to do a better job is greatly appreciated.
Kind regards,
Arjan.
Moved from thread Perl RSS aggregator by Arunbear
In reply to Perl RSS aggregator by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |