From: Michael Tremer Date: Sun, 23 Sep 2012 10:57:36 +0000 (+0000) Subject: logging: Log calling function and hooks of messages. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5438b0c1df2ecfc44bd763a06a524b87230ef3bc;p=people%2Fstevee%2Fnetwork.git logging: Log calling function and hooks of messages. This helps to debug things more easily and keeps stdout cleaner. --- diff --git a/functions.logging b/functions.logging index 9df5ce86..ce0a9564 100644 --- a/functions.logging +++ b/functions.logging @@ -33,17 +33,23 @@ function log() { local level=${1} shift local message="$@" + local message_log="${message}" if [ -z "${DEBUG}" ] && [ "${level}" = "DEBUG" ]; then return fi + local funcname="${FUNCNAME[1]}" + if isset funcname; then + message_log="${funcname}: ${message_log}" + fi + # 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