summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2008-09-02 09:00:12 -0400
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>2008-09-02 09:00:12 -0400
commit7d9b281e67d75163d491e303d4693a00667b7f91 (patch)
treeff3af0b43e598648b347ee43faa3f4887876f624 /src
parenta07556b5ce12eaa2c3ceb51f5b6cce7884775c0f (diff)
cleanup stray commas, ensure that ill-specified loglevels default to INFO
Diffstat (limited to 'src')
-rw-r--r--src/common19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/common b/src/common
index f93793e..4e731e1 100644
--- a/src/common
+++ b/src/common
@@ -33,6 +33,10 @@ log() {
local priority
local level
local output
+ # don't include SILENT in alllevels: it's handled separately
+ # list in decreasing verbosity (all caps)
+ local alllevels="DEBUG INFO ERROR"
+ local found=
# translate lowers to uppers in global log level
LOG_LEVEL=$(echo "$LOG_LEVEL" | tr "[:lower:]" "[:upper:]")
@@ -42,16 +46,25 @@ log() {
return
fi
+ for level in $alllevels; do
+ if [ "$LOG_LEVEL" = "$level" ] ; then
+ found=true
+ fi
+ done
+ if [ -z "$found" ] ; then
+ # default to INFO:
+ LOG_LEVEL=INFO
+ fi
+
# get priority from first parameter, translating all lower to
# uppers
priority=$(echo "$1" | tr "[:lower:]" "[:upper:]")
shift
# scan over available levels
- # list in decreasing verbosity (all caps)
- for level in DEBUG INFO ERROR ; do
+ for level in $alllevels ; do
# output if the log level matches, set output to true
- # this will output for all subsequenty loops as well.
+ # this will output for all subsequent loops as well.
if [ "$LOG_LEVEL" = "$level" ] ; then
output=true
fi