Skip to content

Removed logging about the toolbar failing to serialize a value into JSON #2181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 14, 2025
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: 0 additions & 4 deletions debug_toolbar/store.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import contextlib
import json
import logging
from collections import defaultdict, deque
from collections.abc import Iterable
from typing import Any
Expand All @@ -13,15 +12,12 @@
from debug_toolbar import settings as dt_settings
from debug_toolbar.models import HistoryEntry

logger = logging.getLogger(__name__)


class DebugToolbarJSONEncoder(DjangoJSONEncoder):
def default(self, o):
try:
return super().default(o)
except (TypeError, ValueError):
logger.debug("The debug toolbar can't serialize %s into JSON" % o)
return force_str(o)


Expand Down
1 change: 1 addition & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Pending
-------

* Added a note about the default password in ``make example``.
* Removed logging about the toolbar failing to serialize a value into JSON.

6.0.0 (2025-07-22)
------------------
Expand Down
6 changes: 6 additions & 0 deletions tests/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ def test_serialize(self):
'{"hello": {"foo": "bar"}}',
)

def test_serialize_logs_on_failure(self):
self.assertEqual(
store.serialize({"hello": {"foo": b"bar"}}),
'{"hello": {"foo": "bar"}}',
)

def test_deserialize(self):
self.assertEqual(
store.deserialize('{"hello": {"foo": "bar"}}'),
Expand Down
Loading