Skip to content

Commit 8c8c5e6

Browse files
committed
Added symlinks for latest log files.
1 parent 3b2b74f commit 8c8c5e6

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

simpledaemonlog/logsetup.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,15 @@ def setup_file(application_name, logdir="log", level=logging.NOTSET, fs=DEFAULT_
5959
ts = time.strftime("%Y%m%d_%H%M%S%Z", utc)
6060

6161
logfilename = "log_{}_{}.txt".format(application_name, ts)
62-
logfile = logging.FileHandler(os.path.join(logdir, logfilename))
62+
loglatest = "log_{}_latest.txt".format(application_name)
63+
logfilepath = os.path.join(logdir, logfilename)
64+
loglinkpath = os.path.join(logdir, loglatest)
65+
logfile = logging.FileHandler(logfilepath)
66+
67+
if os.path.islink(loglinkpath):
68+
os.unlink(loglinkpath)
69+
70+
os.symlink(logfilepath, loglinkpath)
6371

6472
formatter = logging.Formatter(fs)
6573
logfile.setFormatter(formatter)

0 commit comments

Comments
 (0)