diff --git a/README.md b/README.md index 2d1b4f4..4383efa 100644 --- a/README.md +++ b/README.md @@ -86,3 +86,21 @@ The database is stored at `$XDG_DATA_HOME/local-wisper/transcripts.sqlite3`, or `~/.local/share/local-wisper/transcripts.sqlite3` when `XDG_DATA_HOME` is unset. Local Wisper restricts the directory to the current user, but the database contents are not encrypted. + +## Error logs + +The Sway wrapper appends errors and warnings to +`$XDG_STATE_HOME/local-wisper/sway.log`, defaulting to +`~/.local/state/local-wisper/sway.log`. It records the command, timestamp, and +nonzero exit status. This includes transcription failures, cleanup warnings, +and clipboard or typing failures. Transcript stdout is not added to this log. +Reinstall the wrapper after updating to enable logging. + +```bash +tail -n 100 ~/.local/state/local-wisper/sway.log +``` + +The model daemon also writes to `$XDG_CACHE_HOME/local-wisper/daemon.log`, +defaulting to `~/.cache/local-wisper/daemon.log`. +Direct CLI invocations print errors to stderr. Logs remain on this device and +are not automatically rotated. diff --git a/integrations/sway/local-wisper.sh b/integrations/sway/local-wisper.sh index 57431e6..81f4cb8 100755 --- a/integrations/sway/local-wisper.sh +++ b/integrations/sway/local-wisper.sh @@ -19,6 +19,15 @@ LW_POST_PROCESS_MODEL="${LW_POST_PROCESS_MODEL:-}" LW_POST_PROCESS_TIMEOUT="${LW_POST_PROCESS_TIMEOUT:-20}" LW_POST_PROCESS_GLOSSARY_FILE="${LW_POST_PROCESS_GLOSSARY_FILE:-}" +# Sway does not reliably retain stderr from shortcut commands. +LW_LOG_DIR="${XDG_STATE_HOME:-${HOME}/.local/state}/local-wisper" +if (umask 077; mkdir -p "${LW_LOG_DIR}" && touch "${LW_LOG_DIR}/sway.log"); then + exec 2>>"${LW_LOG_DIR}/sway.log" + printf '\n[%s] command=%s pid=%s\n' "$(date -Is)" "${1:-record}" "$$" >&2 +else + echo "local wisper: could not open persistent error log" >&2 +fi + if [[ -z "${LW_BIN}" ]]; then if command -v notify-send >/dev/null 2>&1; then notify-send "local wisper" "'lw' is not in PATH; install it from https://github.com/none23/local-wisper" @@ -63,4 +72,10 @@ case "${1:-}" in ;; esac -exec "${LW_BIN}" "${args[@]}" "$@" +if "${LW_BIN}" "${args[@]}" "$@"; then + exit 0 +else + status=$? + printf '[%s] command=%s pid=%s exited=%s\n' "$(date -Is)" "${1:-record}" "$$" "${status}" >&2 + exit "${status}" +fi