summaryrefslogtreecommitdiff
path: root/pm
diff options
context:
space:
mode:
authorVictor Lowther <victor.lowther@gmail.com>2008-03-15 16:38:32 -0500
committerVictor Lowther <victor.lowther@gmail.com>2008-03-15 16:38:32 -0500
commit962304a9279c244c9cdc1328cb800dd6bd49736e (patch)
tree1f01f54de499e12d46a9dba96c5aa806273701ac /pm
parent135bc1f5858caeae2b803e1e5c220b284c45b03c (diff)
Restore separate logging functionality
Somehow the changes introduced by 1fb77e994d7d1628c86324066693fd23d4abfb6c got dropped in the merge process. Restored them.
Diffstat (limited to 'pm')
-rw-r--r--pm/pm-functions.in15
1 files changed, 9 insertions, 6 deletions
diff --git a/pm/pm-functions.in b/pm/pm-functions.in
index 10dd2a9..d7ba77c 100644
--- a/pm/pm-functions.in
+++ b/pm/pm-functions.in
@@ -76,6 +76,8 @@ mkdir -p "$STORAGEDIR"
done < "$PM_UTILS_ETCDIR/parameters"
}
+log() { [ $LOGGING ] && echo $*; }
+
take_suspend_lock()
{
VT=$(fgconsole)
@@ -95,11 +97,11 @@ remove_suspend_lock()
hook_exit_status(){
case $1 in
- 0) echo "success." ;;
- $NA) echo "not applicable." ;;
- $NX) echo "not executable." ;;
- $DX) echo "disabled." ;;
- *) echo "Returned exit code $1." ;;
+ 0) log "success." ;;
+ $NA) log "not applicable." ;;
+ $NX) log "not executable." ;;
+ $DX) log "disabled." ;;
+ *) log "Returned exit code $1." ;;
esac
}
@@ -139,7 +141,7 @@ run_hooks() {
elif [ -f "$phooks/$base" ]; then
hook="$phooks/$base"
fi
- echo $(date): running ${hook} $2
+ log $(date): running ${hook} $2
hook_ok "$hook" && (
IFS="${oifs}"
"${hook}" $2
@@ -161,6 +163,7 @@ init_logfile()
echo "Please pass a filename to init_logfile."
return 1
fi
+ export LOGGING=true
exec > "$1" 2>&1
}