Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .agents/scripts/supervisor-archived/_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,32 @@ db() {

#######################################
# Structured logging functions
# All output to stderr with color-coded prefixes
# All output to stderr with color-coded prefixes.
# Uses printf to safely handle arbitrary message content (avoids echo -e
# interpreting backslash sequences in $* and word-splitting on unquoted args).
#######################################
log_info() {
echo -e "${BLUE}[SUPERVISOR]${NC} $*" >&2
printf "%b %s\n" "${BLUE}[SUPERVISOR]${NC}" "$*" >&2
return 0
Comment on lines +36 to 37
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved robustness, consider adding || true to the printf command. This prevents the script from exiting on a logging failure (e.g., a broken pipe on stderr) when set -e is active. This change also makes the explicit return 0 redundant, as the command will always succeed.

Suggested change
printf "%b %s\n" "${BLUE}[SUPERVISOR]${NC}" "$*" >&2
return 0
printf "%b %s\n" "${BLUE}[SUPERVISOR]${NC}" "$*" >&2 || true
References
  1. When set -e is active, using || true for non-critical commands like logging prevents the script from exiting prematurely on minor failures (e.g., broken pipe), ensuring robustness.

}

log_success() {
echo -e "${GREEN}[SUPERVISOR]${NC} $*" >&2
printf "%b %s\n" "${GREEN}[SUPERVISOR]${NC}" "$*" >&2
return 0
Comment on lines +41 to 42
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency and robustness, consider adding || true here as well. This prevents script termination on logging failures and makes the return 0 redundant.

Suggested change
printf "%b %s\n" "${GREEN}[SUPERVISOR]${NC}" "$*" >&2
return 0
printf "%b %s\n" "${GREEN}[SUPERVISOR]${NC}" "$*" >&2 || true
References
  1. When set -e is active, using || true for non-critical commands like logging prevents the script from exiting prematurely on minor failures (e.g., broken pipe), ensuring robustness.

}

log_warn() {
echo -e "${YELLOW}[SUPERVISOR]${NC} $*" >&2
printf "%b %s\n" "${YELLOW}[SUPERVISOR]${NC}" "$*" >&2
return 0
Comment on lines +46 to 47
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency and robustness, consider adding || true here as well. This prevents script termination on logging failures and makes the return 0 redundant.

Suggested change
printf "%b %s\n" "${YELLOW}[SUPERVISOR]${NC}" "$*" >&2
return 0
printf "%b %s\n" "${YELLOW}[SUPERVISOR]${NC}" "$*" >&2 || true
References
  1. When set -e is active, using || true for non-critical commands like logging prevents the script from exiting prematurely on minor failures (e.g., broken pipe), ensuring robustness.

}

log_error() {
echo -e "${RED}[SUPERVISOR]${NC} $*" >&2
printf "%b %s\n" "${RED}[SUPERVISOR]${NC}" "$*" >&2
return 0
Comment on lines +51 to 52
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency and robustness, consider adding || true here as well. This prevents script termination on logging failures and makes the return 0 redundant.

Suggested change
printf "%b %s\n" "${RED}[SUPERVISOR]${NC}" "$*" >&2
return 0
printf "%b %s\n" "${RED}[SUPERVISOR]${NC}" "$*" >&2 || true
References
  1. When set -e is active, using || true for non-critical commands like logging prevents the script from exiting prematurely on minor failures (e.g., broken pipe), ensuring robustness.

}

log_verbose() {
[[ "${SUPERVISOR_VERBOSE:-}" == "true" ]] && echo -e "${BLUE}[SUPERVISOR]${NC} $*" >&2 || true
[[ "${SUPERVISOR_VERBOSE:-}" == "true" ]] && printf "%b %s\n" "${BLUE}[SUPERVISOR]${NC}" "$*" >&2 || true
return 0
}

Expand Down
Loading