@@ -197,7 +197,7 @@ def __init__(
197197 self .local = threading .local ()
198198 self .level_from_msg = level_from_msg if level_from_msg is not None else lambda _ : None
199199
200- def emit (self , record : logging .LogRecord ):
200+ def emit (self , record : logging .LogRecord ): # noqa: PLR0912
201201 """Print the log record formatted as JSON to stdout."""
202202 created = datetime .datetime .fromtimestamp (record .created , timezone )
203203 msg = self .format (record )
@@ -234,7 +234,7 @@ def emit(self, record: logging.LogRecord):
234234 obj ["context" ] = self .local .context
235235 except AttributeError :
236236 pass
237- print (json .dumps (obj , sort_keys = True ), file = sys .stdout , flush = True )
237+ print (json .dumps (obj , sort_keys = True ), file = sys .stdout , flush = True ) # noqa: T201
238238
239239 def flush (self ):
240240 """Write all pending text to stdout."""
@@ -279,8 +279,8 @@ def ensure_utf8_stream(stream):
279279
280280 root = logging .getLogger ()
281281 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.
282+ # basicConfig is only called to make sure there is at least one handler for
283+ # the root logger. All the output level setting is down right afterwards.
284284 logging .basicConfig ()
285285 logging .captureWarnings (capture = True )
286286 for key , val in os .environ .items ():
@@ -292,7 +292,11 @@ def ensure_utf8_stream(stream):
292292 if not structured :
293293 handler = root .handlers [0 ]
294294 # pytest injects DontReadFromInput which does not have "closed"
295- if handler .formatter is None and not getattr (sys .stdin , "closed" , False ) and sys .stdout .isatty ():
295+ if (
296+ handler .formatter is None
297+ and not getattr (sys .stdin , "closed" , False )
298+ and sys .stdout .isatty ()
299+ ):
296300 handler .setFormatter (AwesomeFormatter ())
297301 else :
298302 handler = StructuredHandler (level , level_from_msg )
0 commit comments