feat: Integrates logging into scripts that need it.

This commit is contained in:
2025-10-05 16:35:19 -04:00
parent f729bedc99
commit dccb1ca0a3
11 changed files with 185 additions and 137 deletions

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env bash
THIS=$(basename ${BASH_SOURCE[0]})
THIS_FILE=${BASH_SOURCE[0]}
THIS=$(basename $THIS_FILE)
usage() {
cat <<EOF
@@ -27,7 +28,6 @@ launch_flag="0"
rows=()
invocation_id=${RANDOM}
LOG_FILE=${LOG_FILE:-/tmp/$THIS.log}
XDG_CONFIG_HOME=${XDG_CONFIG_HOME}
SCRIPTS=${SCRIPTS}
@@ -42,15 +42,9 @@ while [[ $# -gt 0 ]]; do
done
log() {
echo "[$invocation_id]:[$($SCRIPTS/isosec)]:[$THIS]: $1" >>$LOG_FILE
logging log --source "$THIS_FILE" "$@"
}
if [[ -z $XDG_CONFIG_HOME ]]; then
log "XDG_CONFIG_HOME not set"
log "using ~/.config"
XDG_CONFIG_HOME=$HOME/.config
fi
launch() {
ghostty --class=$window_class --window-padding-x=$window_padding_x \
--keybind="ctrl+c=quit" \
@@ -81,6 +75,16 @@ generate_rows() {
# MAIN
################################################################################
# Setup logging file and label.
source "$SCRIPTS/hypr/logging"
setup-logging "/tmp/$THIS.log" "$THIS"
if [[ -z $XDG_CONFIG_HOME ]]; then
log "XDG_CONFIG_HOME not set"
log "using ~/.config"
XDG_CONFIG_HOME=$HOME/.config
fi
if [[ -z $config_file ]]; then
log "No config file set."
log "Using ~/.config/utils-launcher/config.json"