Added FileRotate parameter (defaults to 1 also if not set in ini)
This parameter controls the name of the logfile to be able to to log-rotation with system logrotate in linux to get rid of the timestamped files and get a much more smaller footprint in the log-directory
This commit is contained in:
parent
36c6368436
commit
f5340c019d
|
@ -287,6 +287,11 @@ def ReadConfig(f,p):
|
||||||
id = 0
|
id = 0
|
||||||
log_path = config['Log']['FilePath']
|
log_path = config['Log']['FilePath']
|
||||||
log_name = config['Log']['FileRoot']
|
log_name = config['Log']['FileRoot']
|
||||||
|
try:
|
||||||
|
file_rotate = config['Log']['FileRotate']
|
||||||
|
except:
|
||||||
|
file_rotate = "1" # to keep file-rotation by default with timestamp
|
||||||
|
|
||||||
try:
|
try:
|
||||||
port = int(config['Network']['Port'])
|
port = int(config['Network']['Port'])
|
||||||
except:
|
except:
|
||||||
|
@ -311,6 +316,7 @@ def ReadConfig(f,p):
|
||||||
p.append(port) # 5
|
p.append(port) # 5
|
||||||
p.append(file_blacklist) # 6
|
p.append(file_blacklist) # 6
|
||||||
p.append(t_reload_blacklist) # 7
|
p.append(t_reload_blacklist) # 7
|
||||||
|
p.append(file_rotate) # 8
|
||||||
|
|
||||||
|
|
||||||
def RunServer(config):
|
def RunServer(config):
|
||||||
|
@ -500,7 +506,11 @@ def RunServer(config):
|
||||||
def printlog(mess):
|
def printlog(mess):
|
||||||
global filelog
|
global filelog
|
||||||
global log_basename
|
global log_basename
|
||||||
|
global file_rotate
|
||||||
|
if file_rotate == "1":
|
||||||
log_file = log_basename + '-' + str(datetime.utcnow().strftime('%Y-%m-%d')) + '.log'
|
log_file = log_basename + '-' + str(datetime.utcnow().strftime('%Y-%m-%d')) + '.log'
|
||||||
|
else:
|
||||||
|
log_file = log_basename + '.log'
|
||||||
try:
|
try:
|
||||||
if not os.path.isfile(log_file):
|
if not os.path.isfile(log_file):
|
||||||
filelog.flush()
|
filelog.flush()
|
||||||
|
@ -538,8 +548,12 @@ except:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
log_basename = config[3] + '/' + config[4]
|
log_basename = config[3] + '/' + config[4]
|
||||||
|
file_rotate = config[8]
|
||||||
### log
|
### log
|
||||||
|
if file_rotate == "1":
|
||||||
log_file = log_basename + '-' + str(datetime.utcnow().strftime('%Y-%m-%d')) + '.log'
|
log_file = log_basename + '-' + str(datetime.utcnow().strftime('%Y-%m-%d')) + '.log'
|
||||||
|
else:
|
||||||
|
log_file = log_basename + '.log'
|
||||||
try:
|
try:
|
||||||
if os.path.isfile(log_file):
|
if os.path.isfile(log_file):
|
||||||
filelog = open(log_file,'a')
|
filelog = open(log_file,'a')
|
||||||
|
|
|
@ -17,6 +17,8 @@ DisplayLevel=1
|
||||||
FileLevel=1
|
FileLevel=1
|
||||||
FilePath=/var/log
|
FilePath=/var/log
|
||||||
FileRoot=YSFReflector
|
FileRoot=YSFReflector
|
||||||
|
# Set this to 0 and configure systems logrotate to do the job with a single log file
|
||||||
|
FileRotate=1
|
||||||
|
|
||||||
[Network]
|
[Network]
|
||||||
Port=42395
|
Port=42395
|
||||||
|
|
Loading…
Reference in New Issue