mirror of
https://github.com/itdoginfo/podkop.git
synced 2026-07-29 18:16:45 +03:00
refactor: Move logging functions to library file
This commit is contained in:
30
podkop/files/usr/lib/logging.sh
Normal file
30
podkop/files/usr/lib/logging.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
COLOR_CYAN="\033[0;36m"
|
||||
COLOR_GREEN="\033[0;32m"
|
||||
COLOR_RESET="\033[0m"
|
||||
|
||||
log() {
|
||||
local message="$1"
|
||||
local level="$2"
|
||||
|
||||
if [ "$level" == "" ]; then
|
||||
level="info"
|
||||
fi
|
||||
|
||||
logger -t "podkop" "[$level] $message"
|
||||
}
|
||||
|
||||
nolog() {
|
||||
local message="$1"
|
||||
local timestamp
|
||||
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
|
||||
|
||||
echo -e "${COLOR_CYAN}[$timestamp]${COLOR_RESET} ${COLOR_GREEN}$message${COLOR_RESET}"
|
||||
}
|
||||
|
||||
echolog() {
|
||||
local message="$1"
|
||||
local level="$2"
|
||||
|
||||
log "$message" "$level"
|
||||
nolog "$message"
|
||||
}
|
||||
Reference in New Issue
Block a user