Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [1.1.1] - 2025-11-20

- Fix InternalLogger to properly register with Python's logging hierarchy, enabling handler propagation from `logging.basicConfig()` and parent loggers [#18]

## [0.12.0] - 2025-04-14

- Add special case handling for context `prefab.current-time` to return the current time (UTC) to round out new operator support [#124]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sdk-reforge"
version = "1.1.0"
version = "1.1.1"
description = "Python sdk for Reforge Feature Flags and Config as a Service: https://www.reforge.com"
license = "MIT"
authors = ["Michael Berkowitz <michael.berkowitz@gmail.com>", "James Kebinger <james.kebinger@reforge.com>"]
Expand Down
2 changes: 1 addition & 1 deletion sdk_reforge/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
1.1.1
59 changes: 54 additions & 5 deletions sdk_reforge/_internal_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,58 @@ def __init__(self, name: str, level: int = logging.NOTSET) -> None:
super().__init__(name, level)
self.thread_local = threading.local()

def log(self, level: int, msg, *args, **kwargs) -> None:
# Register this logger with the logging manager so it can participate
# in the logger hierarchy and inherit handlers from parent loggers
logging.Logger.manager.loggerDict[name] = self

# Set up the parent logger in the hierarchy
# This is adapted from logging.Logger.manager._fixupParents
i = name.rfind(".")
rv = None
while (i > 0) and not rv:
substr = name[:i]
if substr not in logging.Logger.manager.loggerDict:
logging.Logger.manager.loggerDict[substr] = logging.PlaceHolder(self)
else:
obj = logging.Logger.manager.loggerDict[substr]
if isinstance(obj, logging.Logger):
rv = obj
else:
# It's a PlaceHolder
obj.append(self)
i = name.rfind(".", 0, i - 1)
if not rv:
rv = logging.root
self.parent = rv

def _log(
self,
level: int,
msg,
args,
exc_info=None,
extra=None,
stack_info=False,
stacklevel=1,
) -> None:
"""
Override _log to add prefab_internal to extra.
This is called by info(), debug(), warning(), error(), etc.
"""
if not ReentrancyCheck.is_set():
extras = kwargs.pop("extra", {})
extras["prefab_internal"] = True
# Pass the possibly-modified 'extra' dictionary to the underlying logger
super().log(level, msg, *args, extra=extras, **kwargs)
if extra is None:
extra = {}
else:
# Make a copy to avoid modifying the caller's dict
extra = extra.copy()
extra["prefab_internal"] = True

super()._log(
level,
msg,
args,
exc_info=exc_info,
extra=extra,
stack_info=stack_info,
stacklevel=stacklevel,
)
Loading