Skip to content

Conversation

@patridunk
Copy link

@patridunk patridunk commented Dec 22, 2025

This module provides a utility function to create a configured logger for Polymarket Agents components, enhancing logging capabilities. Introduces a shared get_logger helper to provide consistent logging across Polymarket Agent modules.


Note

Adds a minimal logging utility for consistent agent logs.

  • New agents/logging_utils.py exposes get_logger(name) returning an INFO-level logger with a stream handler and concise formatter "%(asctime)s | %(levelname)s | %(name)s | %(message)s"
  • Reuses existing logger if handlers are already attached to avoid duplicates; defaults to logger name polymarket-agents

Written by Cursor Bugbot for commit 16fc0a2. This will update automatically on new commits. Configure here.

This module provides a utility function to create a configured logger for Polymarket Agents components, enhancing logging capabilities.
Introduces a shared get_logger helper to provide consistent logging across Polymarket Agent modules.
datefmt="%Y-%m-%d %H:%M:%S",
)
handler.setFormatter(formatter)
logger.addHandler(handler)
Copy link

Choose a reason for hiding this comment

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

Race condition may cause duplicate log handlers

When multiple threads call get_logger() concurrently with the same logger name, there's a race condition between checking if logger.handlers: and calling logger.addHandler(handler). Multiple threads could pass the check simultaneously before any handler is added, causing each to add its own handler. This results in duplicate handlers and duplicate log messages being emitted. A threading lock around the check-and-add sequence would prevent this.

Fix in Cursor Fix in Web

if logger.handlers:
return logger

logger.setLevel(logging.INFO)
Copy link

Choose a reason for hiding this comment

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

Log level not set on early return path

When the logger already has handlers (from external configuration or previous calls), the function returns early without setting logger.setLevel(logging.INFO). This means if the logger was previously configured with a different level like WARNING or ERROR, the returned logger won't have the INFO level that get_logger is expected to configure. The level setting occurs after the early return check, so it's skipped when handlers already exist.

Fix in Cursor Fix in Web

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.

1 participant