Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
poezio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
178
Issues
178
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poezio
poezio
Commits
b1052e14
Commit
b1052e14
authored
Apr 15, 2021
by
mathieui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: handle single-line log files, and reentry into fd_busy
parent
a6489fb6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
poezio/logger.py
poezio/logger.py
+12
-7
No files found.
poezio/logger.py
View file @
b1052e14
...
...
@@ -136,7 +136,8 @@ class Logger:
"""
jidstr
=
str
(
jid
).
replace
(
'/'
,
'
\\
'
)
self
.
_busy_fds
[
jidstr
]
=
True
self
.
_buffered_fds
[
jidstr
]
=
[]
if
jidstr
not
in
self
.
_buffered_fds
:
self
.
_buffered_fds
[
jidstr
]
=
[]
def
fd_available
(
self
,
jid
:
Union
[
str
,
JID
])
->
None
:
"""Signal to the logger that this logfile is no longer busy.
...
...
@@ -371,15 +372,19 @@ def iterate_messages_reverse(filepath: Path) -> Generator[LogDict, None, None]:
with
mmap
.
mmap
(
fd
.
fileno
(),
0
,
prot
=
mmap
.
PROT_READ
)
as
m
:
# start of messages begin with MI or MR, after a \n
pos
=
m
.
rfind
(
b
"
\n
M"
)
+
1
lines
=
parse_log_lines
(
m
[
pos
:
-
1
].
decode
(
errors
=
'replace'
).
splitlines
()
)
if
pos
!=
-
1
:
lines
=
parse_log_lines
(
m
[
pos
:
-
1
].
decode
(
errors
=
'replace'
).
splitlines
()
)
elif
m
[
0
:
1
]
==
b
'M'
:
# Handle the case of a single message present in the log
# file, hence no newline.
lines
=
parse_log_lines
(
m
[:].
decode
(
errors
=
'replace'
).
splitlines
()
)
if
lines
:
yield
lines
[
0
]
# number of message found so far
count
=
0
while
pos
>
0
:
count
+=
1
old_pos
=
pos
pos
=
m
.
rfind
(
b
"
\n
M"
,
0
,
pos
)
+
1
lines
=
parse_log_lines
(
...
...
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