mirror of
https://github.com/univention/univention-corporate-server.git
synced 2025-10-26 11:17:13 +00:00
fix(logging): always check univention-debug level for cases when something
externally directly sets the univention.debug level.
performance looks okay:
```
python3 -m timeit -s 'import univention.debug as ud; ud.init("stderr", 1, 1); ud.set_level(ud.ADMIN, ud.ALL)' 'ud.get_level(ud.ADMIN)'
05.03.24 16:30:32.608 DEBUG_INIT
2000000 loops, best of 5: 163 nsec per loop
python3 -m timeit -s 'import univention.logging; univention.logging.basicConfig("stderr"); admin = univention.logging.getLogger("ADMIN")' 'admin.getEffectiveLevel()'
05.03.24 16:33:25.823 DEBUG_INIT
500000 loops, best of 5: 749 nsec per loop
05.03.24 16:33:28.400 DEBUG_EXIT
```
Alternative is to adapt the `set_level()` C Python function to call `logging.getLogger(component).set_ud_level(level)`.
Bug #57101
This commit is contained in:
parent
8b962aec22
commit
e702b79128
@ -1,12 +1,19 @@
|
||||
univention-debug-python (12.0.3-11) unstable; urgency=medium
|
||||
|
||||
* Bug #57101: always check univention-debug level for cases when something
|
||||
externally directly sets the univention.debug level
|
||||
|
||||
-- Florian Best <best@univention.de> Tue, 05 Mar 2024 16:24:44 +0100
|
||||
|
||||
univention-debug-python (12.0.3-10) unstable; urgency=medium
|
||||
|
||||
* Bug #56970: set level to upstream handler
|
||||
* Bug #57101: set level to upstream handler
|
||||
|
||||
-- Florian Best <best@univention.de> Tue, 05 Mar 2024 09:43:46 +0100
|
||||
|
||||
univention-debug-python (12.0.3-9) unstable; urgency=medium
|
||||
|
||||
* Bug #56970: detect correct univention-debug log level if univention.debug
|
||||
* Bug #57101: detect correct univention-debug log level if univention.debug
|
||||
is initialized by ud instead of univention.logging
|
||||
|
||||
-- Florian Best <best@univention.de> Fri, 01 Mar 2024 12:46:02 +0100
|
||||
|
||||
@ -289,6 +289,12 @@ class Logger(logging.Logger):
|
||||
super(Logger, self).setLevel(level)
|
||||
self.univention_debug_handler.setLevel(self.level)
|
||||
|
||||
def isEnabledFor(self, level):
|
||||
# we need to overwrite the method because something might have
|
||||
# called `ud.set_level()` without using this logging interface.
|
||||
# prevent the cache from giving wrong results
|
||||
return level >= self.getEffectiveLevel()
|
||||
|
||||
def getEffectiveLevel(self):
|
||||
current_level = self.univention_debug_handler.getLevel()
|
||||
if self.univention_debug_handler.level != current_level:
|
||||
|
||||
@ -3,7 +3,7 @@ release: "5.0"
|
||||
version: [6]
|
||||
scope: ucs_5.0-0-errata5.0-6
|
||||
src: univention-debug-python
|
||||
fix: 12.0.3-10
|
||||
fix: 12.0.3-11
|
||||
desc: |
|
||||
This update addresses the following issues:
|
||||
* The detection of the correct log level has been repaired in case
|
||||
|
||||
Loading…
Reference in New Issue
Block a user