Skip to content

Commit

Permalink
Disable 3rd party loggers for now, and separate out toggling to a sep…
Browse files Browse the repository at this point in the history
…arate function call not bound to LoggingMachine state.
  • Loading branch information
Sepehr Ghavam authored and Sepehr Ghavam committed Mar 22, 2024
1 parent 41f3769 commit 95fd1f3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions bittensor/btlogging/loggingmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(self, config: bittensor.config, name: str = BITTENSOR_LOGGER_NAME):

# set up all the loggers
self._logger = self._initialize_bt_logger(name, config)
self._initialize_external_loggers(config)
self.disable_third_party_loggers()

def _configure_handlers(self, config) -> list[stdlogging.Handler]:
handlers = list()
Expand Down Expand Up @@ -171,17 +171,22 @@ def _create_file_handler(self, logfile: str):
file_handler.setFormatter(self._file_formatter)
file_handler.setLevel(stdlogging.TRACE)
return file_handler

def _initialize_external_loggers(self, config):

def enable_third_party_loggers(self):
for logger in all_loggers():
if logger.name == self._name:
continue
queue_handler = QueueHandler(self._queue)
logger.addHandler(queue_handler)
logger.setLevel(self._logger.level)

def disable_third_party_loggers(self):
# remove all handlers
for logger in all_loggers():
if logger.name == self._name:
continue
for handler in logger.handlers:
logger.removeHandler(handler)
queue_handler = QueueHandler(self._queue)
logger.addHandler(queue_handler)
logger.setLevel(stdlogging.CRITICAL)

def _enable_file_logging(self, logfile: str):
# preserve idempotency; do not create extra filehandlers
Expand Down

1 comment on commit 95fd1f3

@BwKJank
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.disable_third_party_loggers() disable logging for Prefect, when it is used in orchestration goal. Moreover, this is also probably related to logging error in Apache Airflow Scheduler

Please sign in to comment.