mirror of
https://github.com/acedanger/shell.git
synced 2026-03-25 00:51:50 -07:00
feat: Improve logging functions in backup scripts for better readability and structured output
This commit is contained in:
@@ -170,35 +170,35 @@ log_message() {
|
||||
local message="$1"
|
||||
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
echo -e "${CYAN}[${timestamp}]${NC} ${message}"
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $message" >> "${LOG_FILE}" 2>/dev/null || true
|
||||
echo "[${timestamp}] $message" >> "${LOG_FILE}" 2>/dev/null || true
|
||||
}
|
||||
|
||||
log_error() {
|
||||
local message="$1"
|
||||
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
echo -e "${RED}[${timestamp}] ERROR:${NC} ${message}" >&2
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ERROR: $message" >> "${LOG_FILE}" 2>/dev/null || true
|
||||
echo "[${timestamp}] ERROR: $message" >> "${LOG_FILE}" 2>/dev/null || true
|
||||
}
|
||||
|
||||
log_success() {
|
||||
local message="$1"
|
||||
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
echo -e "${GREEN}[${timestamp}] SUCCESS:${NC} ${message}"
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] SUCCESS: $message" >> "${LOG_FILE}" 2>/dev/null || true
|
||||
echo "[${timestamp}] SUCCESS: $message" >> "${LOG_FILE}" 2>/dev/null || true
|
||||
}
|
||||
|
||||
log_warning() {
|
||||
local message="$1"
|
||||
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
echo -e "${YELLOW}[${timestamp}] WARNING:${NC} ${message}"
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] WARNING: $message" >> "${LOG_FILE}" 2>/dev/null || true
|
||||
echo "[${timestamp}] WARNING: $message" >> "${LOG_FILE}" 2>/dev/null || true
|
||||
}
|
||||
|
||||
log_info() {
|
||||
local message="$1"
|
||||
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
echo -e "${BLUE}[${timestamp}] INFO:${NC} ${message}"
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] INFO: $message" >> "${LOG_FILE}" 2>/dev/null || true
|
||||
echo "[${timestamp}] INFO: $message" >> "${LOG_FILE}" 2>/dev/null || true
|
||||
}
|
||||
|
||||
# Performance tracking functions
|
||||
|
||||
Reference in New Issue
Block a user