From 21385930c7ca62c993c0f55993a286d4edfa34c1 Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Tue, 26 Jul 2016 16:42:54 -0500 Subject: RT#38217: Send email when logging conditions are met [removed unwanted log levels, preserved level num mapping, v4] --- httemplate/browse/log_email.html | 2 +- httemplate/edit/log_email.html | 4 ++-- httemplate/search/log.html | 31 ++++++++++++++----------------- 3 files changed, 17 insertions(+), 20 deletions(-) (limited to 'httemplate') diff --git a/httemplate/browse/log_email.html b/httemplate/browse/log_email.html index 0f64dd454..007ea6f74 100644 --- a/httemplate/browse/log_email.html +++ b/httemplate/browse/log_email.html @@ -21,7 +21,7 @@ ], 'fields' => [ 'logemailnum', sub { $_[0]->context || '(all)' }, - sub { $FS::Log::LEVELS[$_[0]->min_level] }, + sub { $FS::Log::LEVELS{$_[0]->min_level} }, 'msgname', 'to_addr', $actions, diff --git a/httemplate/edit/log_email.html b/httemplate/edit/log_email.html index 0c98046d3..b79aba986 100644 --- a/httemplate/edit/log_email.html +++ b/httemplate/edit/log_email.html @@ -16,8 +16,8 @@ }, { 'field' => 'min_level', 'type' => 'select', - 'options' => [ 0..7 ], - 'labels' => { map {$_ => $FS::Log::LEVELS[$_]} 0..7 }, + 'options' => [ &FS::Log::levelnums ], + 'labels' => { &FS::Log::levelmap }, 'curr_value' => scalar($cgi->param('min_level')), }, 'to_addr', diff --git a/httemplate/search/log.html b/httemplate/search/log.html index 111200f55..5b330f899 100644 --- a/httemplate/search/log.html +++ b/httemplate/search/log.html @@ -81,15 +81,15 @@ a:visited {text-decoration: none} Level <& /elements/select.html, field => 'min_level', - options => [ 0..7 ], - labels => { map {$_ => $FS::Log::LEVELS[$_]} 0..7 }, + options => [ &FS::Log::levelnums ], + labels => { &FS::Log::levelmap }, curr_value => $cgi->param('min_level'), &> to <& /elements/select.html, field => 'max_level', - options => [ 0..7 ], - labels => { map {$_ => $FS::Log::LEVELS[$_]} 0..7 }, + options => [ &FS::Log::levelnums ], + labels => { &FS::Log::levelmap }, curr_value => $cgi->param('max_level'), &> @@ -128,7 +128,7 @@ a:visited {text-decoration: none} <%once> my $date_sub = sub { time2str('%Y-%m-%d %T', $_[0]->_date) }; -my $level_sub = sub { $FS::Log::LEVELS[$_[0]->level] }; +my $level_sub = sub { $FS::Log::LEVELS{$_[0]->level} }; my $context_sub = sub { my $log = shift; @@ -191,18 +191,15 @@ my $object_link_sub = sub { } }; -my @colors = ( - '404040', #debug - '0000aa', #info - '00aa00', #notice - 'aa0066', #warning - '000000', #error - 'aa0000', #critical - 'ff0000', #alert - 'ff0000', #emergency +my %colors = ( + 0 => '404040', #debug, gray + 1 => '000000', #info, black + 3 => '0000aa', #warning, blue + 4 => 'aa0066', #error, purple + 5 => 'ff0000', #critical, red ); -my $color_sub = sub { $colors[ $_[0]->level ]; }; +my $color_sub = sub { $colors{ $_[0]->level }; }; my @contexts = ('', sort FS::log_context->contexts); @@ -212,10 +209,10 @@ die "access denied" unless $curuser->access_right([ 'View system logs', 'Configuration' ]); my @menubar = (); -push @menubar, qq(Configure conditions for sending email when logging), +push @menubar, qq(Configure conditions for sending email when logging); $cgi->param('min_level', 0) unless defined($cgi->param('min_level')); -$cgi->param('max_level', 7) unless defined($cgi->param('max_level')); +$cgi->param('max_level', 5) unless defined($cgi->param('max_level')); my %search = (); $search{'date'} = [ FS::UI::Web::parse_beginning_ending($cgi) ]; -- cgit v1.2.1