]> git.evergreen-ils.org Git - OpenSRF.git/commit
Patch from Scott McKellar to improve default logging:
authormiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 25 Jun 2007 03:06:56 +0000 (03:06 +0000)
committermiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 25 Jun 2007 03:06:56 +0000 (03:06 +0000)
commit442fe6e7a73150f2a06d2fc6760939aee38aa983
tree4aff80f52d84c61f07f47f5de423f6eb87fc5258
parent608728e9f303d981de4ceb7e12676868455ab5fc
Patch from Scott McKellar to improve default logging:

1. In log.h I added another macro OSRF_LOG_TYPE_STDERR by which the
application can specifically request logging to standard error.

2. In log.c I initialze _osrfLogType to OSRF_LOG_TYPE_STDERR so that
the application can issue a log message even if it hasn't called
osrfLogInit() yet.

3. I added the const qualifier to the parameters of the functions
_osrfLogToFile() and _osrfLogSetXid().

4. In osrfLogCleanup() I set _osrfLogAppname and _osrfLogFile to
NULL after freeing them.  Otherwise the application could cause
needless mischief by calling this function twice.

5. Also in osrfLogCleanup() I set _osrfLogType back to the default
OSRF_LOG_TYPE_STDERR so that the application can still issue a
message after calling osrfLogCleanup().

6. I rewrote osrfLogSetType() to use switch/case instead of an "if".
Now that we have three valid values to check instead of two, a
switch/case is a little tidier.  Also the default branch applies
the default log type OSRF_LOG_TYPE_STDERR.

7. _osrfLogDetail() had a local variable named "l" (lower case L).
I renamed it to "label" because "l" looks too much like a digit.

8.Also in _osrfLogDetail(): I added a branch to write a message to
stderr when _osrfLogType is OSRF_LOG_TYPE_STDERR.

9. The existing _osrfLogToFile function sizes and declares a buffer
named "buf", fills it with zeros, and then doesn't do anything with
it.  This buffer is probably a relic of some earlier version. I
eliminated it.

10. A few lines thereafter, I eliminated a useless call to bzero().

11. The call to strftime() contained a hard-coded buffer size.  I
changed it to use the sizeof operator, so that the buffer size is
defined in only one place.

12. If we can't open the log file, we write a message to stderr.
In this message I changed "file" to "log file" to make the meaning
more clear to a benighted and panicky user.

13. If after writing the message we can't close the file, the
existing code logs an error message by calling osrfLogWarning().
However in this circumstance this latter message will probably meet
the same fate, and no one will ever see it.  I changed the code so
as to write this message to stderr.

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