Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BackupManager::Dialog now send to syslog only messages whose level is…

… authorized by BM_LOGGER_LEVEL
  • Loading branch information...
commit 1d63ae3a8833ba0fd4f837ad3c1c67a440c57aa7 1 parent 08f9961
Alexis Sukrieh authored
Showing with 17 additions and 3 deletions.
  1. +17 −3 BackupManager/Dialog.pm
View
20 BackupManager/Dialog.pm
@@ -11,6 +11,20 @@ use BackupManager::Logger;
my $dialog_verbose = 0;
+sub should_log($) {
+ my ($level) = @_;
+
+ my $level_score = {
+ debug => 0,
+ info => 1,
+ warning => 2,
+ error => 3,
+ };
+
+ my $conf_level = $ENV{BM_LOGGER_LEVEL} || 'warning';
+ return $level_score->{$level} >= $level_score->{$conf_level};
+}
+
sub init_dialog($)
{
my ($verbose) = @_;
@@ -23,7 +37,7 @@ sub print_info
$message = "" unless defined $message;
chomp $message;
- info ($message);
+ info ($message) if should_log 'info';
print STDOUT $message."\n" if $dialog_verbose;
}
@@ -33,7 +47,7 @@ sub print_warning
$message = "" unless defined $message;
chomp $message;
- warning ($message);
+ warning ($message) if should_log 'warning';
print STDERR $message."\n" if $dialog_verbose;
}
@@ -43,7 +57,7 @@ sub print_error
$message = "" unless defined $message;
chomp $message;
- error ($message);
+ error ($message) if should_log 'error';
print STDERR $message."\n";
}
Please sign in to comment.
Something went wrong with that request. Please try again.