Skip to content

Commit c04f317

Browse files
update get_log_file_path for backward compatibility
Signed-off-by: Tanishq Chaudhary <[email protected]>
1 parent 30879b6 commit c04f317

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

launch/launch/logging/__init__.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,14 @@ def set_log_format(self, log_format, *, log_style=None):
315315
else:
316316
self.file_formatter = None
317317

318-
def get_log_file_path(self):
318+
def get_log_file_path(self, log_file_name='launch.log'):
319319
"""
320320
Get the absolute path to the given log file.
321321
322+
:param log_file_name: name of the file for which we want full path
322323
:return: the absolute path to the log file.
323324
"""
324-
return os.path.join(self.log_dir, self.log_file_name)
325+
return os.path.join(self.log_dir, log_file_name)
325326

326327
def get_log_file_handler(self):
327328
"""
@@ -335,7 +336,8 @@ def get_log_file_handler(self):
335336
"""
336337
if self.log_file_name not in self.file_handlers:
337338
factory = self.log_handler_factory
338-
file_handler = factory(self.get_log_file_path(), encoding='utf-8')
339+
file_handler = factory(
340+
self.get_log_file_path(self.log_file_name), encoding='utf-8')
339341
file_handler.setFormatter(self.file_formatter)
340342
self.file_handlers[self.log_file_name] = file_handler
341343
return self.file_handlers[self.log_file_name]

launch/test/launch/test_logging.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ def test_output_loggers_configuration(
131131
assert 0 == len(capture.err)
132132

133133
launch.logging.launch_config.log_file_name = main_log_file_name
134-
main_log_path = launch.logging.launch_config.get_log_file_path()
134+
main_log_path = launch.logging.launch_config.get_log_file_path(
135+
launch.logging.launch_config.log_file_name)
135136
assert os.path.exists(main_log_path)
136137
assert 0 != os.stat(main_log_path).st_size
137138
with open(main_log_path, 'r') as f:
@@ -145,7 +146,8 @@ def test_output_loggers_configuration(
145146
assert 0 == len(lines)
146147

147148
launch.logging.launch_config.log_file_name = 'some-proc-stdout.log'
148-
own_log_path = launch.logging.launch_config.get_log_file_path()
149+
own_log_path = launch.logging.launch_config.get_log_file_path(
150+
launch.logging.launch_config.log_file_name)
149151
if 'own_log' in (checks['stdout'] | checks['both']):
150152
assert os.path.exists(own_log_path)
151153
assert 0 != os.stat(own_log_path).st_size
@@ -157,7 +159,8 @@ def test_output_loggers_configuration(
157159
assert (not os.path.exists(own_log_path) or 0 == os.stat(own_log_path).st_size)
158160

159161
launch.logging.launch_config.log_file_name = 'some-proc-stderr.log'
160-
own_log_path = launch.logging.launch_config.get_log_file_path()
162+
own_log_path = launch.logging.launch_config.get_log_file_path(
163+
launch.logging.launch_config.log_file_name)
161164
if 'own_log' in (checks['stderr'] | checks['both']):
162165
assert os.path.exists(own_log_path)
163166
assert 0 != os.stat(own_log_path).st_size
@@ -169,7 +172,8 @@ def test_output_loggers_configuration(
169172
assert (not os.path.exists(own_log_path) or 0 == os.stat(own_log_path).st_size)
170173

171174
launch.logging.launch_config.log_file_name = 'some-proc.log'
172-
own_log_path = launch.logging.launch_config.get_log_file_path()
175+
own_log_path = launch.logging.launch_config.get_log_file_path(
176+
launch.logging.launch_config.log_file_name)
173177
if 'own_log' in checks['both']:
174178
assert os.path.exists(own_log_path)
175179
assert 0 != os.stat(own_log_path).st_size

0 commit comments

Comments
 (0)