[Pm-utils] [PATCH] Logging infrastructure
Peter Jones
pjones at redhat.com
Sat Oct 21 12:05:57 PDT 2006
On Fri, 2006-10-20 at 15:54 +0200, Stefan Seyfried wrote:
> Is this an acceptable idea? I explicitly went for the "as simple as possible"
> approach, which also makes it trivial for hook writers to use it. All the
> alternatives (a log() function or something like that) would have been more
> complicated to use IMO.
In general, I think this is pretty good.
> I also removed all those "rm /var/run/pm-suspend" lines, since it does not
> hurt to let this file lay around until the next suspend (of course it is
> still deleted then before starting) and it also might contain various hints
> on what went wrong.
I'd rather we just log what's in the file than leave it sitting
around.
Some specific comments below.
...
> pm_main()
> {
> + [ -n "$LOGFILE" ] && ![[ "$LOGFILE" =~ "^/dev/" ] && rm -f $LOGFILE
Bad syntax...
> + [ -n "$LOGFILE" ] && exec > $LOGFILE 2>&1
This is really ugly :/
Why not:
if [ -n "$LOGFILE ]; then
[ -f "$LOGFILE" ] && rm -f $LOGFILE
touch "$LOGFILE"
fi
I'm not sure there's any point in redirecting the output of 'touch' to
the logfile -- if touch fails, we can't write to the logfile anyway.
--
Peter
More information about the Pm-utils
mailing list