(fix) Enable and log if logging to file is enabled (#3556)

* enable logging to file also when DEBUG is active

* Log a message if logging to file is enabled

* log a message if DEBUG mode is enabled
This commit is contained in:
tobitege
2024-08-27 22:36:33 +02:00
committed by GitHub
parent 0cdeb83b17
commit 097fbd6362

View File

@@ -165,7 +165,10 @@ LOG_DIR = os.path.join(
'logs',
)
if LOG_TO_FILE:
if DEBUG:
openhands_logger.setLevel(logging.DEBUG)
if LOG_TO_FILE or DEBUG:
# default log to project root
openhands_logger.debug('Logging to file is enabled. Logging to %s', LOG_DIR)
openhands_logger.addHandler(get_file_handler(LOG_DIR))
@@ -175,6 +178,10 @@ openhands_logger.addFilter(SensitiveDataFilter(openhands_logger.name))
openhands_logger.propagate = False
openhands_logger.debug('Logging initialized')
if LOG_TO_FILE or DEBUG:
openhands_logger.info('Logging to file is enabled. Logging to %s', LOG_DIR)
if DEBUG:
openhands_logger.info('DEBUG mode enabled')
# Exclude LiteLLM from logging output
logging.getLogger('LiteLLM').disabled = True