@@ -44,7 +44,7 @@ def threading_exception_handler(args):
44
44
threading .excepthook = threading_exception_handler
45
45
46
46
47
- def get_structured_logger (name = __name__ , filename = None , log_exceptions = True ):
47
+ def get_structured_logger (name = __name__ , filename = None , log_exceptions = True , is_real = True ):
48
48
"""Create a new structlog logger.
49
49
50
50
Use the logger returned from this in indicator code using the standard
@@ -63,6 +63,9 @@ def get_structured_logger(name=__name__, filename=None, log_exceptions=True):
63
63
name: Name to use for logger (included in log lines), __name__ from caller
64
64
is a good choice.
65
65
filename: An (optional) file to write log output.
66
+ log_exceptions: should we log exceptions?
67
+ is_real: is this logger *not* in a testing environment? Used to avoid
68
+ setting features that interfere with testing the logging output
66
69
"""
67
70
# Set the underlying logging configuration
68
71
if "LOG_DEBUG" in os .environ :
@@ -109,7 +112,7 @@ def add_pid(_logger, _method_name, event_dict):
109
112
# Use a standard wrapper class for utilities like log.warning()
110
113
wrapper_class = structlog .stdlib .BoundLogger ,
111
114
# Cache the logger
112
- cache_logger_on_first_use = True ,
115
+ cache_logger_on_first_use = is_real ,
113
116
)
114
117
115
118
# Create the underlying python logger and wrap it with structlog
0 commit comments