Skip to content

Commit

Permalink
fix: fix format exceptions in utils.logging_debug (#514)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Chris Rossi authored Aug 20, 2020
1 parent 4e46327 commit d38c0a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion google/cloud/ndb/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ def logging_debug(log, message, *args, **kwargs):
**kwargs)`, otherwise this is a no-op.
"""
if DEBUG:
log.debug(str(message).format(*args, **kwargs))
message = str(message)
if args or kwargs:
message = message.format(*args, **kwargs)
log.debug(message)


class keyword_only(object):
Expand Down
3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from google.cloud.ndb import _eventloop
from google.cloud.ndb import global_cache as global_cache_module
from google.cloud.ndb import model
from google.cloud.ndb import utils

import pytest

Expand All @@ -34,6 +35,8 @@
except ImportError:
import mock

utils.DEBUG = True


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

0 comments on commit d38c0a3

Please sign in to comment.