]> git.ipfire.org Git - people/stevee/network.git/blobdiff - functions.logging
Don't use connection tracking for loopback traffic.
[people/stevee/network.git] / functions.logging
index 9df5ce8648542f2381746a86e3fd3841754608cf..d3043ef8afd3a27b53a1a995d8a84efdd1c84a3a 100644 (file)
@@ -33,17 +33,21 @@ function log() {
        local level=${1}
        shift
        local message="$@"
+       local message_log="${message}"
 
        if [ -z "${DEBUG}" ] && [ "${level}" = "DEBUG" ]; then
                return
        fi
 
+       local funcname="${FUNCNAME[1]}"
+       message_log="${funcname}: ${message_log}"
+
        # Set a prefix if we are in a hook.
        if [ -n "${HOOK}" ]; then
-               message="${HOOK}: ${message}"
+               message_log="${HOOK}: ${message_log}"
        fi
 
-       logger -t "${LOG_FACILITY}[$$]" "${message}"
+       logger -t "${LOG_FACILITY}[$$]" "${message_log}" &
 
        # Leave here, when there should be no output on the console.
        [ "${LOG_DISABLE_STDOUT}" = "true" ] && return 0
@@ -55,7 +59,6 @@ function log() {
                        colour="${CLR_CYAN_R}"
                        ;;
                INFO)
-                       colour="${CLR_BLACK_R}"
                        console="1"
                        ;;
                WARNING)
@@ -68,10 +71,10 @@ function log() {
 
        case "${console}" in
                1)
-                       printf "${colour}${message}${CLR_RESET_ALL}\n"
+                       printf "${colour}${message}${CLR_RESET}\n"
                        ;;
                2)
-                       printf "${colour}${message}${CLR_RESET_ALL}\n" >&2
+                       printf "${colour}${message}${CLR_RESET}\n" >&2
                        ;;
        esac
 }