summaryrefslogtreecommitdiff
path: root/odoo/netsvc.py
diff options
context:
space:
mode:
authorAdrian Torres <adt@odoo.com>2020-03-26 08:37:42 +0000
committerRaphael Collet <rco@odoo.com>2020-03-26 09:25:15 +0000
commit975ba2772304c66adf8be66a353fab529ada9c35 (patch)
tree06cd4578398f7ab996488b993f1e893eded3c819 /odoo/netsvc.py
parent34227348f0097eb6d357fb1b22fcdb68240f4b4a (diff)
[FIX] core: enable logger.runbot() when importing odoo as a library
Before this commit, trying to use Odoo as a library without initializing the logging features would result in a crash because `Logger.runbot()` is monkey-patched inside the function `init_logger()`, which is de facto necessary for using Odoo as a lib. With this commit, we do the monkey-patch at the module-level so whenever the `netsvc` package is imported the patch is applied, which should be well before the loading of the registry starts. closes odoo/odoo#48396 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/netsvc.py')
-rw-r--r--odoo/netsvc.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/odoo/netsvc.py b/odoo/netsvc.py
index b731eb347bd..9025532f32f 100644
--- a/odoo/netsvc.py
+++ b/odoo/netsvc.py
@@ -125,14 +125,6 @@ def init_logger():
return record
logging.setLogRecordFactory(record_factory)
- logging.RUNBOT = 25
- logging.addLevelName(logging.RUNBOT, "INFO") # displayed as info in log
- logging.captureWarnings(True)
-
- def runbot(self, message, *args, **kws):
- self.log(logging.RUNBOT, message, *args, **kws)
- logging.Logger.runbot = runbot
-
# enable deprecation warnings (disabled by default)
warnings.filterwarnings('once', category=DeprecationWarning)
# ignore deprecation warnings from invalid escape (there's a ton and it's
@@ -242,3 +234,11 @@ PSEUDOCONFIG_MAPPER = {
'error': ['odoo:ERROR', 'werkzeug:ERROR'],
'critical': ['odoo:CRITICAL', 'werkzeug:CRITICAL'],
}
+
+logging.RUNBOT = 25
+logging.addLevelName(logging.RUNBOT, "INFO") # displayed as info in log
+logging.captureWarnings(True)
+
+def runbot(self, message, *args, **kws):
+ self.log(logging.RUNBOT, message, *args, **kws)
+logging.Logger.runbot = runbot