fix: fix: standardize logging across all agents — capture errors, log exit codes, consistent format (#367)
This commit is contained in:
parent
f686d47a98
commit
91f971fe53
10 changed files with 116 additions and 53 deletions
|
|
@ -23,9 +23,15 @@ LOGFILE="${DISINTO_LOG_DIR}/review/review-poll.log"
|
|||
MAX_REVIEWS=3
|
||||
REVIEW_IDLE_TIMEOUT=14400 # 4h: kill review session if idle
|
||||
|
||||
log() {
|
||||
printf '[%s] %s\n' "$(date -u '+%Y-%m-%d %H:%M:%S UTC')" "$*" >> "$LOGFILE"
|
||||
# Override LOG_AGENT for consistent agent identification
|
||||
LOG_AGENT="review"
|
||||
|
||||
# Override log() to append to review-specific log file
|
||||
_log() {
|
||||
log "$@" >> "$LOGFILE"
|
||||
}
|
||||
# shellcheck disable=SC2034
|
||||
log="$_log"
|
||||
|
||||
# Log rotation
|
||||
if [ -f "$LOGFILE" ]; then
|
||||
|
|
@ -126,10 +132,11 @@ if [ -n "$REVIEW_SIDS" ]; then
|
|||
|
||||
log " #${pr_num} re-review: new commits (${reviewed_sha:0:7}→${current_sha:0:7})"
|
||||
|
||||
if "${SCRIPT_DIR}/review-pr.sh" "$pr_num" 2>&1; then
|
||||
review_output=$("${SCRIPT_DIR}/review-pr.sh" "$pr_num" 2>&1) && review_rc=0 || review_rc=$?
|
||||
if [ "$review_rc" -eq 0 ]; then
|
||||
REVIEWED=$((REVIEWED + 1))
|
||||
else
|
||||
log " #${pr_num} re-review failed"
|
||||
log " #${pr_num} re-review failed (exit code $review_rc): $(echo "$review_output" | tail -3)"
|
||||
fi
|
||||
|
||||
[ "$REVIEWED" -lt "$MAX_REVIEWS" ] || break
|
||||
|
|
@ -180,10 +187,11 @@ while IFS= read -r line; do
|
|||
|
||||
log " #${PR_NUM} error check: ${ERROR_COMMENTS:-0} prior error(s) for ${PR_SHA:0:7}"
|
||||
|
||||
if "${SCRIPT_DIR}/review-pr.sh" "$PR_NUM" 2>&1; then
|
||||
review_output=$("${SCRIPT_DIR}/review-pr.sh" "$PR_NUM" 2>&1) && review_rc=0 || review_rc=$?
|
||||
if [ "$review_rc" -eq 0 ]; then
|
||||
REVIEWED=$((REVIEWED + 1))
|
||||
else
|
||||
log " #${PR_NUM} review failed"
|
||||
log " #${PR_NUM} review failed (exit code $review_rc): $(echo "$review_output" | tail -3)"
|
||||
fi
|
||||
|
||||
if [ "$REVIEWED" -ge "$MAX_REVIEWS" ]; then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue