Adds a subtype to all logger.warning calls

This commit is contained in:
René Fritze 2021-04-01 14:22:47 +02:00 committed by Ashley Whetter
parent bec1f6c1b0
commit dbd1e9dfe6
5 changed files with 64 additions and 18 deletions

View File

@ -104,10 +104,13 @@ class DotNetSphinxMapper(SphinxMapperBase):
) )
_, error_output = proc.communicate() _, error_output = proc.communicate()
if error_output: if error_output:
LOGGER.warning(error_output, type="autoapi") LOGGER.warning(error_output, type="autoapi", subtype="not_readable")
except (OSError, subprocess.CalledProcessError): except (OSError, subprocess.CalledProcessError):
LOGGER.warning( LOGGER.warning(
"Error generating metadata", exc_info=True, type="autoapi" "Error generating metadata",
exc_info=True,
type="autoapi",
subtype="metadata_generation",
) )
if raise_error: if raise_error:
raise ExtensionError( raise ExtensionError(
@ -133,9 +136,17 @@ class DotNetSphinxMapper(SphinxMapperBase):
parsed_data = yaml.safe_load(handle) parsed_data = yaml.safe_load(handle)
return parsed_data return parsed_data
except IOError: except IOError:
LOGGER.warning("Error reading file: {0}".format(path), type="autoapi") LOGGER.warning(
"Error reading file: {0}".format(path),
type="autoapi",
subtype="not_readable",
)
except TypeError: except TypeError:
LOGGER.warning("Error reading file: {0}".format(path), type="autoapi") LOGGER.warning(
"Error reading file: {0}".format(path),
type="autoapi",
subtype="not_readable",
)
return None return None
# Subclassed to iterate over items # Subclassed to iterate over items
@ -174,7 +185,9 @@ class DotNetSphinxMapper(SphinxMapperBase):
try: try:
cls = obj_map[data["type"].lower()] cls = obj_map[data["type"].lower()]
except KeyError: except KeyError:
LOGGER.warning("Unknown type: %s" % data, type="autoapi") LOGGER.warning(
"Unknown type: %s" % data, type="autoapi", subtype="create_class"
)
else: else:
obj = cls( obj = cls(
data, jinja_env=self.jinja_env, app=self.app, options=options, **kwargs data, jinja_env=self.jinja_env, app=self.app, options=options, **kwargs

View File

@ -54,9 +54,17 @@ class GoSphinxMapper(SphinxMapperBase):
parsed_data = json.loads(subprocess.check_output(parser_command)) parsed_data = json.loads(subprocess.check_output(parser_command))
return parsed_data return parsed_data
except IOError: except IOError:
LOGGER.warning("Error reading file: {0}".format(path), type="autoapi") LOGGER.warning(
"Error reading file: {0}".format(path),
type="autoapi",
subtype="not_readable",
)
except TypeError: except TypeError:
LOGGER.warning("Error reading file: {0}".format(path), type="autoapi") LOGGER.warning(
"Error reading file: {0}".format(path),
type="autoapi",
subtype="not_readable",
)
return None return None
def create_class(self, data, options=None, **kwargs): def create_class(self, data, options=None, **kwargs):
@ -83,7 +91,9 @@ class GoSphinxMapper(SphinxMapperBase):
else: else:
cls = obj_map[data["type"]] cls = obj_map[data["type"]]
except KeyError: except KeyError:
LOGGER.warning("Unknown Type: %s" % data, type="autoapi") LOGGER.warning(
"Unknown Type: %s" % data, type="autoapi", subtype="create_class"
)
else: else:
if cls.inverted_names and "names" in data: if cls.inverted_names and "names" in data:
# Handle types that have reversed names parameter # Handle types that have reversed names parameter

View File

@ -34,9 +34,17 @@ class JavaScriptSphinxMapper(SphinxMapperBase):
parsed_data = json.loads(subprocess.check_output([subcmd, "-X", path])) parsed_data = json.loads(subprocess.check_output([subcmd, "-X", path]))
return parsed_data return parsed_data
except IOError: except IOError:
LOGGER.warning("Error reading file: {0}".format(path), type="autoapi") LOGGER.warning(
"Error reading file: {0}".format(path),
type="autoapi",
subtype="not_readable",
)
except TypeError: except TypeError:
LOGGER.warning("Error reading file: {0}".format(path), type="autoapi") LOGGER.warning(
"Error reading file: {0}".format(path),
type="autoapi",
subtype="not_readable",
)
return None return None
# Subclassed to iterate over items # Subclassed to iterate over items
@ -71,7 +79,9 @@ class JavaScriptSphinxMapper(SphinxMapperBase):
try: try:
cls = obj_map[data["kind"]] cls = obj_map[data["kind"]]
except (KeyError, TypeError): except (KeyError, TypeError):
LOGGER.warning("Unknown Type: %s" % data, type="autoapi") LOGGER.warning(
"Unknown Type: %s" % data, type="autoapi", subtype="create_class"
)
else: else:
# Recurse for children # Recurse for children
obj = cls(data, jinja_env=self.jinja_env, app=self.app) obj = cls(data, jinja_env=self.jinja_env, app=self.app)

View File

@ -52,7 +52,7 @@ def _expand_wildcard_placeholder(original_module, originals_map, placeholder):
msg = "Invalid __all__ entry {0} in {1}".format( msg = "Invalid __all__ entry {0} in {1}".format(
name, original_module["name"] name, original_module["name"]
) )
LOGGER.warning(msg, type="autoapi") LOGGER.warning(msg, type="autoapi", subtype="python_import_resolution")
continue continue
originals.append(originals_map[name]) originals.append(originals_map[name])
@ -107,7 +107,7 @@ def _resolve_module_placeholders(modules, module_name, visit_path, resolved):
msg = "Cannot resolve cyclic import: {0}, {1}".format( msg = "Cannot resolve cyclic import: {0}, {1}".format(
", ".join(visit_path), imported_from ", ".join(visit_path), imported_from
) )
LOGGER.warning(msg, type="autoapi") LOGGER.warning(msg, type="autoapi", subtype="python_import_resolution")
module["children"].remove(child) module["children"].remove(child)
children.pop(child["name"]) children.pop(child["name"])
continue continue
@ -116,7 +116,7 @@ def _resolve_module_placeholders(modules, module_name, visit_path, resolved):
msg = "Cannot resolve import of unknown module {0} in {1}".format( msg = "Cannot resolve import of unknown module {0} in {1}".format(
imported_from, module_name imported_from, module_name
) )
LOGGER.warning(msg, type="autoapi") LOGGER.warning(msg, type="autoapi", subtype="python_import_resolution")
module["children"].remove(child) module["children"].remove(child)
children.pop(child["name"]) children.pop(child["name"])
continue continue
@ -144,7 +144,7 @@ def _resolve_module_placeholders(modules, module_name, visit_path, resolved):
msg = "Cannot resolve import of {0} in {1}".format( msg = "Cannot resolve import of {0} in {1}".format(
child["original_path"], module_name child["original_path"], module_name
) )
LOGGER.warning(msg, type="autoapi") LOGGER.warning(msg, type="autoapi", subtype="python_import_resolution")
module["children"].remove(child) module["children"].remove(child)
children.pop(child["name"]) children.pop(child["name"])
continue continue
@ -319,7 +319,11 @@ class PythonSphinxMapper(SphinxMapperBase):
return parsed_data return parsed_data
except (IOError, TypeError, ImportError): except (IOError, TypeError, ImportError):
LOGGER.debug("Reason:", exc_info=True) LOGGER.debug("Reason:", exc_info=True)
LOGGER.warning("Unable to read file: {0}".format(path), type="autoapi") LOGGER.warning(
"Unable to read file: {0}".format(path),
type="autoapi",
subtype="not_readable",
)
return None return None
def _resolve_placeholders(self): def _resolve_placeholders(self):
@ -359,7 +363,11 @@ class PythonSphinxMapper(SphinxMapperBase):
try: try:
cls = self._OBJ_MAP[data["type"]] cls = self._OBJ_MAP[data["type"]]
except KeyError: except KeyError:
LOGGER.warning("Unknown type: %s" % data["type"], type="autoapi") LOGGER.warning(
"Unknown type: %s" % data["type"],
type="autoapi",
subtype="create_class",
)
else: else:
obj = cls( obj = cls(
data, data,

View File

@ -91,7 +91,12 @@ def _get_toc_reference(node, toc, docname):
ref_id = node.children[0].attributes["ids"][0] ref_id = node.children[0].attributes["ids"][0]
toc_reference = _find_toc_node(toc, ref_id, addnodes.desc) toc_reference = _find_toc_node(toc, ref_id, addnodes.desc)
except (KeyError, IndexError): except (KeyError, IndexError):
LOGGER.warning("Invalid desc node", exc_info=True, type="autoapi") LOGGER.warning(
"Invalid desc node",
exc_info=True,
type="autoapi",
subtype="toc_reference",
)
toc_reference = None toc_reference = None
return toc_reference return toc_reference