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
a630f4a1
Commit
a630f4a1
authored
Oct 16, 2018
by
Link Mauve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logger: Prefix private functions with an underscore.
parent
d626aa15
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
poezio/logger.py
poezio/logger.py
+11
-11
No files found.
poezio/logger.py
View file @
a630f4a1
...
...
@@ -56,7 +56,7 @@ class LogMessage(LogItem):
self
.
nick
=
nick
def
parse_log_line
(
msg
:
str
)
->
Optional
[
LogItem
]:
def
_
parse_log_line
(
msg
:
str
)
->
Optional
[
LogItem
]:
match
=
re
.
match
(
MESSAGE_LOG_RE
,
msg
)
if
match
:
return
LogMessage
(
*
match
.
groups
())
...
...
@@ -169,14 +169,14 @@ class Logger:
# do that efficiently, instead of seek()s and read()s which are costly.
with
fd
:
try
:
lines
=
get_lines_from_fd
(
fd
,
nb
=
nb
)
lines
=
_
get_lines_from_fd
(
fd
,
nb
=
nb
)
except
Exception
:
# file probably empty
log
.
error
(
'Unable to mmap the log file for (%s)'
,
filename
,
exc_info
=
True
)
return
None
return
parse_log_lines
(
lines
)
return
_
parse_log_lines
(
lines
)
def
log_message
(
self
,
jid
:
str
,
...
...
@@ -193,7 +193,7 @@ class Logger:
"""
if
not
config
.
get_by_tabname
(
'use_log'
,
jid
):
return
True
logged_msg
=
build_log_message
(
nick
,
msg
,
date
=
date
,
typ
=
typ
)
logged_msg
=
_
build_log_message
(
nick
,
msg
,
date
=
date
,
typ
=
typ
)
if
not
logged_msg
:
return
True
if
jid
in
self
.
_fds
.
keys
():
...
...
@@ -260,10 +260,10 @@ class Logger:
return
True
def
build_log_message
(
nick
:
str
,
msg
:
str
,
date
:
Optional
[
datetime
]
=
None
,
typ
:
int
=
1
)
->
str
:
def
_
build_log_message
(
nick
:
str
,
msg
:
str
,
date
:
Optional
[
datetime
]
=
None
,
typ
:
int
=
1
)
->
str
:
"""
Create a log message from a nick, a message, optionally a date and type
message types:
...
...
@@ -290,7 +290,7 @@ def build_log_message(nick: str,
return
logged_msg
+
''
.
join
(
' %s
\n
'
%
line
for
line
in
lines
)
def
get_lines_from_fd
(
fd
:
IO
[
Any
],
nb
:
int
=
10
)
->
List
[
str
]:
def
_
get_lines_from_fd
(
fd
:
IO
[
Any
],
nb
:
int
=
10
)
->
List
[
str
]:
"""
Get the last log lines from a fileno
"""
...
...
@@ -309,7 +309,7 @@ def get_lines_from_fd(fd: IO[Any], nb: int = 10) -> List[str]:
return
lines
def
parse_log_lines
(
lines
:
List
[
str
])
->
List
[
Dict
[
str
,
Any
]]:
def
_
parse_log_lines
(
lines
:
List
[
str
])
->
List
[
Dict
[
str
,
Any
]]:
"""
Parse raw log lines into poezio log objects
"""
...
...
@@ -323,7 +323,7 @@ def parse_log_lines(lines: List[str]) -> List[Dict[str, Any]]:
idx
+=
1
log
.
debug
(
'fail?'
)
continue
log_item
=
parse_log_line
(
lines
[
idx
])
log_item
=
_
parse_log_line
(
lines
[
idx
])
idx
+=
1
if
not
isinstance
(
log_item
,
LogItem
):
log
.
debug
(
'wrong log format? %s'
,
log_item
)
...
...
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