Files
agent-framework/python/agent_framework/_logging.py
T
Eduard van Valkenburg 7cc29fe192 Python: package setup with logger (#125)
* package setup with logger

* set config once

* add unit test workflow

* updated naming of workflows

* add mypy check

* renamed job

* smaller name

* ignore certain files for ruff

* remove assignment

* fix ruff config

* removed pyright from pre-commit

* fixed logging test

* fix mypy setup

* mypy fix

* mypy

* mypy
2025-07-02 15:17:28 +00:00

25 lines
731 B
Python

# Copyright (c) Microsoft. All rights reserved.
import logging
from .exceptions import AgentFrameworkException
logging.basicConfig(
format="[%(asctime)s - %(pathname)s:%(lineno)d - %(levelname)s] %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
def get_logger(name: str = "agent_framework") -> logging.Logger:
"""Get a logger with the specified name, defaulting to 'agent_framework'.
Args:
name (str): The name of the logger. Defaults to 'agent_framework'.
Returns:
logging.Logger: The configured logger instance.
"""
if not name.startswith("agent_framework"):
raise AgentFrameworkException("Logger name must start with 'agent_framework'.")
return logging.getLogger(name)