Created a class `BaseAgent`, from which all agents inherit. They get assigned a logger with a nice name (something like `control_backend.agents.AgentName`). The BDI core takes care of its own logger, as bdi is still a module. ref: N25B-241
19 lines
455 B
Python
19 lines
455 B
Python
import logging
|
|
|
|
from spade.agent import Agent
|
|
|
|
|
|
class BaseAgent(Agent):
|
|
"""
|
|
Base agent class for our agents to inherit from.
|
|
This ensures that all agents have a logger.
|
|
"""
|
|
|
|
logger: logging.Logger
|
|
|
|
# Whenever a subclass is initiated, give it the correct logger
|
|
def __init_subclass__(cls, **kwargs) -> None:
|
|
super().__init_subclass__(**kwargs)
|
|
|
|
cls.logger = logging.getLogger(__package__).getChild(cls.__name__)
|