From: Amadeusz Żołnowski Date: Wed, 16 Mar 2011 20:24:29 +0000 (+0100) Subject: dracut-logger: make $maxloglvl public X-Git-Tag: 009~40 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=46265a9d3e0a15e4e8d21995cdf0618691d4e394;p=platform%2Fupstream%2Fdracut.git dracut-logger: make $maxloglvl public $maxloglvl might be useful to check, if expensive informational operation is going to be logged at all, before executing it. --- diff --git a/dracut-logger b/dracut-logger index 0978d58..830ce1c 100755 --- a/dracut-logger +++ b/dracut-logger @@ -76,9 +76,9 @@ __DRACUT_LOGGER__=1 # - @var kmsgloglvl - logging level to /dev/kmsg (only for boot-time) # - @var logfile - log file which is used when @var fileloglvl is higher # than 0 -# and one global internal variable @var _maxloglvl which must not be -# overwritten. @_maxloglvl is set by dlog_init() and holds maximum logging level -# of those three and indicates that dlog_init() was run. +# and one global variable @var maxloglvl which must not be overwritten. +# @var maxloglvl is set by dlog_init() and holds maximum logging level of those +# three and indicates that dlog_init() was run. # # Logging level set by the variable means that messages from this logging level # and above (FATAL is the highest) will be shown. Logging levels may be set @@ -101,11 +101,11 @@ __DRACUT_LOGGER__=1 # - @var kmsgloglvl = 0 (no logging) # set to 0 # -# @warning Function sets global variable @var _maxloglvl for internal use. Don't -# overwrite it. +# @warning Function sets global variable @var maxloglvl. See file doc for +# details. dlog_init() { # Skip initialization if it's already done. - [ -n "$_maxloglvl" ] && return 0 + [ -n "$maxloglvl" ] && return 0 local ret=0; local errmsg @@ -144,12 +144,12 @@ dlog_init() { fi fi - local lvl - _maxloglvl=0 - for lvl in $stdloglvl $sysloglvl $fileloglvl; do - [ $lvl -gt $_maxloglvl ] && _maxloglvl=$lvl + local lvl; local maxloglvl_l=0 + for lvl in $stdloglvl $sysloglvl $fileloglvl $kmsgloglvl; do + [ $lvl -gt $maxloglvl_l ] && maxloglvl_l=$lvl done - export _maxloglvl + readonly maxloglvl=$maxloglvl_l + export maxloglvl [ -n "$errmsg" ] && derror "$errmsg" @@ -251,11 +251,11 @@ _dlvl2klvl() { # - @c INFO to @c info # - @c DEBUG and @c TRACE both to @c debug _do_dlog() { - [ -z "$_maxloglvl" ] && return 0 + [ -z "$maxloglvl" ] && return 0 local lvl="$1"; shift local lvlc=$(_lvl2char "$lvl") || return 0 - [ $lvl -le $_maxloglvl ] || return 0 + [ $lvl -le $maxloglvl ] || return 0 local msg="$lvlc: $*"