You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
828 B
Bash

#!/bin/bash
source "bash-colors.sh"
# Echo formatted time right now
function _now {
date +"%y/%m/%d %H:%M:%S"
}
# Write log to stdout
function log {
echo "[ $(_now) :: INFO ] $@"
}
# Log with custom tag
function logAdv {
TAG="${1}"
shift
echo -e "${FG_BLUE}[ $(_now) :: ${TAG} ] ${@}${C_RESET}"
}
# Log tagged for sensor scripts, can be muted with main.sh -qs
function logScript {
if ! [ "${SCRIPTS_QUIET}" = "yes" ]; then
echo -e "[ $(_now) :: SENS ] ${@}"
fi
}
# Write error to stderr
function logError {
echo -e "${BG_RED}[ $(_now) :: FAIL ] ${@}${C_RESET}" >&2
}
# Write pipe input to stdout
function logPipe {
PREFIX="PIPE"
[ "${1}" = "" ] || PREFIX="${@}"
while read -r LINE; do
echo -e "${FG_YELLOW}[ $(_now) :: ${PREFIX} ] ${LINE}${C_RESET}"
done
}