HaochenGong commited on
Commit
bece3c1
·
1 Parent(s): fe8af47

complete log part

Browse files
Files changed (1) hide show
  1. app.py +4 -10
app.py CHANGED
@@ -92,9 +92,9 @@ if not os.path.exists(log_directory):
92
  os.makedirs(log_directory)
93
 
94
  # set log handler(Generate one log file per day and keep only the latest 7 files)
95
- # handler = CustomTimedRotatingFileHandler(log_file_path, when='midnight', interval=1, backupCount=5, utc=True)
96
- handler = CustomTimedRotatingFileHandler(log_file_path, when='s', interval=30, backupCount=5, utc=True)
97
- formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
98
  handler.setLevel(logging.INFO)
99
  handler.setFormatter(formatter)
100
 
@@ -112,7 +112,7 @@ def schedule_monitoring(interval_hours):
112
  """
113
  service = authenticate_gdrive()
114
  while True:
115
- time.sleep(interval_hours) # 等待指定小时数
116
 
117
  # 记录系统资源使用情况
118
  cpu_usage = psutil.cpu_percent(interval=1)
@@ -406,12 +406,6 @@ with demo:
406
  threading.Thread(target=schedule_restarts, args=(72,)).start() # restart per 72 hours
407
  threading.Thread(target=schedule_monitoring, args=(24,)).start() # monitor resources using per 24 hours
408
 
409
- def schedule_log_writing():
410
- while True:
411
- logger.info('Test log entry')
412
- time.sleep(10) # 每10秒写入一次日志
413
- threading.Thread(target=schedule_log_writing).start()
414
-
415
  try:
416
  demo.launch()
417
  logger.info('Gradio app launched successfully')
 
92
  os.makedirs(log_directory)
93
 
94
  # set log handler(Generate one log file per day and keep only the latest 7 files)
95
+ handler = CustomTimedRotatingFileHandler(log_file_path, when='midnight', interval=1, backupCount=5, utc=False)
96
+ formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
97
+ formatter.converter = time.localtime
98
  handler.setLevel(logging.INFO)
99
  handler.setFormatter(formatter)
100
 
 
112
  """
113
  service = authenticate_gdrive()
114
  while True:
115
+ time.sleep(interval_hours * 3600) # 等待指定小时数
116
 
117
  # 记录系统资源使用情况
118
  cpu_usage = psutil.cpu_percent(interval=1)
 
406
  threading.Thread(target=schedule_restarts, args=(72,)).start() # restart per 72 hours
407
  threading.Thread(target=schedule_monitoring, args=(24,)).start() # monitor resources using per 24 hours
408
 
 
 
 
 
 
 
409
  try:
410
  demo.launch()
411
  logger.info('Gradio app launched successfully')