Files
openclaw-backups/scripts/log-error.sh

51 lines
928 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
WS="/home/openclaw/.openclaw/workspace"
OUT="$WS/.learnings/ERRORS.md"
summary="${1:-Unspecified error}"
err_msg="${2:-No error text provided}"
context="${3:-No context provided}"
priority="${4:-medium}"
area="${5:-infra}"
stamp="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
date_id="$(date -u +"%Y%m%d")"
seq=$(grep -o "ERR-${date_id}-[0-9][0-9][0-9]" "$OUT" 2>/dev/null | tail -n1 | awk -F- '{print $3}' || true)
if [ -z "${seq:-}" ]; then seq=0; fi
seq=$(printf "%03d" $((10#$seq + 1)))
id="ERR-${date_id}-${seq}"
cat >> "$OUT" <<EOF
## [${id}] quick-log
**Logged**: ${stamp}
**Priority**: ${priority}
**Status**: pending
**Area**: ${area}
### Summary
${summary}
### Error
\`\`\`
${err_msg}
\`\`\`
### Context
${context}
### Suggested Fix
Triage and resolve; update this entry when fixed.
### Metadata
- Reproducible: unknown
- Related Files: n/a
---
EOF
echo "Logged ${id} to ${OUT}"