From d8d1cc520be4dea60ac2ce2494c62c054e43b16a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Fri, 6 Aug 2021 11:22:54 +0200 Subject: [PATCH] paths: Allow customizing log file extension MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the file contents is JSON, it would be nice to have matching extension. Signed-off-by: Lubomír Sedlář --- pungi/paths.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pungi/paths.py b/pungi/paths.py index 2916a577..6049b667 100644 --- a/pungi/paths.py +++ b/pungi/paths.py @@ -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) )