Skip to main content

Logging Utilities

Utilities for configuring and controlling Verifiers logging output.

Overview

The verifiers.utils.logging_utils module provides:
  • Centralized logging configuration
  • JSON logging support
  • Context managers for temporary log level changes
  • Formatted output for training/evaluation

Logger Name

All Verifiers logging uses the "verifiers" logger. Access it via:

Functions

setup_logging

Configure logging for the Verifiers package.
str | None
default:"INFO"
Console logging level ("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"). If None, disables logging.
str | None
Custom log format string. Defaults to "%(asctime)s - %(name)s - %(levelname)s - %(message)s".
str | None
Date format string. Defaults to "%Y-%m-%d %H:%M:%S".
str | None
Optional path to log file. If specified, logs are written to this file.
str | None
Log level for file handler. If None, uses same level as console.
bool
default:"False"
If True, output logs as JSON (structured logging).
Example:

log_level

Context manager to temporarily change the Verifiers log level.
str | int
New log level (e.g., "DEBUG", "WARNING", or logging.DEBUG).
Example:

quiet_verifiers

Context manager to temporarily silence Verifiers logging (sets level to WARNING). Useful for suppressing INFO and DEBUG messages during specific operations while still showing warnings and errors. Returns: Context manager that temporarily sets log level to WARNING. Example:
Print a formatted table of prompts, completions, and rewards. Displays samples in a Rich table with color-coded columns (yellow for prompts, green for completions, cyan for rewards). Errors are shown in red within the completion column.
list[Messages]
required
List of input prompts (message format).
list[Messages]
required
List of model completions (message format).
list[Error | ErrorInfo | None]
required
List of errors (or None for successful rollouts).
list[float]
required
List of reward scores. If fewer rewards than prompts, pads with 0.0.
int
required
Training step number (displayed in panel title).
int
default:"1"
Number of samples to display from the lists.
Example:
Format seconds as human-readable time string. Examples:
  • 0.05"50ms"
  • 30.0"30s"
  • 90.0"1m 30s"
  • 3700.0"1h 2m"
  • 90000.0"1d 1h"

JSON Logging

JsonFormatter

JSON formatter for structured logging. Output Format:
Example:

Example Usage

Basic Setup

Debug Mode

File Logging

Quiet Mode

Production Logging

Temporary Debug

Custom Format

Logging Levels

Detailed information for diagnosing problems. Very verbose.
Confirmation that things are working as expected. Default level.
Indication of potential issues (e.g., deprecated features).
Serious problem that prevented a function from completing.
Very serious error that may cause termination.

Best Practices

1. Set Up Early

2. Use Appropriate Levels

3. Environment-Specific Config

4. Quiet External Libraries

See Also