enable CardFortress in test database, #71513
[freeside.git] / FS / FS / Log.pm
index b11630b..aed1f39 100644 (file)
@@ -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 => @_ );
@@ -49,7 +56,7 @@ to the database.  FS::Log inherits from L<Log::Dispatch>.
 
 =over 4
 
-new CONTEXT
+=item new CONTEXT
 
 Constructs and returns a log handle.  CONTEXT must be a known context tag
 indicating what activity is going on, such as the name of the function or
@@ -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;