Commit 2820b02f authored by Francesc Guasch's avatar Francesc Guasch
Browse files

feature(log): show IP, remote user and time

issue #1311
parent 6e0af6b5
......@@ -32,4 +32,9 @@
,auto_view => 0
,fallback => 0
,log => {
log => 0
,file => '/var/log/ravada/rvd_front.log'
,level => 'debug'
}
};
......@@ -29,7 +29,7 @@ use Ravada::Front;
use Ravada::Front::Domain;
use Ravada::Auth;
use Ravada::WebSocket;
use POSIX qw(locale_h);
use POSIX qw(locale_h strftime);
my $help;
......@@ -126,6 +126,10 @@ my %ALLOWED_ANONYMOUS_WS = map { $_ => 1 } qw(list_bases_anonymous list_alerts);
init();
############################################################################3
sub _time() {
return strftime('%Y/%m/%d:%H:%M:%S %z',localtime);
}
hook before_routes => sub {
my $c = shift;
......@@ -133,7 +137,6 @@ hook before_routes => sub {
$c->stash(version => $RAVADA->version);
my $url = $c->req->url->to_abs->path;
app->log->info($url) if $CONFIG_FRONT->{log}->{log};
my $host = $c->req->url->to_abs->host;
$c->stash(css=>['/css/sb-admin.css']
,js=>[
......@@ -155,6 +158,11 @@ hook before_routes => sub {
$USER = _logged_in($c);
my $user = '-';
$user = $USER->name if defined $USER;
app->log->info(_remote_ip($c)." $user ["._time()."] ".$c->req->method." ".$url)
if $CONFIG_FRONT->{log}->{log};
return if $url =~ m{^/(css|font|img|js)}
|| $url =~ m{^/fallback/.*\.(css|js|map)$};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment