Files
didactyl/view_api_call_logs.sh

28 lines
909 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
LOG_FILE="${1:-}"
if [ -z "$LOG_FILE" ]; then
for candidate in "./didactyl.log" "./debug.log" "./context.log.md"; do
if [ -f "$candidate" ]; then
LOG_FILE="$candidate"
break
fi
done
fi
if [ -z "$LOG_FILE" ] || [ ! -f "$LOG_FILE" ]; then
echo "Log file not found." >&2
echo "Tried defaults: ./didactyl.log ./debug.log ./context.log.md" >&2
echo "Usage: $0 [path/to/logfile]" >&2
exit 1
fi
echo "Following API call logs from: $LOG_FILE"
echo "(Press Ctrl+C to stop)"
# Show request/response failure lines related to outbound LLM HTTP calls.
# These are emitted by Didactyl in src/llm.c via fprintf(stderr, ...).
tail -n 0 -F "$LOG_FILE" \
| stdbuf -oL grep -E --line-buffered "\\[didactyl\\] llm request:|\\[didactyl\\] llm http request failed:|\\[didactyl\\] llm error response:|\\[didactyl\\] llm partial response:|\\[didactyl\\] llm hint:"