From: Michael Tremer Date: Sun, 22 May 2011 12:38:44 +0000 (+0000) Subject: Enhance logging with colors and output to stderr. X-Git-Tag: 001~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d847fa7c337a6f730cdcbf8b79ce384afb85ae9c;p=network.git Enhance logging with colors and output to stderr. --- diff --git a/functions.colors b/functions.colors index c0de2605..f0da0b4c 100644 --- a/functions.colors +++ b/functions.colors @@ -34,6 +34,12 @@ COLOUR_WARN=${COLOUR_YELLOW} COLOUR_ENABLED=${COLOUR_GREEN} COLOUR_DISABLED=${COLOUR_RED} +declare -A COLOUR_LOG +COLOUR_LOG["DEBUG"]=${COLOUR_NORMAL} +COLOUR_LOG["INFO"]=${COLOUR_NORMAL} +COLOUR_LOG["ERROR"]=${COLOUR_RED} +COLOUR_LOG["WARNING"]=${COLOUR_YELLOW} + COLOUR_STP_FORWARDING=${COLOUR_GREEN} COLOUR_STP_DISCARDING=${COLOUR_RED} COLOUR_STP_LEARNING=${COLOUR_YELLOW} diff --git a/functions.logging b/functions.logging index e909a74e..76b3bdc7 100644 --- a/functions.logging +++ b/functions.logging @@ -37,4 +37,12 @@ function log() { fi logger -t ${LOG_FACILITY} "${message}" + + case "${level}" in + DEBUG|INFO|WARNING|ERROR) + message="${COLOUR_LOG[${level}]}${message}${COLOUR_NORMAL}" + ;; + esac + + echo -e "${message}" >&2 }