Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
64b7e0c2
Unverified
Commit
64b7e0c2
authored
Nov 14, 2023
by
Matt Williams
Committed by
GitHub
Nov 14, 2023
Browse files
Update examples/python-loganalysis/loganalysis.py
Co-authored-by:
Bruce MacDonald
<
brucewmacdonald@gmail.com
>
parent
eced0d52
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
10 deletions
+6
-10
examples/python-loganalysis/loganalysis.py
examples/python-loganalysis/loganalysis.py
+6
-10
No files found.
examples/python-loganalysis/loganalysis.py
View file @
64b7e0c2
...
@@ -16,16 +16,12 @@ def find_errors_in_log_file():
...
@@ -16,16 +16,12 @@ def find_errors_in_log_file():
with
open
(
log_file_path
,
'r'
)
as
log_file
:
with
open
(
log_file_path
,
'r'
)
as
log_file
:
log_lines
=
log_file
.
readlines
()
log_lines
=
log_file
.
readlines
()
error_lines
=
[]
error_logs
=
[]
for
i
,
line
in
enumerate
(
log_lines
):
for
i
,
line
in
enumerate
(
log_lines
):
if
re
.
search
(
'error'
,
line
,
re
.
IGNORECASE
):
if
"error"
in
line
.
lower
():
error_lines
.
append
(
i
)
start_index
=
max
(
0
,
i
-
prelines
)
end_index
=
min
(
len
(
log_lines
),
i
+
postlines
+
1
)
error_logs
=
[]
error_logs
.
extend
(
log_lines
[
start_index
:
end_index
])
for
error_line
in
error_lines
:
start_index
=
max
(
0
,
error_line
-
prelines
)
end_index
=
min
(
len
(
log_lines
),
error_line
+
postlines
)
error_logs
.
extend
(
log_lines
[
start_index
:
end_index
])
return
error_logs
return
error_logs
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment