mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-18 20:17:09 +08:00
fix(desktop): run bundled backend from writable data dir
This commit is contained in:
@@ -33,15 +33,28 @@ def _reset_logger(log):
|
||||
datefmt="%Y-%m-%d %H:%M:%S",
|
||||
)
|
||||
)
|
||||
file_handle = logging.FileHandler(_log_path(), encoding="utf-8")
|
||||
file_handle.setFormatter(
|
||||
logging.Formatter(
|
||||
"[%(levelname)s][%(asctime)s][%(filename)s:%(lineno)d] - %(message)s",
|
||||
datefmt="%Y-%m-%d %H:%M:%S",
|
||||
)
|
||||
)
|
||||
log.addHandler(file_handle)
|
||||
log.addHandler(console_handle)
|
||||
# File logging is best-effort: if the log path isn't writable (e.g. a
|
||||
# packaged app installed under Program Files run by a non-admin user, with
|
||||
# an unwritable CWD), fall back to console-only instead of crashing the
|
||||
# whole process at import time.
|
||||
try:
|
||||
file_handle = logging.FileHandler(_log_path(), encoding="utf-8")
|
||||
file_handle.setFormatter(
|
||||
logging.Formatter(
|
||||
"[%(levelname)s][%(asctime)s][%(filename)s:%(lineno)d] - %(message)s",
|
||||
datefmt="%Y-%m-%d %H:%M:%S",
|
||||
)
|
||||
)
|
||||
log.addHandler(file_handle)
|
||||
except OSError:
|
||||
console_handle.handle(
|
||||
logging.LogRecord(
|
||||
"log", logging.WARNING, __file__, 0,
|
||||
"[log] file logging disabled (log path not writable): %s",
|
||||
(_log_path(),), None,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def _get_logger():
|
||||
|
||||
Reference in New Issue
Block a user