Skip to content

Conversation

@ultmaster
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings November 13, 2025 11:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the logging infrastructure by deprecating configure_logger() and introducing a more flexible logging setup API with setup() and setup_module() functions. The new API provides enhanced functionality including rich console formatting, per-submodule log levels, file handlers, and warning capture.

  • Introduces setup() function with comprehensive logging configuration options (console, color, file handlers, submodule levels, etc.)
  • Adds setup_module() for basic logger configuration with dictConfig
  • Deprecates configure_logger() (renamed to setup_logging()) with migration path to new API
  • Updates all example files and CLI tools to use the new setup_logging() function
  • Adds comprehensive test coverage for new logging functionality

Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
agentlightning/logging.py Core refactoring: adds setup() and setup_module() functions, deprecates old configure_logger() as setup_logging(), adds file handler support and helper utilities
agentlightning/init.py Updates exports to expose new logging functions through module API
tests/test_logging.py New comprehensive test suite covering all logging configuration scenarios including multiprocessing, file handlers, and rich formatting
tests/utils/test_server_launcher.py Removes deprecated configure_logger() import and call
examples/*/*.py Updates 13 example files to use setup_logging() instead of configure_logger()
agentlightning/cli/store.py Updates CLI store command to use setup_logging()
agentlightning/verl/daemon.py Updates VERL daemon to use setup_logging()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

from typing import Any, Dict, Optional

__all__ = ["configure_logger"]
__all__ = ["setup_logging"]
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The __all__ list only exports setup_logging (the deprecated function), but not the new setup and setup_module functions. This means these new functions won't be included when using from agentlightning.logging import *. Consider adding "setup" and "setup_module" to the __all__ list.

Suggested change
__all__ = ["setup_logging"]
__all__ = ["setup_logging", "setup", "setup_module"]
Copilot uses AI. Check for mistakes.
>>> setup(extra_handlers=[fh])
"""
# Ensure UTF-8 encoding on Windows consoles
# Note: This change does not fully represent support for execution under the windown system.
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "windown" should be "Windows".

Suggested change
# Note: This change does not fully represent support for execution under the windown system.
# Note: This change does not fully represent support for execution under the Windows system.
Copilot uses AI. Check for mistakes.
Comment on lines 319 to 348
if color is not False:
fmt_name = "rich"
if isinstance(color, dict):
rich_handler_config = color
else:
rich_handler_config: Dict[str, Any] = {
"rich_tracebacks": True,
"markup": False,
"show_time": True,
"show_path": True,
}
root_cfg["handlers"]["console"] = {
"class": "rich.logging.RichHandler",
"level": level,
**rich_handler_config,
}
# RichHandler manages its own style; keep formatter None
else:
fmt_name = "plain"
root_cfg["formatters"][fmt_name] = {
"format": DEFAULT_FORMAT,
"datefmt": DATE_FORMAT,
}

if console:
root_cfg["handlers"]["console"] = {
"class": "logging.StreamHandler",
"level": level,
"formatter": fmt_name,
}
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent behavior: When color=True and console=False, a RichHandler is still created (lines 319-334), but when color=False and console=False, no handler is created at all (lines 336-348). This asymmetry means the console parameter is only respected when color=False. Consider checking the console parameter in the color is not False branch as well, or documenting this behavior clearly.

Copilot uses AI. Check for mistakes.
logger.info("agent-lightning is ready!")
```
"""
warnings.warn("This function is deprecated in favor of `setup_logging`.", DeprecationWarning, stacklevel=2)
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deprecation warning message is incorrect. It states "This function is deprecated in favor of setup_logging" but the function itself is setup_logging. Based on the context, this should likely reference the new setup() function instead.

Suggested change
warnings.warn("This function is deprecated in favor of `setup_logging`.", DeprecationWarning, stacklevel=2)
warnings.warn("This function is deprecated in favor of `setup()`.", DeprecationWarning, stacklevel=2)
Copilot uses AI. Check for mistakes.
Comment on lines 23 to 25
!!! danger

This function is deprecated in favor of `[agentlightning.setup_logging][agentlightning.setup_logging]`.
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring states this function is deprecated in favor of [agentlightning.setup_logging][agentlightning.setup_logging], but the function itself is named setup_logging. This creates a circular reference. Based on the refactoring, this should likely reference setup() instead.

Copilot uses AI. Check for mistakes.
from .litagent import *
from .llm_proxy import *
from .logging import *
from .logging import setup as setup_logging # type: ignore
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 14 imports setup_logging with a comment indicating it's deprecated, but line 12 also exports __all__ = ["setup_logging"]. This is confusing because:

  1. Line 13 imports setup and aliases it as setup_logging
  2. Line 14 imports setup_logging (marked as deprecated)
  3. This creates a naming conflict where setup_logging refers to both the new setup function and the deprecated setup_logging function

The second import on line 14 will overwrite the alias from line 13. This appears to be a bug in the export logic.

Suggested change
from .logging import setup as setup_logging # type: ignore
# from .logging import setup as setup_logging # type: ignore
Copilot uses AI. Check for mistakes.

# Choose formatter / handler definition
if color is not False:
fmt_name = "rich"
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable fmt_name is not used.

Suggested change
fmt_name = "rich"
Copilot uses AI. Check for mistakes.
Runs in a separate process using spawn. It performs a specific logging
configuration scenario and returns a summary dict via the queue.
"""
import logging
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import of module logging is redundant, as it was previously imported on line 4.

Copilot uses AI. Check for mistakes.
Runs in a separate spawned process and configures logging with a single
files=str path. Returns information about the attached FileHandler.
"""
import logging
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import of module logging is redundant, as it was previously imported on line 4.

Suggested change
import logging
Copilot uses AI. Check for mistakes.
Runs in a separate spawned process and configures logging with a files=dict
mapping, then calls setup twice to verify idempotent FileHandler attachment.
"""
import logging
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import of module logging is redundant, as it was previously imported on line 4.

Suggested change
import logging
Copilot uses AI. Check for mistakes.
@ultmaster
Copy link
Contributor Author

/ci

@github-actions
Copy link

github-actions bot commented Nov 13, 2025

🚀 CI Watcher for correlation id-3527573709-mhxej3ss triggered by comment 3527573709
🏃‍♀️ Tracking 6 workflow run(s):

✅ All runs completed.

@ultmaster
Copy link
Contributor Author

/ci

@github-actions
Copy link

github-actions bot commented Nov 13, 2025

🚀 CI Watcher for correlation id-3527885453-mhxhceoc triggered by comment 3527885453
🏃‍♀️ Tracking 6 workflow run(s):

✅ All runs completed.

@ultmaster
Copy link
Contributor Author

/ci

@github-actions
Copy link

github-actions bot commented Nov 13, 2025

🚀 CI Watcher for correlation id-3527997190-mhxi70jp triggered by comment 3527997190
🏃‍♀️ Tracking 6 workflow run(s):

✅ All runs completed.

@ultmaster ultmaster merged commit eab691b into main Nov 13, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants