mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 14:12:41 +00:00
feat: Updates setup-logger script to not require file argument, will default to /tmp/<label>.log
This commit is contained in:
32
env/.local/scripts/hypr/logging
vendored
32
env/.local/scripts/hypr/logging
vendored
@@ -120,12 +120,34 @@ logging() {
|
||||
}
|
||||
|
||||
setup-logging() {
|
||||
LOG_FILE+=("$1")
|
||||
LOG_INVOCATION_ID=${LOG_INVOCATION_ID:-$RANDOM}
|
||||
if [[ -n "$LOG_LABEL" ]]; then
|
||||
LOG_LABEL+=("${LOG_LABEL[@]}=>$2")
|
||||
label=""
|
||||
file=""
|
||||
|
||||
if [[ "${#@}" == "1" ]]; then
|
||||
file="/tmp/$1.log"
|
||||
label="$1"
|
||||
else
|
||||
LOG_LABEL+=("$2")
|
||||
file="$1"
|
||||
label="$2"
|
||||
fi
|
||||
|
||||
if [[ -z "$file" ]]; then
|
||||
echo -e "\e[31m[ERROR]:\e[0m Must supply a log file."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$label" ]]; then
|
||||
echo -e "\e[31m[ERROR]:\e[0m Must supply a logger label."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LOG_FILE+=("$file")
|
||||
LOG_INVOCATION_ID=${LOG_INVOCATION_ID:-$RANDOM}
|
||||
|
||||
if [[ -n "$LOG_LABEL" ]]; then
|
||||
LOG_LABEL+=("${LOG_LABEL[@]}=>$label")
|
||||
else
|
||||
LOG_LABEL+=("$label")
|
||||
fi
|
||||
export LOG_FILE
|
||||
export LOG_LABEL
|
||||
|
||||
Reference in New Issue
Block a user