From b2b36524c27ddd8a892fe740a5eec874e06f8cf8 Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Wed, 4 Mar 2020 11:00:38 +0000 Subject: [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) --- odoo/tests/common.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'odoo/tests') diff --git a/odoo/tests/common.py b/odoo/tests/common.py index a86f0cc8bcf..15bc0ce1cec 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -964,7 +964,7 @@ class ChromeBrowser(): full_path = os.path.join(self.screenshots_dir, fname) with open(full_path, 'wb') as f: f.write(decoded) - self._logger.log(25, 'Screenshot in: %s', full_path) + self._logger.runbot('Screenshot in: %s', full_path) def _save_screencast(self, prefix='failed'): # could be encododed with something like that @@ -993,11 +993,11 @@ class ChromeBrowser(): if ffmpeg_path: framerate = int(len(self.screencast_frames) / (self.screencast_frames[-1].get('timestamp') - self.screencast_frames[0].get('timestamp'))) r = subprocess.run([ffmpeg_path, '-framerate', str(framerate), '-i', '%s/frame_%%05d.png' % self.screencasts_dir, outfile]) - self._logger.log(25, 'Screencast in: %s', outfile) + self._logger.runbot('Screencast in: %s', outfile) else: outfile = outfile.strip('.mp4') shutil.move(self.screencasts_frames_dir, outfile) - self._logger.log(25, 'Screencast frames in: %s', outfile) + self._logger.runbot('Screencast frames in: %s', outfile) def start_screencast(self): if self.screencasts_dir: -- cgit v1.2.3