55config .read (configdir )
66
77log = []
8+ logidr = None
89def writeonlog (thingtowrite , * otherthingstowrite ):
910 global log
11+ global logdir
1012 thingtowrite = time .strftime ("%H:%M:%S" ) + "@" + thingtowrite
1113 try :
1214 thingtowrite += " | " + str (otherthingstowrite )
1315 except :
1416 pass
1517 log .append (thingtowrite + "\n " )
16- #if len(log) > 15:
17- # savelog()
18-
1918
2019def savelog ():
2120 global log
@@ -24,13 +23,21 @@ def savelog():
2423 log = []
2524
2625def createlogfile ():
27- if not os .path .exists ("logfiles/" ):
28- os .makedirs ("logfiles/" )
29- nlogfiles = int (len (os .listdir ("logfiles/" )))
26+ if config .get ("DIRS" , "logdir" ) == "Default" :
27+ if not os .path .exists ("logfiles/" ):
28+ try :
29+ os .makedirs ("logfiles/" )
30+ logdir = "logfiles/"
31+ except :
32+ logdir = "~/.invproy/logfiles/"
33+ if not os .path .exists (logdir )
34+ try :
35+ os .makedirs (logdir )
36+ else :
37+ logdir = config .get ("DIRS" , "logdir" )
38+
39+ nlogfiles = int (len (os .listdir (logdir )))
3040 if nlogfiles >= int (config .get ("DIRS" , "Maxlogs" )):
31- #print(nlogfiles)
32- #print(int(config.get("DIRS", "Maxlogs")) - nlogfiles)
33- #for i in range(abs(nlogfiles - int(config.get("DIRS", "Maxlogs")))):
3441 while nlogfiles > int (config .get ("DIRS" , "Maxlogs" )):
3542 #Aqui pones que borre el archivo mas viejo
3643 nlogfiles -= 1
@@ -42,7 +49,7 @@ def createlogfile():
4249 except :
4350 raise
4451 try :
45- newlogfilename = "logfiles/" + time .strftime ("%y%m%d%H%M%S" ) + " " + config .get ("DIRS" , "Log" )
52+ newlogfilename = logdir + time .strftime ("%y%m%d%H%M%S" ) + " " + config .get ("DIRS" , "Log" )
4653 try :
4754 os .rename ("Log.log" , newlogfilename )
4855 except :
0 commit comments