File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
_delphi_utils_python/delphi_utils Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -40,16 +40,12 @@ def get_structured_logger(name=__name__,
40
40
is a good choice.
41
41
filename: An (optional) file to write log output.
42
42
"""
43
- # Configure the underlying logging configuration
44
- handlers = [logging .StreamHandler ()]
45
- if filename :
46
- handlers .append (logging .FileHandler (filename ))
47
-
43
+ # Configure the basic underlying logging configuration
48
44
logging .basicConfig (
49
45
format = "%(message)s" ,
50
46
level = logging .INFO ,
51
- handlers = handlers
52
- )
47
+ handlers = [ logging . StreamHandler ()]
48
+ )
53
49
54
50
# Configure structlog. This uses many of the standard suggestions from
55
51
# the structlog documentation.
@@ -84,7 +80,12 @@ def get_structured_logger(name=__name__,
84
80
cache_logger_on_first_use = True ,
85
81
)
86
82
87
- logger = structlog .get_logger (name )
83
+ # Create the underlying python logger and wrap it with structlog
84
+ system_logger = logging .getLogger (name )
85
+ if filename :
86
+ system_logger .addHandler (logging .FileHandler (filename ))
87
+ system_logger .setLevel (logging .INFO )
88
+ logger = structlog .wrap_logger (system_logger )
88
89
89
90
if log_exceptions :
90
91
handle_exceptions (logger )
You can’t perform that action at this time.
0 commit comments