From 409d3a6ae6df62bc900431293510e2b6a7fe37a4 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Mon, 20 Jul 2015 09:19:23 +0200 Subject: [PATCH] Log the same thing in the DB and on stdout --- vroom.pl | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/vroom.pl b/vroom.pl index 6d09179..b96fb70 100755 --- a/vroom.pl +++ b/vroom.pl @@ -196,20 +196,18 @@ helper log_event => sub { $self->app->log->debug("Oops, invalid event received"); return 0; } + my $addr = $self->tx->remote_address || '127.0.0.1'; + my $user = $self->get_name || 'VROOM daemon'; my $sth = eval { $self->db->prepare('INSERT INTO `audit` (`date`,`event`,`from_ip`,`user`,`message`) VALUES (CONVERT_TZ(NOW(), @@session.time_zone, \'+00:00\'),?,?,?,?)'); }; $sth->execute( $event->{event}, - $self->tx->remote_address, - $self->get_name, + $addr, + $user, $event->{msg} ); - my $addr = $self->tx->remote_address || ''; - my $user = $self->get_name || ''; - $addr = ($addr eq '') ? '127.0.0.1' : $addr; - $user = ($user eq '') ? 'VROOM daemon' : $user; $self->app->log->info('[' . $addr . '] [' . $user . '] [' . $event->{event} . '] ' . $event->{msg}); return 1; };