]> git.ipfire.org Git - people/ms/network.git/commitdiff
logging: Fix output on different consoles.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 30 Jun 2012 09:53:21 +0000 (09:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 30 Jun 2012 09:53:21 +0000 (09:53 +0000)
functions.logging

index 7357a60c8805837da70f82ae8a76cc53480661f8..9df5ce8648542f2381746a86e3fd3841754608cf 100644 (file)
@@ -49,14 +49,14 @@ function log() {
        [ "${LOG_DISABLE_STDOUT}" = "true" ] && return 0
 
        local colour
-       local console=">&2"
+       local console="2"
        case "${level}" in
                DEBUG)
                        colour="${CLR_CYAN_R}"
                        ;;
                INFO)
                        colour="${CLR_BLACK_R}"
-                       console=""
+                       console="1"
                        ;;
                WARNING)
                        colour="${CLR_YELLOW_R}"
@@ -66,5 +66,12 @@ function log() {
                        ;;
        esac
 
-       printf "${colour}${message}${CLR_RESET_ALL}\n" ${console}
+       case "${console}" in
+               1)
+                       printf "${colour}${message}${CLR_RESET_ALL}\n"
+                       ;;
+               2)
+                       printf "${colour}${message}${CLR_RESET_ALL}\n" >&2
+                       ;;
+       esac
 }