Skip to content
Snippets Groups Projects
Commit ef5d83ef authored by Faidon Liambotis's avatar Faidon Liambotis
Browse files

New upstream version 25.3.0

parent b84e7fb8
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@ ci:
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.10
rev: v0.11.7
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
......
......@@ -13,6 +13,14 @@ You can find our backwards-compatibility policy [here](https://github.com/hynek/
<!-- changelog follows -->
## [25.3.0](https://github.com/hynek/structlog/compare/25.2.0...25.3.0) - 2025-04-25
### Fixed
- `structlog.processors.TimeStamper` now again uses timestamps using UTC for custom format strings when `utc=True`.
[#713](https://github.com/hynek/structlog/pull/713)
## [25.2.0](https://github.com/hynek/structlog/compare/25.1.0...25.2.0) - 2025-03-11
### Added
......
Metadata-Version: 2.4
Name: structlog
Version: 25.2.0
Version: 25.3.0
Summary: Structured Logging for Python
Project-URL: Documentation, https://www.structlog.org/
Project-URL: Changelog, https://github.com/hynek/structlog/blob/main/CHANGELOG.md
......@@ -94,15 +94,15 @@ Especially those generously supporting us at the *The Organization* tier and hig
import pathlib, tomllib
for sponsor in tomllib.loads(pathlib.Path("pyproject.toml").read_text())["tool"]["sponcon"]["sponsors"]:
print(f'<a href="{sponsor["url"]}"><img title="{sponsor["title"]}" src="https://www.structlog.org/en/25.2.0/_static/sponsors/{sponsor["img"]}" width="190" /></a>')
print(f'<a href="{sponsor["url"]}"><img title="{sponsor["title"]}" src="https://www.structlog.org/en/25.3.0/_static/sponsors/{sponsor["img"]}" width="190" /></a>')
]]] -->
<a href="https://www.variomedia.de/"><img title="Variomedia AG" src="https://www.structlog.org/en/25.2.0/_static/sponsors/Variomedia.svg" width="190" /></a>
<a href="https://tidelift.com/?utm_source=lifter&utm_medium=referral&utm_campaign=hynek"><img title="Tidelift" src="https://www.structlog.org/en/25.2.0/_static/sponsors/Tidelift.svg" width="190" /></a>
<a href="https://klaviyo.com/"><img title="Klaviyo" src="https://www.structlog.org/en/25.2.0/_static/sponsors/Klaviyo.svg" width="190" /></a>
<a href="https://privacy-solutions.org/"><img title="Privacy Solutions" src="https://www.structlog.org/en/25.2.0/_static/sponsors/Privacy-Solutions.svg" width="190" /></a>
<a href="https://www.emsys-renewables.com/"><img title="emsys renewables" src="https://www.structlog.org/en/25.2.0/_static/sponsors/emsys-renewables.svg" width="190" /></a>
<a href="https://filepreviews.io/"><img title="FilePreviews" src="https://www.structlog.org/en/25.2.0/_static/sponsors/FilePreviews.svg" width="190" /></a>
<a href="https://polar.sh/"><img title="Polar" src="https://www.structlog.org/en/25.2.0/_static/sponsors/Polar.svg" width="190" /></a>
<a href="https://www.variomedia.de/"><img title="Variomedia AG" src="https://www.structlog.org/en/25.3.0/_static/sponsors/Variomedia.svg" width="190" /></a>
<a href="https://tidelift.com/?utm_source=lifter&utm_medium=referral&utm_campaign=hynek"><img title="Tidelift" src="https://www.structlog.org/en/25.3.0/_static/sponsors/Tidelift.svg" width="190" /></a>
<a href="https://klaviyo.com/"><img title="Klaviyo" src="https://www.structlog.org/en/25.3.0/_static/sponsors/Klaviyo.svg" width="190" /></a>
<a href="https://privacy-solutions.org/"><img title="Privacy Solutions" src="https://www.structlog.org/en/25.3.0/_static/sponsors/Privacy-Solutions.svg" width="190" /></a>
<a href="https://www.emsys-renewables.com/"><img title="emsys renewables" src="https://www.structlog.org/en/25.3.0/_static/sponsors/emsys-renewables.svg" width="190" /></a>
<a href="https://filepreviews.io/"><img title="FilePreviews" src="https://www.structlog.org/en/25.3.0/_static/sponsors/FilePreviews.svg" width="190" /></a>
<a href="https://polar.sh/"><img title="Polar" src="https://www.structlog.org/en/25.3.0/_static/sponsors/Polar.svg" width="190" /></a>
<!-- [[[end]]] -->
</p>
......@@ -138,28 +138,11 @@ Save time, reduce risk, and improve code health, while paying the maintainers of
## Release Information
### Added
- `structlog.tracebacks.Stack` now includes an `exc_notes` field reflecting the notes attached to the exception.
[#684](https://github.com/hynek/structlog/pull/684)
### Changed
- `structlog.stdlib.BoundLogger`'s binding-related methods now also return `Self`.
[#694](https://github.com/hynek/structlog/pull/694)
- `structlog.processors.TimeStamper` now produces internally timezone-aware `datetime` objects.
Default output hasn't changed, but you can now use `%z` in your *fmt* string.
[#709](https://github.com/hynek/structlog/pull/709)
### Fixed
- Expose `structlog.dev.RichTracebackFormatter` for imports.
[#699](https://github.com/hynek/structlog/pull/699)
- Expose `structlog.processors.LogfmtRenderer` for imports.
[#701](https://github.com/hynek/structlog/pull/701)
- `structlog.processors.TimeStamper` now again uses timestamps using UTC for custom format strings when `utc=True`.
[#713](https://github.com/hynek/structlog/pull/713)
---
......
......@@ -553,12 +553,18 @@ def _make_stamper(
return stamper_iso_local
def stamper_fmt(event_dict: EventDict) -> EventDict:
def stamper_fmt_local(event_dict: EventDict) -> EventDict:
event_dict[key] = now().astimezone().strftime(fmt)
return event_dict
def stamper_fmt_utc(event_dict: EventDict) -> EventDict:
event_dict[key] = now().strftime(fmt)
return event_dict
return stamper_fmt
if utc:
return stamper_fmt_utc
return stamper_fmt_local
class MaybeTimeStamper:
......
......@@ -414,6 +414,36 @@ class TestTimeStamper:
assert "1980" == d["timestamp"]
@freeze_time("1980-03-25 16:00:00")
def test_inserts_formatted_utc(self):
"""
The fmt string in UTC timezone works.
The exact hours calculated here maybe incorrect because of freezegun bugs:
https://github.com/spulec/freezegun/issues/348
https://github.com/spulec/freezegun/issues/494
"""
ts = TimeStamper(fmt="%Y-%m-%d %H:%M:%S %Z")
d = ts(None, None, {})
assert "1980-03-25 16:00:00 UTC" == d["timestamp"]
@freeze_time("1980-03-25 16:00:00")
def test_inserts_formatted_local(self):
"""
The fmt string in local timezone works.
The exact hours calculated here maybe incorrect because of freezegun bugs:
https://github.com/spulec/freezegun/issues/348
https://github.com/spulec/freezegun/issues/494
"""
local_tz = datetime.datetime.now().astimezone().tzname()
ts = TimeStamper(fmt="%Y-%m-%d %H:%M:%S %Z", utc=False)
d = ts(None, None, {})
assert f"1980-03-25 16:00:00 {local_tz}" == d["timestamp"]
@freeze_time("1980-03-25 16:00:00")
def test_tz_aware(self):
"""
......
......@@ -663,7 +663,7 @@ class TestExtraAdder:
handler.setLevel(0)
logger.addHandler(handler)
logger.setLevel(0)
logging.warning("allow = %s", allow)
logging.warning("allow = %s", allow) # noqa: LOG015
event_dict = {"event": "Some text"}
expected = self._copy_allowed(event_dict, extra_dict, allow)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment