graphrag/graphrag/callbacks/console_workflow_callbacks.py
2024-10-10 17:01:42 -04:00

33 lines
980 B
Python

# Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""A logger that emits updates from the indexing engine to the console."""
from datashaper import NoopWorkflowCallbacks
class ConsoleWorkflowCallbacks(NoopWorkflowCallbacks):
"""A logger that writes to a console."""
def on_error(
self,
message: str,
cause: BaseException | None = None,
stack: str | None = None,
details: dict | None = None,
):
"""Handle when an error occurs."""
print(message, str(cause), stack, details) # noqa T201
def on_warning(self, message: str, details: dict | None = None):
"""Handle when a warning occurs."""
_print_warning(message)
def on_log(self, message: str, details: dict | None = None):
"""Handle when a log message is produced."""
print(message, details) # noqa T201
def _print_warning(skk):
print("\033[93m {}\033[00m".format(skk)) # noqa T201