Pass format arguments to logger

This commit is contained in:
Adam Turner 2024-10-19 19:06:23 +01:00
parent e58dd58f35
commit c973de391e
4 changed files with 32 additions and 11 deletions

View File

@ -259,8 +259,14 @@ class CObject(ObjectDescription[ASTDeclaration]):
self.env.temp_data['c:last_symbol'] = e.symbol self.env.temp_data['c:last_symbol'] = e.symbol
msg = __("Duplicate C declaration, also defined at %s:%s.\n" msg = __("Duplicate C declaration, also defined at %s:%s.\n"
"Declaration is '.. c:%s:: %s'.") "Declaration is '.. c:%s:: %s'.")
msg = msg % (e.symbol.docname, e.symbol.line, self.display_object_type, sig) logger.warning(
logger.warning(msg, location=signode) msg,
e.symbol.docname,
e.symbol.line,
self.display_object_type,
sig,
location=signode,
)
if ast.objectType == 'enumerator': if ast.objectType == 'enumerator':
self._add_enumerator_to_parent(ast) self._add_enumerator_to_parent(ast)

View File

@ -508,9 +508,14 @@ class Symbol:
name = str(ourChild.declaration) name = str(ourChild.declaration)
msg = __("Duplicate C declaration, also defined at %s:%s.\n" msg = __("Duplicate C declaration, also defined at %s:%s.\n"
"Declaration is '.. c:%s:: %s'.") "Declaration is '.. c:%s:: %s'.")
msg = msg % (ourChild.docname, ourChild.line, logger.warning(
ourChild.declaration.directiveType, name) msg,
logger.warning(msg, location=(otherChild.docname, otherChild.line)) ourChild.docname,
ourChild.line,
ourChild.declaration.directiveType,
name,
location=(otherChild.docname, otherChild.line),
)
else: else:
# Both have declarations, and in the same docname. # Both have declarations, and in the same docname.
# This can apparently happen, it should be safe to # This can apparently happen, it should be safe to

View File

@ -359,9 +359,14 @@ class CPPObject(ObjectDescription[ASTDeclaration]):
self.env.temp_data['cpp:last_symbol'] = e.symbol self.env.temp_data['cpp:last_symbol'] = e.symbol
msg = __("Duplicate C++ declaration, also defined at %s:%s.\n" msg = __("Duplicate C++ declaration, also defined at %s:%s.\n"
"Declaration is '.. cpp:%s:: %s'.") "Declaration is '.. cpp:%s:: %s'.")
msg = msg % (e.symbol.docname, e.symbol.line, logger.warning(
self.display_object_type, sig) msg,
logger.warning(msg, location=signode) e.symbol.docname,
e.symbol.line,
self.display_object_type,
sig,
location=signode,
)
if ast.objectType == 'enumerator': if ast.objectType == 'enumerator':
self._add_enumerator_to_parent(ast) self._add_enumerator_to_parent(ast)

View File

@ -792,9 +792,14 @@ class Symbol:
name = str(ourChild.declaration) name = str(ourChild.declaration)
msg = __("Duplicate C++ declaration, also defined at %s:%s.\n" msg = __("Duplicate C++ declaration, also defined at %s:%s.\n"
"Declaration is '.. cpp:%s:: %s'.") "Declaration is '.. cpp:%s:: %s'.")
msg = msg % (ourChild.docname, ourChild.line, logger.warning(
ourChild.declaration.directiveType, name) msg,
logger.warning(msg, location=(otherChild.docname, otherChild.line)) ourChild.docname,
ourChild.line,
ourChild.declaration.directiveType,
name,
location=(otherChild.docname, otherChild.line),
)
else: else:
if (otherChild.declaration.objectType == if (otherChild.declaration.objectType ==
ourChild.declaration.objectType and ourChild.declaration.objectType and