feat(log): 日志等级

This commit is contained in:
YuleBest committed 2026-04-10 08:23:55 +08:00
1 parent ae42b7f0f2
commit 66ff3a6429
9 files changed
+74 -7

No files matched your search

+7
View File
@@ -36,6 +36,13 @@ get_config_hash() {
_log() {
local level="${2:-INFO}"
local ll
ll="$(get_cfg log_level "info")"
case "$ll" in
off) return ;;
error) case "$level" in ERROR) ;; *) return ;; esac ;;
warn) case "$level" in ERROR | WARN) ;; *) return ;; esac ;;
esac
printf '[%s] [%s] [%s] %s\n' "$(date '+%m-%d %H:%M:%S')" "daemon" "$level" "$1" >>"$log_file"
}
+7
View File
@@ -22,6 +22,7 @@ get_cfg() {
}
now_bri_file="$(get_cfg now_bri_file "$DEFAULT_NOW_BRI_FILE")"
log_level="$(get_cfg log_level "info")"
_log() {
local level="${2:-INFO}"
@@ -31,6 +32,12 @@ _log() {
*) if [ -f "$stop_file" ]; then return; fi ;;
esac
case "$log_level" in
off) return ;;
error) case "$level" in ERROR) ;; *) return ;; esac ;;
warn) case "$level" in ERROR | WARN) ;; *) return ;; esac ;;
esac
local max_size
max_size="$(get_cfg log_max_size 500)"
if [ -f "$log_file" ]; then