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
e000466a
Commit
e000466a
authored
Apr 06, 2014
by
mathieui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not instantiate the message logger at module level
.
parent
fe070163
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
src/logger.py
src/logger.py
+18
-4
src/poezio.py
src/poezio.py
+2
-0
No files found.
src/logger.py
View file @
e000466a
...
@@ -5,6 +5,11 @@
...
@@ -5,6 +5,11 @@
# Poezio is free software: you can redistribute it and/or modify
# Poezio is free software: you can redistribute it and/or modify
# it under the terms of the zlib license. See the COPYING file.
# it under the terms of the zlib license. See the COPYING file.
"""
The logger module that handles logging of the poezio
conversations and roster changes
"""
import
mmap
import
mmap
import
os
import
os
import
re
import
re
...
@@ -24,8 +29,12 @@ from config import LOG_DIR
...
@@ -24,8 +29,12 @@ from config import LOG_DIR
log_dir
=
os
.
path
.
join
(
LOG_DIR
,
'logs'
)
log_dir
=
os
.
path
.
join
(
LOG_DIR
,
'logs'
)
message_log_re
=
re
.
compile
(
'MR (\d{4})(\d{2})(\d{2})T(\d{2}):(\d{2}):(\d{2})Z (\d+) <([^ ]+)> (.*)'
)
message_log_re
=
re
.
compile
(
r
'MR (\d{4})(\d{2})(\d{2})T'
info_log_re
=
re
.
compile
(
'MI (\d{4})(\d{2})(\d{2})T(\d{2}):(\d{2}):(\d{2})Z (\d+) (.*)'
)
r
'(\d{2}):(\d{2}):(\d{2})Z '
r
'(\d+) <([^ ]+)> (.*)'
)
info_log_re
=
re
.
compile
(
r
'MI (\d{4})(\d{2})(\d{2})T'
r
'(\d{2}):(\d{2}):(\d{2})Z '
r
'(\d+) (.*)'
)
def
parse_message_line
(
msg
):
def
parse_message_line
(
msg
):
if
re
.
match
(
message_log_re
,
msg
):
if
re
.
match
(
message_log_re
,
msg
):
...
@@ -153,7 +162,7 @@ class Logger(object):
...
@@ -153,7 +162,7 @@ class Logger(object):
continue
continue
tup
=
parse_message_line
(
lines
[
idx
])
tup
=
parse_message_line
(
lines
[
idx
])
idx
+=
1
idx
+=
1
if
not
tup
or
7
>
len
(
tup
)
>
10
:
# skip
if
not
tup
or
7
>
len
(
tup
)
>
10
:
# skip
log
.
debug
(
'format? %s'
,
tup
)
log
.
debug
(
'format? %s'
,
tup
)
continue
continue
time
=
[
int
(
i
)
for
index
,
i
in
enumerate
(
tup
)
if
index
<
6
]
time
=
[
int
(
i
)
for
index
,
i
in
enumerate
(
tup
)
if
index
<
6
]
...
@@ -264,4 +273,9 @@ class Logger(object):
...
@@ -264,4 +273,9 @@ class Logger(object):
return
False
return
False
return
True
return
True
logger
=
Logger
()
def
create_logger
():
"Create the global logger object"
global
logger
logger
=
Logger
()
logger
=
None
src/poezio.py
View file @
e000466a
...
@@ -33,6 +33,8 @@ def main():
...
@@ -33,6 +33,8 @@ def main():
from
config
import
options
from
config
import
options
import
logger
logger
.
create_logger
()
import
core
import
core
...
...
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