From 22784a47d44cb2369a6aa9c56a30e7fb98ca20ef Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 12 Nov 2018 10:52:35 +0100 Subject: Enable trace logging in BEGIN block for test suite Signed-off-by: Florian Pritz --- lib/App/BorgRestore/PathTimeTable/DB.pm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/App/BorgRestore/PathTimeTable/DB.pm b/lib/App/BorgRestore/PathTimeTable/DB.pm index c01bbd0..221063c 100644 --- a/lib/App/BorgRestore/PathTimeTable/DB.pm +++ b/lib/App/BorgRestore/PathTimeTable/DB.pm @@ -2,7 +2,15 @@ package App::BorgRestore::PathTimeTable::DB; use strictures 2; use Function::Parameters; -use Log::Any qw($log); +BEGIN { + use Log::Any qw($log); + # Trace logging statements are disabled here since they incur a performance + # overhead because they are in tight loops. This block only works for the + # test suite code (set env var TAP_LOG_FILTER=none) since the normal + # application only changes the log level at run time. Hardcode to 1 when + # necessary (or write a test!). + use constant TRACE => $log->is_trace; +} =head1 NAME @@ -22,9 +30,6 @@ properly sorted, this results in only a single database write for each path. =cut -# Trace logging statements are disabled here since they incur a performance -# overhead because they are in tight loops. Change to 1 when necessary. -use constant TRACE => 0; method new($class: $deps = {}) { return $class->new_no_defaults($deps); -- cgit v1.2.3-24-g4f1b