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
msg = __("Duplicate C declaration, also defined at %s:%s.\n"
"Declaration is '.. c:%s:: %s'.")
msg = msg % (e.symbol.docname, e.symbol.line, self.display_object_type, sig)
logger.warning(msg, location=signode)
logger.warning(
msg,
e.symbol.docname,
e.symbol.line,
self.display_object_type,
sig,
location=signode,
)
if ast.objectType == 'enumerator':
self._add_enumerator_to_parent(ast)

View File

@ -508,9 +508,14 @@ class Symbol:
name = str(ourChild.declaration)
msg = __("Duplicate C declaration, also defined at %s:%s.\n"
"Declaration is '.. c:%s:: %s'.")
msg = msg % (ourChild.docname, ourChild.line,
ourChild.declaration.directiveType, name)
logger.warning(msg, location=(otherChild.docname, otherChild.line))
logger.warning(
msg,
ourChild.docname,
ourChild.line,
ourChild.declaration.directiveType,
name,
location=(otherChild.docname, otherChild.line),
)
else:
# Both have declarations, and in the same docname.
# 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
msg = __("Duplicate C++ declaration, also defined at %s:%s.\n"
"Declaration is '.. cpp:%s:: %s'.")
msg = msg % (e.symbol.docname, e.symbol.line,
self.display_object_type, sig)
logger.warning(msg, location=signode)
logger.warning(
msg,
e.symbol.docname,
e.symbol.line,
self.display_object_type,
sig,
location=signode,
)
if ast.objectType == 'enumerator':
self._add_enumerator_to_parent(ast)

View File

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