odoo/odoo#200418

Created by fw-bot
Merged at 8bd6d51e07a9511cd7b12a08a2e189c5603ddc44

Statuses:

label
odoo-dev:saas-17.4-18.0-netsvc-log-metadata-xdo-420665-fw
head
fd1fefe4ecd1f66c76f316fd83f662124d81c8e9
merged
7 months ago by Framework (ORM), Xavier Dollé (xdo)
odoo/odoo
16.0 #199964
17.0 #200408
saas-17.4 #200418
18.0 #200429
saas-18.1 #200458
saas-18.2 #200476
saas-18.3
saas-18.4
19.0
master #200769

[FW][IMP] runbot: add metadata to log_db

When handling errors on runbot, it can be difficult to know where a message comes from. It can be problematic to identify automatically the source of an error.

This branch give the possibility to add metadata to log_db.

The current only metadata is the canonical tag.

Some other information, like the stack, or the subtest could be added in the future. This is not the case for now to make the review easier.

     def get_log_metadata(self):
+        stack = traceback.format_stack()
+        start = next((index for index, frame in enumerate(stack) if self._testMethodName in frame), 0)
         metadata = {
             'canonical_tag': self.canonical_tag,
+            'stack': '\n'.join(traceback.format_stack()[start:-7]),
+            'subtest': str(self._subtest),
         }
         return metadata

Forward-Port-Of: #199964