summaryrefslogtreecommitdiff
path: root/FS/FS/Log.pm
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2016-07-26 16:42:54 -0500
committerJonathan Prykop <jonathan@freeside.biz>2016-08-29 20:10:33 -0500
commit21385930c7ca62c993c0f55993a286d4edfa34c1 (patch)
tree9ed7abb5e8da4f5d1710a0552fc5b256c681a2f3 /FS/FS/Log.pm
parentf1d59659244a34b2ee9c6380babff464639e2927 (diff)
RT#38217: Send email when logging conditions are met [removed unwanted log levels, preserved level num mapping, v4]
Diffstat (limited to 'FS/FS/Log.pm')
-rw-r--r--FS/FS/Log.pm33
1 files changed, 30 insertions, 3 deletions
diff --git a/FS/FS/Log.pm b/FS/FS/Log.pm
index 2fd0020..aed1f39 100644
--- a/FS/FS/Log.pm
+++ b/FS/FS/Log.pm
@@ -5,13 +5,20 @@ use FS::Record qw(qsearch qsearchs);
use FS::Conf;
use FS::Log::Output;
use FS::log;
-use vars qw(@STACK @LEVELS);
+use vars qw(@STACK %LEVELS);
# override the stringification of @_ with something more sensible.
BEGIN {
- @LEVELS = qw(debug info notice warning error critical alert emergency);
+ # subset of Log::Dispatch levels
+ %LEVELS = (
+ 0 => 'debug',
+ 1 => 'info',
+ 3 => 'warning',
+ 4 => 'error',
+ 5 => 'critical'
+ );
- foreach my $l (@LEVELS) {
+ foreach my $l (values %LEVELS) {
my $sub = sub {
my $self = shift;
$self->log( level => $l, message => @_ );
@@ -100,4 +107,24 @@ sub DESTROY {
splice(@STACK, $self->{'index'}, 1); # delete the stack entry
}
+=item levelnums
+
+Subroutine. Returns ordered list of level nums.
+
+=cut
+
+sub levelnums {
+ sort keys %LEVELS;
+}
+
+=item levelmap
+
+Subroutine. Returns ordered map of level num => level name.
+
+=cut
+
+sub levelmap {
+ map { $_ => $LEVELS{$_} } levelnums;
+}
+
1;