Ver Fonte

fix: 修复日志写文件的错误

SongZihuan há 3 anos atrás
pai
commit
0b1064eaab
1 ficheiros alterados com 5 adições e 6 exclusões
  1. 5 6
      view/base.py

+ 5 - 6
view/base.py

@@ -31,12 +31,11 @@ class App:
         self.mail = Mail(self._app)
 
         self._app.logger.setLevel(conf["log-level"])
-        if conf["log-home"] is None:
-            if conf["log-home"]:
-                handle = logging.handlers.TimedRotatingFileHandler(
-                    os.path.join(conf["log-home"], f"flask-{os.getpid()}.log"))
-                handle.setFormatter(logging.Formatter(conf["log-format"]))
-                self._app.logger.addHandler(handle)
+        if conf["log-home"] is not None:
+            handle = logging.handlers.TimedRotatingFileHandler(
+                os.path.join(conf["log-home"], f"flask-{os.getpid()}.log"))
+            handle.setFormatter(logging.Formatter(conf["log-format"]))
+            self._app.logger.addHandler(handle)
         else:
             handle = logging.StreamHandler(sys.stderr)
             handle.setFormatter(logging.Formatter(conf["log-format"]))