Configure the metrics for LLM Compressor. This function sets up the console and file logging as per the specified or default parameters.
Note: Environment variables take precedence over the function parameters.
Parameters:
| Name | Type | Description | Default |
config | LoggingSettings | The configuration for the logger to use. | logging |
Source code in src/guidellm/logger.py
| def configure_logger(config: LoggingSettings = settings.logging):
"""
Configure the metrics for LLM Compressor.
This function sets up the console and file logging
as per the specified or default parameters.
Note: Environment variables take precedence over the function parameters.
:param config: The configuration for the logger to use.
:type config: LoggerConfig
"""
if config.disabled:
logger.disable("guidellm")
return
logger.enable("guidellm")
if config.clear_loggers:
logger.remove()
# log as a human readable string with the time, function, level, and message
logger.add(
sys.stdout,
level=config.console_log_level.upper(),
format="<green>{time:YY-MM-DD HH:mm:ss}</green>|<level>{level: <8}</level> \
|<cyan>{name}:{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>",
)
if config.log_file or config.log_file_level:
log_file = config.log_file or "guidellm.log"
log_file_level = config.log_file_level or "INFO"
# log as json to the file for easier parsing
logger.add(log_file, level=log_file_level.upper(), serialize=True)
|