Provide logging helpers for structured logging
Parse log level from text representation to level number
Parse log level from text representation to level number
# Parse lower case log level
parse_log_level "info"
# Parse upper case log level
parse_log_level "ERROR"
- $1 (string): Log level to parse
- LOG_LEVEL (the): global log level to use in the script
- numeric log level
Log output on a given level, checks if $LOG_LEVEL, if not set defaults to INFO
# Log a message on info level
log "$LOG_INFO" "this is a info message"
log "LOG_DEBUG" "i am only visible when \$LOG_LEVEL is debug"
- $1 (number): Numeric log level
- $2 (string): Message to output
- Formatted log message with ANSI color codes