@@ -113,6 +113,7 @@ def reset(self):
113
113
self .screen_formatter = None
114
114
self .file_formatter = None
115
115
self ._log_handler_factory = None
116
+ self ._log_file_name = 'launch.log'
116
117
logging .root .setLevel (logging .INFO )
117
118
self .set_screen_format ('default' )
118
119
self .set_log_format ('default' )
@@ -130,6 +131,20 @@ def level(self, new_level):
130
131
"""
131
132
logging .root .setLevel (new_level )
132
133
134
+ @property
135
+ def log_file_name (self ) -> str :
136
+ """Get the current log file name."""
137
+ return self ._log_file_name
138
+
139
+ @log_file_name .setter
140
+ def log_file_name (self , log_file_name : str ):
141
+ """
142
+ Set the name of the log file.
143
+
144
+ :param log_file_name: the name of the log file where logger output should be written.
145
+ """
146
+ self ._log_file_name = log_file_name
147
+
133
148
@property
134
149
def log_dir (self ):
135
150
"""Get the current log directory, generating it if necessary."""
@@ -341,13 +356,13 @@ def log_launch_config(*, logger=logging.root):
341
356
)))
342
357
343
358
344
- def get_logger (name = None ) -> logging .Logger :
359
+ def get_logger (name = None , main_log_file_name = 'launch.log' ) -> logging .Logger :
345
360
"""Get named logger, configured to output to screen and launch main log file."""
346
361
logger = logging .getLogger (name )
347
362
screen_handler = launch_config .get_screen_handler ()
348
363
if screen_handler not in logger .handlers :
349
364
logger .addHandler (screen_handler )
350
- launch_log_file_handler = launch_config .get_log_file_handler ()
365
+ launch_log_file_handler = launch_config .get_log_file_handler (main_log_file_name )
351
366
if launch_log_file_handler not in logger .handlers :
352
367
logger .addHandler (launch_log_file_handler )
353
368
return logger
@@ -416,7 +431,7 @@ def _normalize_output_configuration(config):
416
431
return normalized_config
417
432
418
433
419
- def get_output_loggers (process_name , output_config ):
434
+ def get_output_loggers (process_name , output_config , main_log_file_name = "launch.log" ):
420
435
"""
421
436
Get the stdout and stderr output loggers for the given process name.
422
437
@@ -476,7 +491,7 @@ def get_output_loggers(process_name, output_config):
476
491
# If a 'log' output is configured for this source or for
477
492
# 'both' sources, this logger should output to launch main log file.
478
493
if 'log' in (output_config ['both' ] | output_config [source ]):
479
- launch_log_file_handler = launch_config .get_log_file_handler ()
494
+ launch_log_file_handler = launch_config .get_log_file_handler (main_log_file_name )
480
495
# Add launch main log file handler if necessary.
481
496
if launch_log_file_handler not in logger .handlers :
482
497
launch_log_file_handler .setFormatterFor (
0 commit comments