Skip to content
This repository was archived by the owner on May 6, 2026. It is now read-only.

Commit d38c0a3

Browse files
author
Chris Rossi
authored
fix: fix format exceptions in utils.logging_debug (#514)
Changes introduced in #508 caused debug logging to break. The bug is fixed and debug logging is now turned on during testing, so we can catch regressions.
1 parent 4e46327 commit d38c0a3

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

google/cloud/ndb/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ def logging_debug(log, message, *args, **kwargs):
8484
**kwargs)`, otherwise this is a no-op.
8585
"""
8686
if DEBUG:
87-
log.debug(str(message).format(*args, **kwargs))
87+
message = str(message)
88+
if args or kwargs:
89+
message = message.format(*args, **kwargs)
90+
log.debug(message)
8891

8992

9093
class keyword_only(object):

tests/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from google.cloud.ndb import _eventloop
2626
from google.cloud.ndb import global_cache as global_cache_module
2727
from google.cloud.ndb import model
28+
from google.cloud.ndb import utils
2829

2930
import pytest
3031

@@ -34,6 +35,8 @@
3435
except ImportError:
3536
import mock
3637

38+
utils.DEBUG = True
39+
3740

3841
class TestingEventLoop(_eventloop.EventLoop):
3942
def call_soon(self, callback, *args, **kwargs):

0 commit comments

Comments
 (0)