From 59fbf946b0930085ab3f1de64422c3b486ae255f Mon Sep 17 00:00:00 2001
From: Andreas Romeyke <andreas.romeyke@slub-dresden.de>
Date: Thu, 10 Nov 2022 14:36:09 +0100
Subject: [PATCH] - fixed problem if from and to date used - show all matches

---
 lib/SLUB/LZA/Rosetta/TA/Command/log.pm | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/lib/SLUB/LZA/Rosetta/TA/Command/log.pm b/lib/SLUB/LZA/Rosetta/TA/Command/log.pm
index 7810057..df68b3b 100644
--- a/lib/SLUB/LZA/Rosetta/TA/Command/log.pm
+++ b/lib/SLUB/LZA/Rosetta/TA/Command/log.pm
@@ -35,11 +35,9 @@ sub opt_spec {
             ["colorize|c" => "colorize output"],
             ["csv" => "use csv output"],
         ]}],
-        ["datemode" => hidden => {one_of => [
-            ["last-24h" => "search within last 24h"],
-            ["fromdate=s" => "search starting with date"],
-            ["todate=s" => "search ending with date"],
-        ] } ],
+        ["last-24h" => "search within last 24h"],
+        ["fromdate=s" => "search starting with date"],
+        ["todate=s" => "search ending with date"],
         ["level=s@" => "levels to search for. Levels could be: 'error', 'warn', 'info', debug. You could use multiple levels by repeating"],
         ["match=s" => "perl regex to search for" => {default=>".*"}],
     );
@@ -124,9 +122,9 @@ sub create_regex_from_to {
             || $line =~ s/ (INFO) / ${green}$1${reset} /
             || $line =~ s/ (WARN) / ${red}$1${reset} /
             || $line =~ s/ (ERROR) / ${bred}$1${reset} /;
-        $line =~ s/(SIP ?\d+)/${back_yellow}$1${reset}/;
-        $line =~ s/(IE ?\d+)/${back_yellow}$1${reset}/;
-        $line =~ s/(dc.identifier)/${back_cyan}$1${reset}/;
+        $line =~ s/(SIP ?\d+)/${back_yellow}$1${reset}/g;
+        $line =~ s/(IE ?\d+)/${back_yellow}$1${reset}/g;
+        $line =~ s/(dc.identifier)/${back_cyan}$1${reset}/g;
         return $line;
     }
 }
@@ -164,12 +162,7 @@ sub execute {
     my $date_rx=qr/[^ ]*/;
     if (defined $opt->last_24h and $opt->last_24h == 1) {
         $date_rx=create_regex_last24h();
-    } elsif (defined $opt->datemode
-        and (
-        $opt->datemode eq "todate"
-        or $opt->datemode eq "fromdate"
-        )
-    ) {
+    } else {
         $date_rx=create_regex_from_to($opt->fromdate, $opt->todate);
     }
     # create level_rx if multiple levels provided by CLI
-- 
GitLab