summaryrefslogtreecommitdiff
path: root/odoo/netsvc.py
diff options
context:
space:
mode:
authorXavier-Do <xdo@odoo.com>2020-03-04 11:00:38 +0000
committerXavier-Do <xdo@odoo.com>2020-03-16 13:21:57 +0000
commitb2b36524c27ddd8a892fe740a5eec874e06f8cf8 (patch)
treebfe74f8bd4a855954a617cca673ffb8cc33cbb96 /odoo/netsvc.py
parenta12479aaa8cb2c8311c8d6c0fceb0dc641b44eac (diff)
[IMP] core: improve module loading logs
Performances from a general point of view can be difficult to track. This commit proposes to improve logs in two ways: The current logs only use the sql_counter, wich will only be updated when a cursor is closed. In a test-enable install, this counter is actually the queries of the tests wince the install cursor is open untill the end. The first fix is to use bot sql_counter and sql_log_count to have total queries untill now on closed cursor, but also the current number of queries of the current cursor. This means that the new log format will be {nb} modules loaded in {time}, {loading_querie} (+{test_cr_queries}) queries instead of {nb} modules loaded in {time}, {tests_cr__queries}queries Nothe that in the current version, {nb} is actually the total number of loaded modules until now. This commit also add an equivalent end log by module and change the loglevel of module start on install (mainly usefull if an error occurs before anything else is logged hidding the module causing this error.) A cleaner runbot logger is also added, in order to be abble to call _logger.runbot( instead of _logger.log(25. This will clarify the purpose of such a log level. closes odoo/odoo#47283 Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
Diffstat (limited to 'odoo/netsvc.py')
-rw-r--r--odoo/netsvc.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/odoo/netsvc.py b/odoo/netsvc.py
index a9c1a365986..8257dccdbcb 100644
--- a/odoo/netsvc.py
+++ b/odoo/netsvc.py
@@ -125,9 +125,14 @@ def init_logger():
return record
logging.setLogRecordFactory(record_factory)
- logging.addLevelName(25, "INFO")
+ 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
@@ -228,6 +233,7 @@ PSEUDOCONFIG_MAPPER = {
'debug': ['odoo:DEBUG', 'odoo.sql_db:INFO'],
'debug_sql': ['odoo.sql_db:DEBUG'],
'info': [],
+ 'runbot': ['odoo:RUNBOT', 'werkzeug:WARNING'],
'warn': ['odoo:WARNING', 'werkzeug:WARNING'],
'error': ['odoo:ERROR', 'werkzeug:ERROR'],
'critical': ['odoo:CRITICAL', 'werkzeug:CRITICAL'],