2025-01-17 19:07:28 +08:00
|
|
|
#!/usr/bin/env bash
|
2024-11-24 21:13:37 +08:00
|
|
|
|
|
|
|
########################################################
|
|
|
|
# Logging functions
|
|
|
|
########################################################
|
|
|
|
|
|
|
|
# write some message $1 in log file and stdout with timestamp
|
|
|
|
log_path="/home/$USER/logs"
|
|
|
|
log() {
|
|
|
|
[ ! -d "$log_path" ] && log_path="./log"
|
|
|
|
[ ! -d "$log_path" ] && mkdir -p "$log_path"
|
|
|
|
echo -e "[$(date '+%H:%M:%S')] $*" | tee -a "$log_path/$(date '+%Y%m%d').log"
|
|
|
|
}
|