Skip to content

feat: add optional logger_prefix config and --logger-prefix CLI flag - #507

Merged
codelion merged 1 commit into
algorithmicsuperintelligence:mainfrom
akushonkamen:feat/290-logger-prefix
Oct 10, 2026
Merged

codelion merged 1 commit into
algorithmicsuperintelligence:mainfrom
akushonkamen:feat/290-logger-prefix

Conversation

@akushonkamen

@akushonkamen akushonkamen commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add an optional logger prefix so log output from concurrent OpenEvolve runs can be told apart.

  • New Config.logger_prefix: Optional[str] — set it directly when using the library: OpenEvolve(..., config=Config(logger_prefix="run1")) or openevolve.run_evolution(..., config=Config(logger_prefix="run1")), addressing the "optional prefix" request in Feature Request: Logger prefix #290 (delivered via Config + CLI rather than a run() kwarg, as planned on the issue).
  • New --logger-prefix CLI flag, applied to the config before the controller is constructed.
  • New LoggerPrefixFilter (openevolve/utils/logging_utils.py): a handler-level logging.Filter installed by _setup_logging() that rewrites record.name (e.g. openevolve.controller → run1.openevolve.controller). Since all module loggers are created at import time via logging.getLogger(__name__), rewriting record.name at the handler level is the one clean point that covers all of them without touching each module.
  • The filter is idempotent: the same LogRecord object flows through every handler on the logger, so the prefix is applied exactly once.
  • When a prefix is active, the console formatter also gains %(name)s (the file formatter already had it). Without a prefix the output format is byte-for-byte unchanged.

Example:

2026-10-10 23:02:00 - run1.openevolve.controller - INFO - Logging to .../logs/openevolve_20261010_230200.log

Motivation

Fixes #290. As @theahura reported, running multiple openevolve.run() calls in parallel makes it extremely hard to tell which logs belong to which run. @codelion endorsed the idea on 2025-10-13: "This is a good idea we can add a logger prefix." This PR lands exactly that, with the smallest footprint possible.

Scope notes

Testing

New fully-offline unittest suite tests/test_logger_prefix.py (7 tests; LLMEnsemble/Evaluator patched, no LLM calls):

  • Filter unit tests: rewrites record.name, idempotent under repeated application, empty prefix is a no-op, never swallows records.
  • Integration tests: constructing OpenEvolve(config=Config(logger_prefix="run1")) (constructor runs _setup_logging) writes run1.openevolve.controller to both the log file and the console stream; with no prefix, output is unchanged (plain names, no run1.).

Red → green:

  • Before implementation: ModuleNotFoundError: No module named 'openevolve.utils.logging_utils' (1 test, FAILED).
  • After implementation: Ran 7 tests ... OK.

Full regression (CONTRIBUTING command):

export OPENAI_API_KEY=test-key-for-unit-tests
python -m unittest discover tests
...
Ran 629 tests in 69.690s
OK

Formatting: black --line-length 100 and isort --profile black --line-length 100 applied to all changed files.

Running multiple OpenEvolve calls in parallel makes it hard to tell which
log lines belong to which run (issue algorithmicsuperintelligence#290). Add an optional prefix that is
applied to every downstream module logger name:

- Config.logger_prefix (e.g. "run1" logs as "run1.openevolve.*")
- --logger-prefix CLI flag, applied before controller construction
- New LoggerPrefixFilter (openevolve/utils/logging_utils.py): a
  handler-level logging.Filter that rewrites record.name in
  _setup_logging; idempotent so a record shared by several handlers is
  only prefixed once. The console formatter gains %(name)s only when a
  prefix is set, so the default output format is unchanged.

Fixes algorithmicsuperintelligence#290
@codelion
codelion merged commit e6731a9 into algorithmicsuperintelligence:main Oct 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Logger prefix

2 participants