@@ -206,10 +206,21 @@ def set_screen_format(self, screen_format, *, screen_style=None):
206206 :param screen_format: format specification used when logging to the screen,
207207 as expected by the `logging.Formatter` constructor.
208208 Alternatively, aliases for common formats are available, see above.
209+ This format can also be overridden by the environment variable
210+ 'OVERRIDE_LAUNCH_SCREEN_FORMAT'.
209211 :param screen_style: the screen style used if no alias is used for
210212 screen_format.
211213 No style can be provided if a format alias is given.
212214 """
215+ # Check if the environment variable is set
216+ screen_format_env = os .environ .get ('OVERRIDE_LAUNCH_SCREEN_FORMAT' )
217+ # If the environment variable is set override the given format
218+ if screen_format_env not in [None , '' ]:
219+ # encoded escape characters correctly
220+ screen_format = screen_format_env .encode (
221+ 'latin1' ).decode ('unicode_escape' )
222+ # Set the style correspondingly
223+ screen_style = '{'
213224 if screen_format is not None :
214225 if screen_format == 'default' :
215226 screen_format = '[{levelname}] [{name}]: {msg}'
@@ -258,9 +269,20 @@ def set_log_format(self, log_format, *, log_style=None):
258269 as expected by the `logging.Formatter` constructor.
259270 Alternatively, the 'default' alias can be given to log verbosity level,
260271 logger name and logged message.
272+ This format can also be overridden by the environment variable
273+ 'OVERRIDE_LAUNCH_LOG_FORMAT'.
261274 :param log_style: the log style used if no alias is given for log_format.
262275 No style can be provided if a format alias is given.
263276 """
277+ # Check if the environment variable is set
278+ log_format_env = os .environ .get ('OVERRIDE_LAUNCH_LOG_FORMAT' )
279+ # If the environment variable is set override the given format
280+ if log_format_env not in [None , '' ]:
281+ # encoded escape characters correctly
282+ log_format = log_format_env .encode (
283+ 'latin1' ).decode ('unicode_escape' )
284+ # Set the style correspondingly
285+ log_style = '{'
264286 if log_format is not None :
265287 if log_format == 'default' :
266288 log_format = '{created:.7f} [{levelname}] [{name}]: {msg}'
@@ -489,7 +511,7 @@ def get_output_loggers(process_name, output_config):
489511
490512# Mypy does not support dynamic base classes, so workaround by typing the base
491513# class as Any
492- _Base = logging .getLoggerClass () # type: Any
514+ _Base : Any = logging .getLoggerClass ()
493515
494516
495517# Track all loggers to support module resets
0 commit comments