]> git.ipfire.org Git - network.git/blobdiff - functions.logging
bridge: Don't throw an assertion error when a device does not exist.
[network.git] / functions.logging
index 6cb827815b4ef02ef998045754e114859b506f00..9df5ce8648542f2381746a86e3fd3841754608cf 100644 (file)
@@ -43,16 +43,35 @@ function log() {
                message="${HOOK}: ${message}"
        fi
 
-       logger -t ${LOG_FACILITY} "${message}"
+       logger -t "${LOG_FACILITY}[$$]" "${message}"
 
        # Leave here, when there should be no output on the console.
        [ "${LOG_DISABLE_STDOUT}" = "true" ] && return 0
 
+       local colour
+       local console="2"
        case "${level}" in
-               DEBUG|INFO|WARNING|ERROR)
-                       message="${COLOUR_LOG[${level}]}${message}${COLOUR_NORMAL}"
+               DEBUG)
+                       colour="${CLR_CYAN_R}"
+                       ;;
+               INFO)
+                       colour="${CLR_BLACK_R}"
+                       console="1"
+                       ;;
+               WARNING)
+                       colour="${CLR_YELLOW_R}"
+                       ;;
+               ERROR)
+                       colour="${CLR_RED_B}"
                        ;;
        esac
 
-       echo -e "${message}" >&2
+       case "${console}" in
+               1)
+                       printf "${colour}${message}${CLR_RESET_ALL}\n"
+                       ;;
+               2)
+                       printf "${colour}${message}${CLR_RESET_ALL}\n" >&2
+                       ;;
+       esac
 }