mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Thanks Akshesh Doshi for the initial patch and Tim Graham for the review
This commit is contained in:
@@ -99,7 +99,7 @@ class BaseDatabaseSchemaEditor(object):
|
||||
Executes the given SQL statement, with optional parameters.
|
||||
"""
|
||||
# Log the command we're running, then run it
|
||||
logger.debug("%s; (params %r)", sql, params)
|
||||
logger.debug("%s; (params %r)", sql, params, extra={'params': params, 'sql': sql})
|
||||
if self.collect_sql:
|
||||
ending = "" if sql.endswith(";") else ";"
|
||||
if params is not None:
|
||||
|
||||
@@ -502,7 +502,7 @@ class ignore_warnings(TestContextDecorator):
|
||||
|
||||
|
||||
@contextmanager
|
||||
def patch_logger(logger_name, log_level):
|
||||
def patch_logger(logger_name, log_level, log_kwargs=False):
|
||||
"""
|
||||
Context manager that takes a named logger and the logging level
|
||||
and provides a simple mock-like list of messages received
|
||||
@@ -510,7 +510,8 @@ def patch_logger(logger_name, log_level):
|
||||
calls = []
|
||||
|
||||
def replacement(msg, *args, **kwargs):
|
||||
calls.append(msg % args)
|
||||
call = msg % args
|
||||
calls.append((call, kwargs) if log_kwargs else call)
|
||||
logger = logging.getLogger(logger_name)
|
||||
orig = getattr(logger, log_level)
|
||||
setattr(logger, log_level, replacement)
|
||||
|
||||
Reference in New Issue
Block a user