feat(脚本): 优化查看日志功能

pull/534/merge
mack-a 2021-04-18 14:37:04 +08:00
parent d03ffe705b
commit e6874c98d2
1 changed files with 25 additions and 16 deletions

View File

@ -2681,14 +2681,24 @@ checkLog() {
if [[ -z ${configPath} ]]; then if [[ -z ${configPath} ]]; then
echoContent red " ---> 没有检测到安装目录,请执行脚本安装内容" echoContent red " ---> 没有检测到安装目录,请执行脚本安装内容"
fi fi
local logStatus=false
if [[ -n $(cat ${configPath}00_log.json|grep access) ]];then
logStatus=true
fi
echoContent skyBlue "\n功能 $1/${totalProgress} : 查看日志" echoContent skyBlue "\n功能 $1/${totalProgress} : 查看日志"
echoContent red "\n==============================================================" echoContent red "\n=============================================================="
echoContent yellow "# 建议仅调试打开access日志\n" echoContent yellow "# 建议仅调试打开access日志\n"
if [[ "${logStatus}" == "false" ]];then
echoContent yellow "1.打开access日志" echoContent yellow "1.打开access日志"
echoContent yellow "2.关闭access日志" else
echoContent yellow "3.监听access日志" echoContent yellow "1.关闭access日志"
echoContent yellow "4.监听error日志" fi
echoContent yellow "5.清空日志"
echoContent yellow "2.监听access日志"
echoContent yellow "3.监听error日志"
echoContent yellow "4.清空日志"
echoContent red "==============================================================" echoContent red "=============================================================="
read -r -p "请选择:" selectAccessLogType read -r -p "请选择:" selectAccessLogType
@ -2696,6 +2706,7 @@ checkLog() {
case ${selectAccessLogType} in case ${selectAccessLogType} in
1) 1)
if [[ "${logStatus}" == "false" ]];then
cat <<EOF >${configPath}00_log.json cat <<EOF >${configPath}00_log.json
{ {
"log": { "log": {
@ -2704,12 +2715,8 @@ checkLog() {
"loglevel": "warning" "loglevel": "warning"
} }
} }
EOF EOF
reloadCore elif [[ "${logStatus}" == "true" ]];then
checkLog 1
;;
2)
cat <<EOF >${configPath}00_log.json cat <<EOF >${configPath}00_log.json
{ {
"log": { "log": {
@ -2718,15 +2725,17 @@ EOF
} }
} }
EOF EOF
fi
reloadCore reloadCore
checkLog 1
;; ;;
3) 2)
tail -f ${configPathLog}access.log tail -f ${configPathLog}access.log
;; ;;
4) 3)
tail -f ${configPathLog}error.log tail -f ${configPathLog}error.log
;; ;;
5) 4)
echo >${configPathLog}access.log echo >${configPathLog}access.log
echo >${configPathLog}error.log echo >${configPathLog}error.log
;; ;;
@ -3602,7 +3611,7 @@ menu() {
cd "$HOME" || exit cd "$HOME" || exit
echoContent red "\n==============================================================" echoContent red "\n=============================================================="
echoContent green "作者mack-a" echoContent green "作者mack-a"
echoContent green "当前版本v2.4.14" echoContent green "当前版本v2.4.15"
echoContent green "Githubhttps://github.com/mack-a/v2ray-agent" echoContent green "Githubhttps://github.com/mack-a/v2ray-agent"
echoContent green "描述:七合一共存脚本\c" echoContent green "描述:七合一共存脚本\c"
showInstallStatus showInstallStatus