-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.sh
More file actions
31 lines (25 loc) · 770 Bytes
/
utils.sh
File metadata and controls
31 lines (25 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
LOG_FILE="$KANSO_REPO/kanso.log"
log() {
local level="${1:-INFO}"
local message="$2"
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
case "$level" in
"ERROR") gum log --structured --level error "$message" ;;
"WARN") gum log --structured --level warn "$message" ;;
"SUCCESS")
printf "%s " "$(gum style --foreground '#00FF7F' --bold 'SUCCESS' | tr -d '\n')"
echo "$message"
;;
"INFO") gum log --structured --level info "$message" ;;
*) gum log --structured --level info "$message" ;;
esac
echo "[$timestamp] [LOG] [$level] $message" >>"$LOG_FILE"
}
silent_log() {
mkdir -p "$(dirname "$LOG_FILE")"
"$@" >>"$LOG_FILE" 2>&1
}
command_exists() {
command -v "$1" >/dev/null 2>&1
}