24 lines
526 B
Bash
24 lines
526 B
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
# log.sh - Logging utilities for homelab deployment
|
||
|
|
|
||
|
|
log() {
|
||
|
|
local level=$1
|
||
|
|
shift
|
||
|
|
local message=$*
|
||
|
|
echo "[$(date +'%Y-%m-%d %H:%M:%S')] [$level] $message"
|
||
|
|
}
|
||
|
|
|
||
|
|
# Structured log for machine reading
|
||
|
|
# timestamp, stage, host, service, command_result, info
|
||
|
|
struct_log() {
|
||
|
|
local stage=$1
|
||
|
|
local host=$2
|
||
|
|
local service=$3
|
||
|
|
local result=$4
|
||
|
|
local info=$5
|
||
|
|
log "STRUCT" "stage=$stage host=$host service=$service result=$result info=\"$info\""
|
||
|
|
}
|
||
|
|
|
||
|
|
export -f log
|
||
|
|
export -f struct_log
|