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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.