Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
f424399
Outline of changes
rodrigobr-msft Nov 6, 2025
c44287a
Adding logging configuration handling when loading configuration
rodrigobr-msft Nov 11, 2025
7712b93
name to level mapping fix for Python 3.10
rodrigobr-msft Nov 11, 2025
44c0731
Code feedback changes
rodrigobr-msft Nov 11, 2025
44386b4
Merge branch 'main' into users/robrandao/logging-with-config
rodrigobr-msft Nov 12, 2025
dccf8ae
Update libraries/microsoft-agents-activity/microsoft_agents/activity/…
rodrigobr-msft Nov 13, 2025
6a4ac08
Small changes
rodrigobr-msft Nov 13, 2025
ca011cf
Merge branch 'main' of https://github.com/microsoft/Agents-for-python…
rodrigobr-msft Nov 13, 2025
8bb10c5
Update libraries/microsoft-agents-activity/microsoft_agents/activity/…
rodrigobr-msft Nov 13, 2025
9a322bc
Merge branch 'main' into users/robrandao/logging-with-config
rodrigobr-msft Nov 13, 2025
9b810ac
Merge branch 'main' into users/robrandao/logging-with-config
rodrigobr-msft Nov 25, 2025
0f860d8
Creating ConfigurationErrorResources for microsoft-agents-activity
rodrigobr-msft Nov 25, 2025
0d26e9c
Merge branch 'main' of https://github.com/microsoft/Agents-for-python…
rodrigobr-msft Nov 25, 2025
f35009f
Pulling from remote
rodrigobr-msft Nov 25, 2025
b78948f
Merge branch 'users/robrandao/logging-with-config' of https://github.…
rodrigobr-msft Nov 25, 2025
50eca2a
Merge branch 'main' into users/robrandao/logging-with-config
rodrigobr-msft Dec 1, 2025
c1b5224
Merge branch 'main' into users/robrandao/logging-with-config
rodrigobr-msft Dec 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@

from .channel_adapter_protocol import ChannelAdapterProtocol
from .turn_context_protocol import TurnContextProtocol
from ._load_configuration import load_configuration_from_env
from .config import load_configuration_from_env

__all__ = [
"AgentsModel",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

from ._load_configuration import load_configuration_from_env

__all__ = [
"load_configuration_from_env",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

import logging

from ..errors import configuration_errors

# in Python 3.11, we can move to using
# logging.getLevelNamesMapping()
_NAME_TO_LEVEL = {
"CRITICAL": logging.CRITICAL,
"FATAL": logging.FATAL,
"ERROR": logging.ERROR,
"WARN": logging.WARNING,
"WARNING": logging.WARNING,
"INFO": logging.INFO,
"INFORMATION": logging.INFO, # .NET parity
"DEBUG": logging.DEBUG,
"NOTSET": logging.NOTSET,
}


def _configure_logging(logging_config: dict):
"""Configures logging based on the provided logging configuration dictionary.

:param logging_config: A dictionary containing logging configuration.
:raises ValueError: If an invalid log level is provided in the configuration.
"""

log_levels = logging_config.get("LOGLEVEL", {})

console_handler = logging.StreamHandler()
console_handler.setFormatter(
logging.Formatter(
"%(asctime)s - %(name)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)"
)
)

for key in log_levels:
level_name = log_levels[key].upper()
level = _NAME_TO_LEVEL.get(level_name)
if level is None:
raise ValueError(
configuration_errors.InvalidLoggingConfiguration.format(key, level_name)
)

namespace = key.lower()
if namespace == "default":
logger = logging.getLogger()
else:
logger = logging.getLogger(namespace)

logger.handlers.clear() # Remove existing handlers to prevent duplicates
logger.addHandler(console_handler)
logger.setLevel(level)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from typing import Any

from ._configure_logging import _configure_logging


def load_configuration_from_env(env_vars: dict[str, Any]) -> dict:
"""
Expand All @@ -26,6 +28,8 @@ def load_configuration_from_env(env_vars: dict[str, Any]) -> dict:
conn for conn in result.get("CONNECTIONSMAP", {}).values()
]

_configure_logging(result.get("LOGGING", {}))

return {
"AGENTAPPLICATION": result.get("AGENTAPPLICATION", {}),
"CONNECTIONS": result.get("CONNECTIONS", {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@
"""

from .error_message import ErrorMessage
from .error_resources import ActivityErrorResources
from .error_resources import ActivityErrorResources, ConfigurationErrorResources

# Singleton instance
activity_errors = ActivityErrorResources()
configuration_errors = ConfigurationErrorResources()

__all__ = ["ErrorMessage", "ActivityErrorResources", "activity_errors"]
__all__ = [
"ErrorMessage",
"ActivityErrorResources",
"ConfigurationErrorResources",
"activity_errors",
"configuration_errors",
]
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,16 @@ class ActivityErrorResources:
def __init__(self):
"""Initialize ActivityErrorResources."""
pass


class ConfigurationErrorResources:
"""
Error messages for environment configuration operations.

Error codes are organized in the range -66000 to -66999.
"""

InvalidLoggingConfiguration = ErrorMessage(
"Invalid logging level configured: {0} = {1}",
-66011,
)