]> git.ipfire.org Git - people/ms/network.git/commitdiff
Enhance logging with colors and output to stderr.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 22 May 2011 12:38:44 +0000 (12:38 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 22 May 2011 12:38:44 +0000 (12:38 +0000)
functions.colors
functions.logging

index c0de2605d6fa8266428346b5bfca2f199615f1d7..f0da0b4c8d64328f5d47356a1b926c0edbaa7eab 100644 (file)
@@ -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}
index e909a74e5a712c3240072b1e1e7a4c0fa68027c6..76b3bdc732be5cd84a76a74681c8478ce5ef2263 100644 (file)
@@ -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
 }