]> git.evergreen-ils.org Git - OpenSRF.git/commit
arg ... Patch from Scott McKellar that:
authormiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Fri, 29 Jun 2007 02:24:47 +0000 (02:24 +0000)
committermiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Fri, 29 Jun 2007 02:24:47 +0000 (02:24 +0000)
commit95c9e63f1202ac90f1b05cadc98a18c8a99a55fd
tree2efb3c20200eba0aa22702d6216886f2a924c2ad
parent56eac457879931d1ec9e296b0366292fa305a069
arg ... Patch from Scott McKellar that:

1. When we log messages to a log file, we open and close the file
for each message.  If the open fails, we write a message to stderr
about the failure to open, but we discard the original message that
we were asked to issue.

With this patch, after issuing the message about the failure to
open, we write the original message to stderr.

I believe that this change plugs the last message leak.  Now if we're
asked to issue a message, by golly we're going to issue it, one way
or another.

Of course the user may still not see the message, either through
inattention or, for example, because stderr is redirected to
/dev/null.  In that case the user is just a poo-poo head, and I have
no sympathy for him.

2. In an earlier post I proposed to change osrfLogSetType() so that
it would return the previous log type.  That way one could
temporarily change the log type and then restore it later, without
knowing in advance what to restore it to.

Upon further reflection I decided that the only plausible use for
this trick would be to reroute messages to standard error, and I
might as well provide a mechanism limited to this purpose.

Accordingly I created two new functions and prototyped them in log.h:

osrfLogToStderr() reroutes messages to stderr, and saves the previous
log type internally.

osrfRestoreLogType() restores the log type previously saved, if any.

This interface provides fewer ways for the calling code to mess up
than what I had originally contemplated.  First, the calling code
doesn't have to keep track of the previous log type.  Second, if the
messages are already rerouted, osrfLogToStderr() will do nothing.
One needn't worry about nested reroutings, or maintaining a stack of
log types, or anything of the sort.

If we ever need anything fancier we can build it, but I don't think
we will.

3. Wherever a function takes no parameters, I coded "void" as the
formal parameter list.  Otherwise the compiler doesn't know whether
the function takes parameters or not.

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@981 9efc2488-bf62-4759-914b-345cdb29e865
src/libopensrf/log.c