Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
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
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
l-n-s
gajim
Commits
6e672c99
Commit
6e672c99
authored
6 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
Add LogAdapter
This adds the account to all log messages issues in module code
parent
b704e27a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gajim/common/modules/base.py
+4
-1
4 additions, 1 deletion
gajim/common/modules/base.py
gajim/common/modules/util.py
+6
-0
6 additions, 0 deletions
gajim/common/modules/util.py
with
10 additions
and
1 deletion
gajim/common/modules/base.py
+
4
−
1
View file @
6e672c99
...
...
@@ -24,6 +24,7 @@ import nbxmpp
from
nbxmpp.structs
import
StanzaHandler
from
gajim.common
import
app
from
gajim.common.modules.util
import
LogAdapter
log
=
logging
.
getLogger
(
'
gajim.c.m.base
'
)
...
...
@@ -33,9 +34,11 @@ class BaseModule:
_nbxmpp_extends
=
''
_nbxmpp_methods
=
[]
# type: List[str]
def
__init__
(
self
,
con
):
def
__init__
(
self
,
con
,
logger
=
None
):
self
.
_con
=
con
self
.
_account
=
con
.
name
if
logger
is
not
None
:
self
.
_log
=
LogAdapter
(
logger
,
{
'
account
'
:
self
.
_account
})
self
.
_nbxmpp_callbacks
=
{}
# type: Dict[str, Any]
self
.
_stored_publish
=
None
# type: Callable
self
.
handlers
=
[]
# type: List[str]
...
...
This diff is collapsed.
Click to expand it.
gajim/common/modules/util.py
+
6
−
0
View file @
6e672c99
...
...
@@ -16,6 +16,7 @@
from
typing
import
Union
from
logging
import
LoggerAdapter
from
functools
import
wraps
from
functools
import
partial
...
...
@@ -81,3 +82,8 @@ def get_eme_message(eme_data):
return
EME_MESSAGES
[
eme_data
.
namespace
]
except
KeyError
:
return
EME_MESSAGES
[
'
fallback
'
]
%
eme_data
.
name
class
LogAdapter
(
LoggerAdapter
):
def
process
(
self
,
msg
,
kwargs
):
return
'
[%s] %s
'
%
(
self
.
extra
[
'
account
'
],
msg
),
kwargs
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