File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -277,21 +277,22 @@ def ensure_utf8_stream(stream):
277277 sys .stdout , sys .stderr = (ensure_utf8_stream (s ) for s in (sys .stdout , sys .stderr ))
278278 np_set_string_function (repr_array )
279279
280- # basicConfig is only called to make sure there is at least one handler for the root logger.
281- # All the output level setting is down right afterwards.
282- logging .basicConfig ()
280+ root = logging .getLogger ()
281+ if not root .handlers :
282+ # basicConfig is only called to make sure there is at least one handler for the root logger.
283+ # All the output level setting is down right afterwards.
284+ logging .basicConfig ()
283285 logging .captureWarnings (capture = True )
284286 for key , val in os .environ .items ():
285287 if key .startswith ("flog_" ):
286288 domain = key [len ("flog_" ) :]
287289 logging .getLogger (domain ).setLevel (logging ._nameToLevel .get (val , level ))
288- root = logging .getLogger ()
289290 root .setLevel (level )
290291
291292 if not structured :
292293 handler = root .handlers [0 ]
293294 # pytest injects DontReadFromInput which does not have "closed"
294- if not getattr (sys .stdin , "closed" , False ) and sys .stdout .isatty ():
295+ if handler . formatter is None and not getattr (sys .stdin , "closed" , False ) and sys .stdout .isatty ():
295296 handler .setFormatter (AwesomeFormatter ())
296297 else :
297298 handler = StructuredHandler (level , level_from_msg )
You can’t perform that action at this time.
0 commit comments