summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJameson Graef Rollins <jrollins@phys.columbia.edu>2008-09-02 00:38:27 -0700
committerJameson Graef Rollins <jrollins@phys.columbia.edu>2008-09-02 00:38:27 -0700
commitbb2427c28bf40179c4881b22c23f23f9bea78f55 (patch)
tree0bc8478cc689eee669edcae7272e621ac4a33f83 /src
parent948b21702fbeaf1874286bd9b0d7c27c37d55c2a (diff)
Finalize new log level changes. This is more or less doing what it should. The only problem, I think, is that it doesn't handle improperly specified LOG_LEVEL well, effectively resorting to silent.
Diffstat (limited to 'src')
-rw-r--r--src/common33
-rwxr-xr-xsrc/monkeysphere-server2
2 files changed, 30 insertions, 5 deletions
diff --git a/src/common b/src/common
index 34d9b5a..f93793e 100644
--- a/src/common
+++ b/src/common
@@ -26,15 +26,40 @@ failure() {
exit ${2:-'255'}
}
-# write output to stderr
+# write output to stderr based on specified LOG_LEVEL the first
+# parameter is the priority of the output, and everything else is what
+# is echoed to stderr
log() {
+ local priority
local level
+ local output
- level="$1"
+ # translate lowers to uppers in global log level
+ LOG_LEVEL=$(echo "$LOG_LEVEL" | tr "[:lower:]" "[:upper:]")
+
+ # just go ahead and return if the log level is silent
+ if [ "$LOG_LEVEL" = 'SILENT' ] ; then
+ return
+ fi
+
+ # get priority from first parameter, translating all lower to
+ # uppers
+ priority=$(echo "$1" | tr "[:lower:]" "[:upper:]")
shift
- echo -n "ms: " >&2
- echo "$@" >&2
+ # scan over available levels
+ # list in decreasing verbosity (all caps)
+ for level in DEBUG INFO ERROR ; do
+ # output if the log level matches, set output to true
+ # this will output for all subsequenty loops as well.
+ if [ "$LOG_LEVEL" = "$level" ] ; then
+ output=true
+ fi
+ if [ "$priority" = "$level" -a "$output" = 'true' ] ; then
+ echo -n "ms: " >&2
+ echo "$@" >&2
+ fi
+ done
}
# cut out all comments(#) and blank lines from standard input
diff --git a/src/monkeysphere-server b/src/monkeysphere-server
index c81c066..e3ffc4b 100755
--- a/src/monkeysphere-server
+++ b/src/monkeysphere-server
@@ -855,7 +855,7 @@ unset MONKEYSPHERE_USER
# set empty config variable with ones from the environment, or with
# defaults
-LOG_LEVEL=${MONKEYSPHERE_LOG_LEVEL:=${LOG_LEVEL:="info"}}
+LOG_LEVEL=${MONKEYSPHERE_LOG_LEVEL:=${LOG_LEVEL:="INFO"}}
KEYSERVER=${MONKEYSPHERE_KEYSERVER:=${KEYSERVER:="subkeys.pgp.net"}}
AUTHORIZED_USER_IDS=${MONKEYSPHERE_AUTHORIZED_USER_IDS:=${AUTHORIZED_USER_IDS:="%h/.config/monkeysphere/authorized_user_ids"}}
RAW_AUTHORIZED_KEYS=${MONKEYSPHERE_RAW_AUTHORIZED_KEYS:=${RAW_AUTHORIZED_KEYS:="%h/.ssh/authorized_keys"}}