Skip to content
This repository was archived by the owner on Nov 29, 2025. It is now read-only.
This repository was archived by the owner on Nov 29, 2025. It is now read-only.

Standardize logging across the project #80

@konradsemsch

Description

@konradsemsch

Context

We currently have inconsistent logging patterns across the codebase:

  • Some modules use logging.getLogger(name) which creates long, unreadable logger names
  • HITL components use both standard logging AND a separate log_hitl() function, creating duplicate logs
  • The hitl_logger.py file creates a separate debug log that could be handled by standard log levels
  • No centralized way to configure or initialize loggers consistently

This makes logs harder to read, manage and filter. We need to standardize on a single approach.

Proposed Approach

Create a logger factory that uses component-based naming (e.g., HITL.FeedbackManager instead of
src.modules.handlers.hitl.feedback_manager) to balance readability with the ability to filter logs by component.

Acceptance Criteria

  1. Logger Factory Created
  • New file src/modules/config/logger_factory.py exists
  • Exports a get_logger(component_name: str) function that returns a configured logger
  • Logger includes formatting with: component name, timestamp, log level, thread info
  • Function integrates with the existing TeeOutput system from environment.py
  • Supports configuring log levels per component (e.g., set HITL to DEBUG, others to INFO)
  • Log files should continue to be cyber_operations.log
  1. Environment Configuration Updated
  • environment.py imports and uses the logger factory
  • setup_logging() function initializes the logger factory configuration
  • Ensure the logger factory works with the existing setup_logging() initialization
  • TeeOutput system remains unchanged (it works well)
  1. Other changes
  • HITL modules migrated to the new setup
  • all other modules standardized - replace logging.getLogger(name) with get_logger("Component.Subcomponent") and use consistent component naming (e.g. Agents.* for agent modules and Tools.* for tool modules etc)

Documentation & Validation

  • Logging standards documented (either in README or comments in logger_factory.py)
  • Explains when to use DEBUG vs INFO vs WARNING levels
  • Shows example of how to use get_logger() in new modules

Component Naming Convention

Use hierarchical component names:

  • CyberAutoAgent - Main application
  • HITL.FeedbackManager, HITL.FeedbackHandler, etc.
  • Evaluation.Manager, Evaluation.TraceParser, etc.
  • Tools.Memory, Tools.ReportBuilder, etc.
  • Agents.CyberAutoAgent, Agents.ReportAgent, etc.
  • Config.Manager, Config.Environment, etc.
  • Handlers.ReactBridge, Handlers.ReportGenerator, etc.

Example Usage

Old pattern (inconsistent)

logger = logging.getLogger(name) # Creates "src.modules.handlers.hitl.feedback_manager"
log_hitl("FeedbackManager", "Processing feedback", "DEBUG")

New pattern (standardized)

from src.modules.config.logger_factory import get_logger

logger = get_logger("HITL.FeedbackManager")
logger.debug("Processing feedback", extra={"context_key": "value"})
logger.info("Feedback accepted")

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions