[Pm-utils] [PATCH] Logging infrastructure

Peter Jones pjones at redhat.com
Mon Oct 30 07:41:04 PST 2006


On Mon, 2006-10-30 at 10:29 +0100, Stefan Seyfried wrote:

> If $LOGFILE is empty, then just do not redirect (basically for debugging by
> running pm-hibernate manually from a root shell).

Oh, I'm also going to change it to PM_LOGFILE, and to only set it if
it's not already set (so we can inherit settings from e.g. HAL rather
than just a config file).

So the full diff from today's conversation so far is:

diff -u -p -r1.25 functions
--- functions   21 Oct 2006 19:47:02 -0000      1.25
+++ functions   30 Oct 2006 15:38:41 -0000
@@ -6,7 +6,7 @@ export PATH=/sbin:/usr/sbin:/bin:/usr/bi
 HIBERNATE_RESUME_POST_VIDEO=no
 SUSPEND_MODULES=""
 RESUME_MODULES=""
-LOGFILE=/var/log/pm-suspend.log
+PM_LOGFILE=${PM_LOGFILE:=/var/log/pm-suspend.log}
 
 [ -f /etc/pm/config ] && . /etc/pm/config
 
@@ -20,7 +20,7 @@ add_global() {
 add_global HIBERNATE_RESUME_POST_VIDEO
 add_global SUSPEND_MODULES
 add_global RESUME_MODULES
-add_global LOGFILE
+add_global PM_LOGFILE
 
 source_configs()
 {
@@ -115,9 +115,9 @@ get_power_status()
 
 pm_main()
 {
-       if [ -n "$LOGFILE" ]; then
-               [ -f "$LOGFILE" ] && rm -f "$LOGFILE"
-               touch "$LOGFILE"
+       if [ -n "$PM_LOGFILE" ]; then
+               [ -f "$PM_LOGFILE" ] && rm -f "$PM_LOGFILE"
+               exec > "$PM_LOGFILE" 2>&1
        fi
        take_suspend_lock || exit 1
        run_hooks "$1"

-- 
  Peter



More information about the Pm-utils mailing list