Adds a subtype to all `logger.warning` calls

pull/284/head
René Fritze 4 years ago committed by Ashley Whetter
parent bec1f6c1b0
commit dbd1e9dfe6

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

@ -54,9 +54,17 @@ class GoSphinxMapper(SphinxMapperBase):
parsed_data = json.loads(subprocess.check_output(parser_command))
return parsed_data
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:
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
def create_class(self, data, options=None, **kwargs):
@ -83,7 +91,9 @@ class GoSphinxMapper(SphinxMapperBase):
else:
cls = obj_map[data["type"]]
except KeyError:
LOGGER.warning("Unknown Type: %s" % data, type="autoapi")
LOGGER.warning(
"Unknown Type: %s" % data, type="autoapi", subtype="create_class"
)
else:
if cls.inverted_names and "names" in data:
# Handle types that have reversed names parameter

@ -34,9 +34,17 @@ class JavaScriptSphinxMapper(SphinxMapperBase):
parsed_data = json.loads(subprocess.check_output([subcmd, "-X", path]))
return parsed_data
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:
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
# Subclassed to iterate over items
@ -71,7 +79,9 @@ class JavaScriptSphinxMapper(SphinxMapperBase):
try:
cls = obj_map[data["kind"]]
except (KeyError, TypeError):
LOGGER.warning("Unknown Type: %s" % data, type="autoapi")
LOGGER.warning(
"Unknown Type: %s" % data, type="autoapi", subtype="create_class"
)
else:
# Recurse for children
obj = cls(data, jinja_env=self.jinja_env, app=self.app)

@ -52,7 +52,7 @@ def _expand_wildcard_placeholder(original_module, originals_map, placeholder):
msg = "Invalid __all__ entry {0} in {1}".format(
name, original_module["name"]
)
LOGGER.warning(msg, type="autoapi")
LOGGER.warning(msg, type="autoapi", subtype="python_import_resolution")
continue
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(
", ".join(visit_path), imported_from
)
LOGGER.warning(msg, type="autoapi")
LOGGER.warning(msg, type="autoapi", subtype="python_import_resolution")
module["children"].remove(child)
children.pop(child["name"])
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(
imported_from, module_name
)
LOGGER.warning(msg, type="autoapi")
LOGGER.warning(msg, type="autoapi", subtype="python_import_resolution")
module["children"].remove(child)
children.pop(child["name"])
continue
@ -144,7 +144,7 @@ def _resolve_module_placeholders(modules, module_name, visit_path, resolved):
msg = "Cannot resolve import of {0} in {1}".format(
child["original_path"], module_name
)
LOGGER.warning(msg, type="autoapi")
LOGGER.warning(msg, type="autoapi", subtype="python_import_resolution")
module["children"].remove(child)
children.pop(child["name"])
continue
@ -319,7 +319,11 @@ class PythonSphinxMapper(SphinxMapperBase):
return parsed_data
except (IOError, TypeError, ImportError):
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
def _resolve_placeholders(self):
@ -359,7 +363,11 @@ class PythonSphinxMapper(SphinxMapperBase):
try:
cls = self._OBJ_MAP[data["type"]]
except KeyError:
LOGGER.warning("Unknown type: %s" % data["type"], type="autoapi")
LOGGER.warning(
"Unknown type: %s" % data["type"],
type="autoapi",
subtype="create_class",
)
else:
obj = cls(
data,

@ -91,7 +91,12 @@ def _get_toc_reference(node, toc, docname):
ref_id = node.children[0].attributes["ids"][0]
toc_reference = _find_toc_node(toc, ref_id, addnodes.desc)
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
return toc_reference

Loading…
Cancel
Save