Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
km3mon
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
km3py
km3mon
Commits
9c2debab
Commit
9c2debab
authored
2 years ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Add gzip support for log analyser
parent
1bd6dc59
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!32
Add gzip support for log analyser
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.rst
+2
-0
2 additions, 0 deletions
CHANGELOG.rst
backend/scripts/log_analyser.py
+11
-3
11 additions, 3 deletions
backend/scripts/log_analyser.py
with
13 additions
and
3 deletions
CHANGELOG.rst
+
2
−
0
View file @
9c2debab
Unreleased changes
------------------
* `log_analyser.py` now also parses gzipped log files
Version 2
---------
2.2.3 / 2022-11-20
~~~~~~~~~~~~~~~~~~
* Updates dependencies: km3pipe==9.13.5 which fixes the issue with the
...
...
This diff is collapsed.
Click to expand it.
backend/scripts/log_analyser.py
+
11
−
3
View file @
9c2debab
...
...
@@ -4,6 +4,7 @@
# Author: Tamas Gal <tgal@km3net.de>
# vim: ts=4 sw=4 et
from
collections
import
defaultdict
import
gzip
import
sys
import
re
import
numpy
as
np
...
...
@@ -75,9 +76,16 @@ def process_log_file(log_file):
"""
summary
=
defaultdict
(
lambda
:
defaultdict
(
int
))
if
log_file
.
endswith
(
"
.gz
"
):
opener
=
gzip
.
open
filemode
=
"
rt
"
else
:
opener
=
open
filemode
=
"
r
"
n_lines_parsed
=
0
n_lines_unparsed
=
0
with
open
(
log_file
,
"
r
"
)
as
fobj
:
with
open
er
(
log_file
,
filemode
)
as
fobj
:
lines_chunk
=
fobj
.
readlines
(
BUFFER_SIZE
)
while
lines_chunk
:
for
line
in
lines_chunk
:
...
...
@@ -118,11 +126,11 @@ def process_log_file(log_file):
def
main
():
log_dir
=
"
/logs/
"
regexp
=
"
^MSG_(.+)\.log
$
"
regexp
=
"
^MSG_(.+)\.log
"
while
True
:
for
fname
in
os
.
listdir
(
log_dir
):
plot_fpath
=
os
.
path
.
join
(
log_dir
,
os
.
path
.
splitext
(
fname
)[
0
]
+
"
.png
"
)
plot_fpath
=
os
.
path
.
join
(
log_dir
,
os
.
path
.
splitext
(
fname
.
replace
(
"
.gz
"
,
""
)
)[
0
]
+
"
.png
"
)
log_fpath
=
os
.
path
.
join
(
log_dir
,
fname
)
if
re
.
match
(
regexp
,
fname
)
and
not
os
.
path
.
exists
(
plot_fpath
):
print
(
"
-> Processing
"
,
fname
)
...
...
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