29 lines
857 B
Bash
Executable File
29 lines
857 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Export recent online errors into a git-trackable NDJSON feed.
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
OUT_FILE="${ROOT_DIR}/docs/support/online-runtime-errors.ndjson"
|
|
TMP_FILE="${OUT_FILE}.tmp"
|
|
|
|
mkdir -p "$(dirname "$OUT_FILE")"
|
|
: > "$TMP_FILE"
|
|
|
|
append_tail() {
|
|
local src="$1"
|
|
local lines="$2"
|
|
if [[ -f "$src" ]]; then
|
|
tail -n "$lines" "$src" >> "$TMP_FILE" || true
|
|
fi
|
|
}
|
|
|
|
append_tail "${ROOT_DIR}/storage/logs/runtime-errors.ndjson" 300
|
|
append_tail "${ROOT_DIR}/storage/logs/support-events.ndjson" 300
|
|
|
|
if [[ ! -s "$TMP_FILE" ]]; then
|
|
echo '{"timestamp":"'"$(date -Iseconds)"'","type":"info","message":"Nessun errore disponibile da esportare","context":"export script","source":"online-export"}' > "$TMP_FILE"
|
|
fi
|
|
|
|
mv "$TMP_FILE" "$OUT_FILE"
|
|
echo "Export completato: ${OUT_FILE}"
|