Skip to content

Commit

Permalink
revert oh changes
Browse files Browse the repository at this point in the history
  • Loading branch information
xingyaoww committed Dec 16, 2024
1 parent 6f282c1 commit c1c5ffd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 13 additions & 0 deletions openhands/core/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

LOG_LEVEL = os.getenv('LOG_LEVEL', 'INFO').upper()
DEBUG = os.getenv('DEBUG', 'False').lower() in ['true', '1', 'yes']
DEBUG_RUNTIME = os.getenv('DEBUG_RUNTIME', 'False').lower() in ['true', '1', 'yes']
if DEBUG:
LOG_LEVEL = 'DEBUG'

Expand Down Expand Up @@ -353,3 +354,15 @@ def _setup_llm_logger(name: str, log_level: int):

llm_prompt_logger = _setup_llm_logger('prompt', current_log_level)
llm_response_logger = _setup_llm_logger('response', current_log_level)

# Runtime logger - only enabled when DEBUG_RUNTIME=true
runtime_logger = logging.getLogger('runtime')
runtime_logger.propagate = False
runtime_logger.setLevel(current_log_level)
runtime_logger.addHandler(get_console_handler(current_log_level))
if LOG_TO_FILE:
runtime_logger.addHandler(
get_file_handler(os.path.join(LOG_DIR, 'runtime'), current_log_level)
)
if not DEBUG_RUNTIME:
runtime_logger.disabled = True
6 changes: 4 additions & 2 deletions openhands/runtime/utils/log_streamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import docker

from openhands.core.logger import runtime_logger


class LogStreamer:
"""Streams Docker container logs to stdout.
Expand Down Expand Up @@ -33,9 +35,9 @@ def _stream_logs(self):
break
if log_line:
decoded_line = log_line.decode('utf-8').rstrip()
self.log('debug', f'[inside container] {decoded_line}')
runtime_logger.debug(f'[inside container] {decoded_line}')
except Exception as e:
self.log('error', f'Error streaming docker logs to stdout: {e}')
runtime_logger.error(f'Error streaming docker logs to stdout: {e}')

def __del__(self):
if self.stdout_thread and self.stdout_thread.is_alive():
Expand Down

0 comments on commit c1c5ffd

Please sign in to comment.