Bläddra i källkod

add error log

ming 3 år sedan
förälder
incheckning
4c2c003fbd
1 ändrade filer med 6 tillägg och 2 borttagningar
  1. 6 2
      api/main.py

+ 6 - 2
api/main.py

@@ -29,6 +29,8 @@ from fastapi.staticfiles import StaticFiles
 import shutil
 import io
 from first import first
+import traceback
+import logging
 #test
 
 app = FastAPI()
@@ -256,7 +258,8 @@ def gen_video_queue(name_hash,name,text_content, image_urls,avatar):
             my_answer = remote_svc.call_video(top1['name_hash'],top1['name'],top1['text_content'].split(','), top1['image_urls'].split(','),top1['avatar']) # method call
             shutil.copy(tmp_video_dir+top1['name_hash']+'.mp4',video_dest+top1['name_hash']+'.mp4')
             os.remove(tmp_video_dir+top1['name_hash']+'.mp4')
-        except:
+        except Exception as e:
+            logging.error(traceback.format_exc())
             print('video generation error')
             notify_group('影片錯誤')
         db['video_queue'].delete(id=top1['id'])
@@ -294,7 +297,8 @@ def gen_video_queue_eng(name_hash,name,text_content, image_urls,sub_titles,avata
             my_answer = remote_svc.call_video_eng(top1['name_hash'],top1['name'],top1['text_content'].split(',%'), top1['image_urls'].split(','),top1['subtitles'].split(',%'),top1['avatar']) # method call
             shutil.copy(tmp_video_dir+top1['name_hash']+'.mp4',video_dest+top1['name_hash']+'.mp4')
             os.remove(tmp_video_dir+top1['name_hash']+'.mp4')
-        except:
+        except Exception as e:
+            logging.error(traceback.format_exc())
             print('video generation error')
             notify_group('影片錯誤')
         db['video_queue'].delete(id=top1['id'])