Skip to content

Commit

Permalink
run
Browse files Browse the repository at this point in the history
  • Loading branch information
horheynm committed Aug 22, 2024
1 parent c57f891 commit 54b4930
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/llmcompressor/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class LoggerConfig:
console_log_level: Optional[str] = "INFO"
log_file: Optional[str] = None
log_file_level: Optional[str] = None
metrics_disabled: bool = False
metrics_disabled: bool = True


def configure_logger(config: Optional[LoggerConfig] = None):
Expand All @@ -75,7 +75,7 @@ def configure_logger(config: Optional[LoggerConfig] = None):
logger_config.console_log_level = console_log_level.upper()
if (log_file := os.getenv("LLM_COMPRESSOR_LOG_FILE")) is not None:
logger_config.log_file = log_file
if log_file_level := os.getenv("LLM_COMPRESSOR_LOG_FILE_LEVEL"):
if (log_file_level := os.getenv("LLM_COMPRESSOR_LOG_FILE_LEVEL")) is not None:
logger_config.log_file_level = log_file_level

if logger_config.disabled:
Expand All @@ -101,8 +101,9 @@ def configure_logger(config: Optional[LoggerConfig] = None):
# log as json to the file for easier parsing
logger.add(log_file, level=log_file_level.upper(), serialize=True)

if logger_config.metrics_disabled or "METRIC" in logger._core.levels.keys():
if logger_config.metrics_disabled:
return

# initialize metric logger on loguru
_initialize_metric_logging()

Expand All @@ -112,10 +113,11 @@ def _initialize_metric_logging() -> None:
Initalize metric logging for loguru and metric-related libraries
Defaults to stdout
usage:
`logger.log("METRIC", "foo description, bar result")`
`logger.log("METRICS", "foo description, bar result")`
"""
logger.level("METRIC", no=38, color="<yellow>", icon="📈")
if not any(level.name == "METRICS" for level in logger._core.levels.values()):
logger.level("METRICS", no=38, color="<yellow>", icon="📈")


# invoke logger setup on import with default values enabling console logging with INFO
Expand Down

0 comments on commit 54b4930

Please sign in to comment.