Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tools for technical analysts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Digital Preservation
tools for technical analysts
Commits
5e15a5ed
Commit
5e15a5ed
authored
2 years ago
by
Andreas Romeyke
Browse files
Options
Downloads
Patches
Plain Diff
- extracted while-loop from scan_log() to helper_scan_log()
- added trace_log()
parent
ed623744
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/SLUB/LZA/Rosetta/TA.pm
+86
-20
86 additions, 20 deletions
lib/SLUB/LZA/Rosetta/TA.pm
with
86 additions
and
20 deletions
lib/SLUB/LZA/Rosetta/TA.pm
+
86
−
20
View file @
5e15a5ed
...
...
@@ -62,7 +62,82 @@ sub sru_search {
}
else
{
croak
("
Error was:
"
.
$req
->
status_line
());
}
}
sub
helper_scan_log
{
my
$directory
=
shift
;
my
$fh_processing
=
shift
;
for
(
$directory
->
children
(
qr/^server.log/
))
{
my
$file
=
$_
;
if
(
!
$file
->
is_file
)
{
next
;
}
my
$fh
;
if
(
$file
=~
m/\.gz$/
)
{
$fh
=
IO::
Zlib
->
new
("
$file
",
"
rb
");
}
else
{
$fh
=
$file
->
openr
;
}
if
(
defined
$fh
)
{
$fh_processing
->
(
$fh
);
}
undef
$fh
;
}
return
1
;
}
sub
trace_log
{
my
$with_trace
=
shift
;
my
$directory
=
path
(
$config
{
logdir
});
my
$deposit_id
;
my
$deposit_dir
;
my
$sip_id
;
my
$rep_id
;
my
$ie_pid
;
my
$searchid
=
$with_trace
;
$searchid
=~
s/^(REP|SIP|IE)(\d+)$/$2/
;
say
"
SEARCHID=
$searchid
";
# match to:
# 1. ... | processing {originalDirName=eb9c1924-4bab-11ec-baca-f69de10fbd49, depositId=422950, ... userName=Goobi_SMA, SIP 422438, producerType=TRUSTED, producerGroup=PG_Goobi, contentStructure=METS, materialFlowSR=0, producerId=264981, contentStructureId=264951, converter_class_name=com.exlibris.dps.deposit.converters.METSCSConverter, retentionPoliciesId=NO_RETENTION} from work queue SIP_LOADING_WORK_QUEUE finished
# 2. ... enqueued {originalDirName=d2cb9509-4bad-11ec-baca-b925eea982a1, depositId=422958, ... userName=Goobi_SMA, sipId=422446, producerType=TRUSTED, producerGroup=PG_Goobi, contentStructure=METS, materialFlowSR=0, producerId=264981, contentStructureId=264951, converter_class_name=com.exlibris.dps.deposit.converters.METSCSConverter, retentionPoliciesId=NO_RETENTION} on work queue V2SL_shr00.SIP_LOADING_WORK_QUEUE
# 3. ... SIP 13156, Deposit Activity ID=17589Properties
my
$sip_rx
=
qr/(SIP |sipId=)/
;
my
$pre_rx
=
qr/\d{4}-\d\d-\d\d \d\d:\d\d:\d\d,\d\d\d INFO .*/
;
my
$line_rx1
=
Regexp::
Optimizer
->
new
->
optimize
(
qr{^$pre_rx.*(originalDirName=|depositId=|$sip_rx)$searchid}
);
my
$line_rx2
=
Regexp::
Optimizer
->
new
->
optimize
(
qr{^$pre_rx.*(SIP |Deposit Activity ID=)$searchid}
);
my
$line_rx3
=
Regexp::
Optimizer
->
new
->
optimize
(
qr{^$pre_rx.*Loaded \d+ files for: .*$searchid}
);
# my $search_rxo = Regexp::Optimizer->new->optimize(qr/^$date_rx [^ ]* $level_rx (.*?)$match_rx(.*?)$/);
my
$fh_processing_stage1
=
sub
{
my
$fh
=
shift
;
while
(
<
$fh
>
)
{
if
(
(
defined
$sip_id
and
defined
$deposit_id
and
defined
$deposit_dir
)
or
(
defined
$ie_pid
and
defined
$rep_id
)
)
{
last
;
}
if
(
!
m/^$pre_rx/
)
{
next
;}
if
(
!
m/$searchid/
)
{
next
;}
chomp
;
if
(
m/$line_rx1/
)
{
if
(
!
defined
$deposit_dir
and
m/originalDirName=([^,]*),/
)
{
$deposit_dir
=
$
1
;
}
if
(
!
defined
$sip_id
and
m/$sip_rx(\d{6}),/
)
{
$sip_id
=
"
SIP
"
.
$
2
;
}
if
(
!
defined
$deposit_id
and
m/depositId=(\d{6}),/
)
{
$deposit_id
=
$
1
;}
}
elsif
(
m/$line_rx2/
)
{
if
(
!
defined
$deposit_id
and
m/Deposit Activity ID=(\d{6})/
)
{
$deposit_id
=
$
1
;}
if
(
!
defined
$sip_id
and
m/SIP (\d{6})/
)
{
$sip_id
=
$
1
;}
}
elsif
(
m/$line_rx3/
)
{
if
(
!
defined
$rep_id
and
m/Loaded \d+ files for: (REP\d+)/
)
{
$rep_id
=
$
1
;}
if
(
!
defined
$ie_pid
and
m/Loaded \d+ files for: REP\d+ \((IE\d+)/
)
{
$ie_pid
=
$
1
;}
}
}
return
1
;
};
helper_scan_log
(
$directory
,
$fh_processing_stage1
);
my
$match
=
"
found: DIR=
$deposit_dir
, DEPOSITID=
$deposit_id
, SIPID=
$sip_id
, IEPID=
$ie_pid
, REPID=
$rep_id
";
say
"
$match
";
say
"
-
"
x
(
length
(
$match
));
# now call scan_log and use own colorizer
my
$fh_processing_stage2
=
sub
{
};
helper_scan_log
(
$directory
,
$fh_processing_stage2
);
}
sub
scan_log
{
...
...
@@ -77,16 +152,8 @@ sub scan_log {
# return
my
$directory
=
path
(
$config
{
logdir
});
my
$search_rxo
=
Regexp::
Optimizer
->
new
->
optimize
(
qr/^$date_rx [^ ]* $level_rx (.*?)$match_rx(.*?)$/
);
for
(
$directory
->
children
(
qr/^server.log/
))
{
my
$file
=
$_
;
if
(
!
$file
->
is_file
)
{
next
;
}
my
$fh
;
if
(
$file
=~
m/\.gz$/
)
{
$fh
=
IO::
Zlib
->
new
("
$file
",
"
rb
");
}
else
{
$fh
=
$file
->
openr
;
}
if
(
defined
$fh
)
{
my
$fh_processing
=
sub
{
my
$fh
=
shift
;
while
(
<
$fh
>
)
{
chomp
;
if
(
!
m/$search_rxo/
)
{
...
...
@@ -96,9 +163,8 @@ sub scan_log {
my
$line
=
$output_filter
->
(
$_
);
say
$line
;
}
}
undef
$fh
;
}
};
helper_scan_log
(
$directory
,
$fh_processing
);
}
1
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment