From f9828c38a143b56e2b0cd79aa2a176398033123b Mon Sep 17 00:00:00 2001
From: Andreas Romeyke <andreas.romeyke@slub-dresden.de>
Date: Thu, 17 Nov 2022 17:44:46 +0100
Subject: [PATCH] - added option "--trace-sip"

---
 lib/SLUB/LZA/Rosetta/TA/Command/log.pm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/SLUB/LZA/Rosetta/TA/Command/log.pm b/lib/SLUB/LZA/Rosetta/TA/Command/log.pm
index 4a473c3..de41f94 100644
--- a/lib/SLUB/LZA/Rosetta/TA/Command/log.pm
+++ b/lib/SLUB/LZA/Rosetta/TA/Command/log.pm
@@ -22,6 +22,8 @@ Examples:
     $0 log --level error --level warning --fromdate 2022-01-01 --todate 2021-02-01
   * Are there lines with regex "ma[tc]?h"?
     $0 log --match "ma[tc]?h"
+  * Give me a trace of specific sip
+    $0 log --trace-sip sip293144
 DESCR
 
 sub description {
@@ -40,6 +42,7 @@ sub opt_spec {
         ["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=>".*"}],
+        ["trace-sip=s" => "trace a sip with given ID (SIP-ID or Deposit-ID)"],
     );
 }
 
@@ -179,7 +182,14 @@ sub execute {
     } elsif (defined $opt->csv) {
         $output_filter = sub { csv($_[0], $opt, $match_rx); };
     }
-    SLUB::LZA::Rosetta::TA::scan_log($date_rx, $level_rx, $match_rx, $output_filter);
+    # prepare trace
+    my $with_trace;
+    if (defined $opt->trace_sip) {
+        $with_trace = $opt->trace_sip;
+        SLUB::LZA::Rosetta::TA::trace_log($with_trace);
+    } else {
+        SLUB::LZA::Rosetta::TA::scan_log($date_rx, $level_rx, $match_rx, $output_filter, $with_trace);
+    }
 }
 
 1;
\ No newline at end of file
-- 
GitLab