paths: Allow customizing log file extension

If the file contents is JSON, it would be nice to have matching
extension.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2021-08-06 11:22:54 +02:00
parent 904a1c3271
commit d8d1cc520b
1 changed files with 3 additions and 2 deletions

View File

@ -113,12 +113,13 @@ class LogPaths(object):
makedirs(path)
return path
def log_file(self, arch, log_name, create_dir=True):
def log_file(self, arch, log_name, create_dir=True, ext=None):
ext = ext or "log"
arch = arch or "global"
if log_name.endswith(".log"):
log_name = log_name[:-4]
return os.path.join(
self.topdir(arch, create_dir=create_dir), "%s.%s.log" % (log_name, arch)
self.topdir(arch, create_dir=create_dir), "%s.%s.%s" % (log_name, arch, ext)
)