summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--META.json2
-rw-r--r--cpanfile2
-rwxr-xr-xscript/borg-restore.pl22
3 files changed, 24 insertions, 2 deletions
diff --git a/META.json b/META.json
index 8691571..c708ce1 100644
--- a/META.json
+++ b/META.json
@@ -43,6 +43,8 @@
"runtime" : {
"requires" : {
"Log::Any" : "0",
+ "Log::Any::Adapter::Log4perl" : "0",
+ "Log::Log4perl" : "0",
"perl" : "v5.10.0"
}
},
diff --git a/cpanfile b/cpanfile
index 5ad79ac..e8bf9f8 100644
--- a/cpanfile
+++ b/cpanfile
@@ -1,5 +1,7 @@
requires 'perl', '5.010000';
requires 'Log::Any';
+requires 'Log::Log4perl';
+requires 'Log::Any::Adapter::Log4perl';
on 'test' => sub {
requires 'Test::More', '0.98';
diff --git a/script/borg-restore.pl b/script/borg-restore.pl
index 7f8d8d4..1834396 100755
--- a/script/borg-restore.pl
+++ b/script/borg-restore.pl
@@ -168,6 +168,9 @@ use File::Spec;
use Getopt::Long;
use Log::Any qw($log);
use Log::Any::Adapter;
+use Log::Log4perl;
+use Log::Log4perl::Layout;
+use Log::Log4perl::Level;
use Pod::Usage;
my $app;
@@ -196,7 +199,19 @@ sub user_select_archive {
}
sub main {
- Log::Any::Adapter->set('Stderr', log_level => "warn");
+ my $appender = "Screen";
+ $appender = "ScreenColoredLevels" if -t STDERR; ## no critic (InputOutput::ProhibitInteractiveTest)
+
+ my $conf = "
+ log4perl.rootLogger = WARN, screenlog
+
+ log4perl.appender.screenlog = Log::Log4perl::Appender::$appender
+ log4perl.appender.screenlog.stderr = 1
+ log4perl.appender.screenlog.layout = Log::Log4perl::Layout::PatternLayout
+ log4perl.appender.screenlog.layout.ConversionPattern = %p %m%n
+ ";
+ Log::Log4perl::init( \$conf );
+ Log::Any::Adapter->set('Log4perl');
my %opts;
# untaint PATH because we only expect this to run as root
@@ -209,7 +224,10 @@ sub main {
pod2usage(0) if $opts{help};
if ($opts{debug}) {
- Log::Any::Adapter->set('Stderr', log_level => "debug");
+ my $logger = Log::Log4perl->get_logger('');
+ $logger->level($DEBUG);
+ Log::Log4perl->appenders()->{"screenlog"}->layout(
+ Log::Log4perl::Layout::PatternLayout->new("%d %r [%30c:%-4L] %p %m%n"));
}
$app = App::BorgRestore->new();