Fix log directory handling
This commit is contained in:
parent
b7b4678183
commit
7ccb031845
@ -3,7 +3,7 @@ serverIP: 127.0.0.1
|
||||
timeout: 5
|
||||
retry: 5
|
||||
maxTime: 6000
|
||||
logdir: "./logs"
|
||||
logdir: "/tmp"
|
||||
maxLogDays: 15
|
||||
sqlUser: "root"
|
||||
sqlPass: "password"
|
||||
|
@ -1041,14 +1041,27 @@ def log(conf, message):
|
||||
logdir = conf["logdir"]
|
||||
now = datetime.today()
|
||||
|
||||
fname = str(now.day) + "-" + str(now.month) \
|
||||
+ "-" + str(now.year) + ".log"
|
||||
fname = ( "molteniron-"
|
||||
+ str(now.day)
|
||||
+ "-"
|
||||
+ str(now.month)
|
||||
+ "-"
|
||||
+ str(now.year)
|
||||
+ ".log"
|
||||
)
|
||||
|
||||
timestamp = "{0:0>2}".format(str(now.hour)) + ":" + \
|
||||
"{0:0>2}".format(str(now.minute)) \
|
||||
+ ":" + "{0:0>2}".format(str(now.second))
|
||||
timestamp = ( "{0:0>2}".format(str(now.hour))
|
||||
+ ":"
|
||||
+ "{0:0>2}".format(str(now.minute))
|
||||
+ ":"
|
||||
+ "{0:0>2}".format(str(now.second))
|
||||
)
|
||||
|
||||
message = timestamp + " " + message + "\n"
|
||||
message = ( timestamp
|
||||
+ " "
|
||||
+ message
|
||||
+ "\n"
|
||||
)
|
||||
|
||||
# check if logdir exists, if not create it
|
||||
if not os.path.isdir(logdir):
|
||||
@ -1068,6 +1081,8 @@ def cleanLogs(conf):
|
||||
now = datetime.today()
|
||||
logs = os.popen("ls " + logdir).read().split("\n")
|
||||
for log in logs:
|
||||
if not log.startswith("molteniron-"):
|
||||
continue
|
||||
elements = log[:-1 * len(".log")].split("-")
|
||||
if len(elements) != 3:
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user