支持在设置页面下载日志
This commit is contained in:
parent
03e3312218
commit
d6df2f6bfe
@ -79,7 +79,7 @@ class Config:
|
|||||||
use_music_api: bool = (
|
use_music_api: bool = (
|
||||||
os.getenv("XIAOMUSIC_USE_MUSIC_API", "false").lower() == "true"
|
os.getenv("XIAOMUSIC_USE_MUSIC_API", "false").lower() == "true"
|
||||||
)
|
)
|
||||||
log_file: str = os.getenv("XIAOMUSIC_MUSIC_LOG_FILE", "/tmp/tmp1/tmp2/xiaomusic.log")
|
log_file: str = os.getenv("XIAOMUSIC_MUSIC_LOG_FILE", "/tmp/xiaomusic.txt")
|
||||||
|
|
||||||
def append_keyword(self, keys, action):
|
def append_keyword(self, keys, action):
|
||||||
for key in keys.split(","):
|
for key in keys.split(","):
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import os
|
import os
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from flask import Flask, request, send_from_directory
|
from flask import Flask, request, send_from_directory, send_file
|
||||||
from flask_httpauth import HTTPBasicAuth
|
from flask_httpauth import HTTPBasicAuth
|
||||||
from waitress import serve
|
from waitress import serve
|
||||||
|
|
||||||
@ -162,6 +162,10 @@ def downloadjson():
|
|||||||
"content": content,
|
"content": content,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@app.route("/downloadlog", methods=["GET"])
|
||||||
|
@auth.login_required
|
||||||
|
def downloadlog():
|
||||||
|
return send_file(xiaomusic.config.log_file, as_attachment=True)
|
||||||
|
|
||||||
def static_path_handler(filename):
|
def static_path_handler(filename):
|
||||||
log.debug(filename)
|
log.debug(filename)
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<a href="/static/m3u.html" target="_blank">m3u文件转换工具</a>
|
<a href="/static/m3u.html" target="_blank">m3u文件转换工具</a>
|
||||||
|
<a href="/downloadlog" download="xiaomusic.txt">下载日志文件</a>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<p>Powered by <a href="https://github.com/hanxi/xiaomusic" target="_blank">xiaomusic</a></p>
|
<p>Powered by <a href="https://github.com/hanxi/xiaomusic" target="_blank">xiaomusic</a></p>
|
||||||
|
@ -117,13 +117,15 @@ class XiaoMusic:
|
|||||||
os.makedirs(log_path)
|
os.makedirs(log_path)
|
||||||
if os.path.exists(log_file):
|
if os.path.exists(log_file):
|
||||||
os.remove(log_file)
|
os.remove(log_file)
|
||||||
handler = RotatingFileHandler(self.config.log_file, maxBytes=1024*1024, backupCount=0)
|
handler = RotatingFileHandler(self.config.log_file, maxBytes=10*1024*1024, backupCount=1)
|
||||||
self.log = logging.getLogger("xiaomusic")
|
self.log = logging.getLogger("xiaomusic")
|
||||||
self.log.addHandler(handler)
|
self.log.addHandler(handler)
|
||||||
self.log.setLevel(logging.DEBUG if self.config.verbose else logging.INFO)
|
self.log.setLevel(logging.DEBUG if self.config.verbose else logging.INFO)
|
||||||
debug_config = copy.deepcopy(self.config)
|
debug_config = copy.deepcopy(self.config)
|
||||||
debug_config.account = '******'
|
debug_config.account = '******'
|
||||||
debug_config.password = '******'
|
debug_config.password = '******'
|
||||||
|
debug_config.httpauth_username = '******'
|
||||||
|
debug_config.httpauth_password = '******'
|
||||||
self.log.info(debug_config)
|
self.log.info(debug_config)
|
||||||
|
|
||||||
async def poll_latest_ask(self):
|
async def poll_latest_ask(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user