mirror of
https://github.com/thatmattlove/hyperglass.git
synced 2026-01-17 08:48:05 +00:00
fix logging issues
This commit is contained in:
parent
b617df24d1
commit
41248231ae
5 changed files with 14 additions and 8 deletions
|
|
@ -47,7 +47,7 @@ async def execute(query: "Query") -> Union["OutputDataModel", str]:
|
|||
"""Initiate query validation and execution."""
|
||||
params = use_state("params")
|
||||
output = params.messages.general
|
||||
_log = log.bind(query=query, device=query.device)
|
||||
_log = log.bind(query=query.summary(), device=query.device)
|
||||
_log.debug("")
|
||||
|
||||
mapped_driver = map_driver(query.device.driver)
|
||||
|
|
@ -67,7 +67,6 @@ async def execute(query: "Query") -> Union["OutputDataModel", str]:
|
|||
response = await driver.collect()
|
||||
|
||||
output = await driver.response(response)
|
||||
_log.bind(response=response).debug("Query response")
|
||||
|
||||
if is_series(output):
|
||||
if len(output) == 0:
|
||||
|
|
|
|||
|
|
@ -56,8 +56,6 @@ async def read_package_json() -> t.Dict[str, t.Any]:
|
|||
except Exception as err:
|
||||
raise RuntimeError(f"Error reading package.json: {str(err)}") from err
|
||||
|
||||
log.bind(package_json=package_json).debug("package.json value")
|
||||
|
||||
return package_json
|
||||
|
||||
|
||||
|
|
@ -328,7 +326,6 @@ async def build_frontend( # noqa: C901
|
|||
}
|
||||
|
||||
build_json = json.dumps(build_data, default=str)
|
||||
log.bind(data=build_json).debug("UI Build Data")
|
||||
|
||||
# Create SHA256 hash from all parameters passed to UI, use as
|
||||
# build identifier.
|
||||
|
|
|
|||
|
|
@ -46,6 +46,11 @@ _LOG_LEVELS = [
|
|||
{"name": "CRITICAL", "color": "<r>"},
|
||||
]
|
||||
|
||||
_EXCLUDE_MODULES = (
|
||||
"PIL",
|
||||
"svglib",
|
||||
)
|
||||
|
||||
HyperglassConsole = Console(
|
||||
theme=Theme(
|
||||
{
|
||||
|
|
@ -119,6 +124,9 @@ class LibInterceptHandler(logging.Handler):
|
|||
def init_logger(level: t.Union[int, str] = logging.INFO):
|
||||
"""Initialize hyperglass logging instance."""
|
||||
|
||||
for mod in _EXCLUDE_MODULES:
|
||||
logging.getLogger(mod).propagate = False
|
||||
|
||||
# Reset built-in Loguru configurations.
|
||||
_loguru_logger.remove()
|
||||
|
||||
|
|
@ -133,6 +141,7 @@ def init_logger(level: t.Union[int, str] = logging.INFO):
|
|||
log_time_format="[%Y%m%d %H:%M:%S]",
|
||||
),
|
||||
format=formatter,
|
||||
colorize=False,
|
||||
level=level,
|
||||
filter=filter_uvicorn_values,
|
||||
enqueue=True,
|
||||
|
|
@ -144,6 +153,7 @@ def init_logger(level: t.Union[int, str] = logging.INFO):
|
|||
enqueue=True,
|
||||
format=_FMT if level == logging.INFO else _FMT_DEBUG,
|
||||
level=level,
|
||||
colorize=False,
|
||||
filter=filter_uvicorn_values,
|
||||
)
|
||||
|
||||
|
|
@ -192,6 +202,7 @@ def enable_file_logging(
|
|||
serialize=structured,
|
||||
level=level,
|
||||
encoding="utf8",
|
||||
colorize=False,
|
||||
rotation=max_size.human_readable(),
|
||||
)
|
||||
_loguru_logger.bind(path=log_file).debug("Logging to file")
|
||||
|
|
@ -207,5 +218,6 @@ def enable_syslog_logging(*, host: str, port: int) -> None:
|
|||
SysLogHandler(address=(str(host), port)),
|
||||
format=_FMT_BASIC,
|
||||
enqueue=True,
|
||||
colorize=False,
|
||||
)
|
||||
_loguru_logger.bind(host=host, port=port).debug("Logging to syslog target")
|
||||
|
|
|
|||
|
|
@ -77,8 +77,6 @@ def parse_juniper(output: Sequence[str]) -> "OutputDataModel": # noqa: C901
|
|||
parsed: "OrderedDict" = xmltodict.parse(
|
||||
cleaned, force_list=("rt", "rt-entry", "community")
|
||||
)
|
||||
_log.debug("Pre-parsed data", data=parsed)
|
||||
|
||||
if "rpc-reply" in parsed.keys():
|
||||
if "xnm:error" in parsed["rpc-reply"]:
|
||||
if "message" in parsed["rpc-reply"]["xnm:error"]:
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ class InputPluginManager(PluginManager[InputPlugin], type="input"):
|
|||
"""Execute all input transformation plugins."""
|
||||
result = query.query_target
|
||||
for plugin in self._gather_plugins(query):
|
||||
result = plugin.transform(query=query)
|
||||
result = plugin.transform(query=query.summary())
|
||||
log.bind(name=plugin.name, result=repr(result)).debug("Input Plugin Transform")
|
||||
return result
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue