Commit a9864be2 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

wip(logs): use Mojo log in frontend

issue #1311
parent 8bc1d242
......@@ -72,6 +72,11 @@ my $CONFIG_FRONT = plugin Config => { default => {
}
,config => $FILE_CONFIG_RAVADA
,auto_view => 0
,log => {
log => 0
,file => '/var/log/ravada/rvd_front.log'
,level => 'debug'
}
}
,file => $FILE_CONFIG
};
......@@ -127,6 +132,7 @@ 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=>[
......@@ -1132,6 +1138,7 @@ post '/request/(:name)/' => sub {
$args->{remote_ip} = _remote_ip($c);
}
app->log->info($USER->name." requesting $name ".encode_json($args)) if $CONFIG_FRONT->{log}->{log};
my $req;
eval {
$req = Ravada::Request->new_request(
......@@ -1536,8 +1543,10 @@ sub login {
my $auto_view = 1;
$c->session(auto_view => $auto_view, expiration => $expiration);
app->log->info("Access granted to $login from "._remote_ip($c)) if $CONFIG_FRONT->{log}->{log};
return $c->redirect_to($url);
} else {
app->log->error("Access denied to $login from "._remote_ip($c)) if $CONFIG_FRONT->{log}->{log};
push @error,("Access denied");
}
}
......@@ -1849,6 +1858,10 @@ sub provision_req($c, $id_base, $name, $ram=0, $disk=0) {
, id_domain => $domain->id
);
}
app->log->info($USER->name." start_domain ".$domain->name." from "._remote_ip($c))
if $CONFIG_FRONT->{log}->{log};
return Ravada::Request->start_domain(
uid => $USER->id
, id_domain => $domain->id
......@@ -1857,6 +1870,10 @@ sub provision_req($c, $id_base, $name, $ram=0, $disk=0) {
}
$name = _new_domain_name($name);
}
app->log->info($USER->name." requesting create_domain ".$name." from "._remote_ip($c))
if $CONFIG_FRONT->{log}->{log};
my @create_args = ( start => 1, remote_ip => _remote_ip($c));
push @create_args, ( memory => $ram ) if $ram;
push @create_args, ( disk => $disk) if $disk;
......@@ -1934,6 +1951,9 @@ sub _init_user_group {
}
sub init {
app->log( Mojo::Log->new( path => $CONFIG_FRONT->{log}->{file}, level => $CONFIG_FRONT->{log}->{level} ) )
if $CONFIG_FRONT->{log}->{log};
_init_user_group();
my $home = Mojo::Home->new();
$home->detect();
......@@ -2110,6 +2130,9 @@ sub view_machine {
$domain = _search_requested_machine($c) if !$domain;
return $c->render(template => 'main/fail') if !$domain;
app->log->info($USER->name." requesting start_domain ".$domain->name." from "._remote_ip($c))
if $CONFIG_FRONT->{log}->{log};
return run_request($c, Ravada::Request->start_domain(
uid => $USER->id
,id_domain => $domain->id
......@@ -2277,6 +2300,9 @@ sub start_machine {
return $c->render(text => "Domain not found") if !$domain;
$domain->_data(status => 'starting');
app->log->info($USER->name." start_domain ".$domain->name." from "._remote_ip($c))
if $CONFIG_FRONT->{log}->{log};
my $req = Ravada::Request->start_domain( uid => $USER->id
,name => $domain->name
,remote_ip => _remote_ip($c)
......
Markdown is supported
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