mirror of
https://github.com/YuleBest/LuminPro.git
synced 2026-12-04 00:54:42 +08:00
feat(log): 日志等级
This commit is contained in:
1 parent
ae42b7f0f2
commit
66ff3a6429
9 files changed
+74
-7
No files matched your search
@@ -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"
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user