odoo/odoo#200408

Created by fw-bot
Merged at cb2db6f6ce405426519a8bb2e5a1ab128f02f931

Statuses:

label
odoo-dev:17.0-18.0-netsvc-log-metadata-xdo-419916-fw
head
b8c55af297bb13a32a85a189cb04735b2b889d41
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