--- trunk/bin/irc-logger.pl 2008/04/05 21:08:27 133 +++ trunk/bin/irc-logger.pl 2008/07/18 20:29:45 140 @@ -255,13 +255,20 @@ eval { $sth->execute( $value, $nick, $channel, $name ) }; - # error or no result - if ( $@ || ! $sth->rows ) { + if ( $@ ) { + # error + _log("META ERROR: $@"); + } elsif ( ! $sth->rows ) { + # no result -> add new $sth = $dbh->prepare(qq{ insert into meta (value,nick,channel,name,changed) values (?,?,?,?,now()) }); - $sth->execute( $value, $nick, $channel, $name ); - warn "## created $nick/$channel/$name = $value\n"; + eval { $sth->execute( $value, $nick, $channel, $name ); }; + if ( $@ ) { + _log "META ERROR: $@"; + } else { + _log "META: created $nick/$channel/$name = $value\n"; + } } else { - warn "## updated $nick/$channel/$name = $value\n"; + _log "META: updated $nick/$channel/$name = $value\n"; } return $value; @@ -556,8 +563,11 @@ " " . $a->{message}; eval { $sth_insert_log->execute($a->{channel}, $a->{me}, $a->{nick}, $a->{message}, $a->{time}); }; - _log "ERROR: can't archive ", $a->{message} if $@; - $cloud->add_tag( id => $dbh->last_insert_id(undef,undef,"log",undef), %$a ); + if ( $@ ) { + _log "ERROR: can't archive ", $a->{message}; + } else { + $cloud->add_tag( id => $dbh->last_insert_id(undef,undef,"log",undef), %$a ); + } } @@ -626,7 +636,8 @@ warn "## RSS fetch first $send_rss_msgs items from", $args->{url} if $debug; - my $feed = XML::Feed->parse( \$args->{xml} ); + my $feed; + eval { $feed = XML::Feed->parse( \$args->{xml} ) }; if ( ! $feed ) { _log "can't fetch RSS ", $args->{url}, XML::Feed->errstr; return; @@ -1283,7 +1294,8 @@ $rc = RC_DENY; } - $response->content( $feed->as_xml ); + eval { $response->content( $feed->as_xml ); }; + $rc = RC_INTERNAL_SERVER_ERROR if $@; return $rc; } @@ -1350,7 +1362,7 @@ } else { $html .= join("

", get_from_log( - limit => ( $q->param('last') || $q->param('date') ) ? undef : 100, + limit => ( $q->param('date') ? undef : $q->param('last') || 100 ), search => $search || undef, tag => $q->param('tag') || undef, date => $q->param('date') || undef, @@ -1375,7 +1387,7 @@

See history of all messages.

}; - $response->content( decode('utf-8',$html) ); + $response->content( $html ); warn "<< ", $request->method, " ", $request->uri, " created ", length($html), " bytes\n"; return RC_OK; } @@ -1415,7 +1427,7 @@ } my $html = qq{
}; - foreach my $tag (@tags) { + foreach my $tag ( sort { lc($a->{name}) cmp lc($b->{name}) } @tags) { $html .= sprintf(qq{%s\n}, $tag->{level}, $tag->{url}, $tag->{count}, $tag->{name} );