On Nov 9, 2005, at 4:03 PM, Lev Lvovsky wrote:
Hello,
In RE to my email yesterday about the syslog functionality of
log4cxx not working on Mac OS X (10.4.3):
My system has the "syslog.h" header for syslogd logging
functionality, and subsequently upon looking for the code, there're
some tests for this file:
Using the latest 0.9.8 source the precompiler directive
"LOG4CXX_HAVE_SYSLOG" is initially defined in the "include/log4cxx/
private/log4cxx_private.h" header file, however the header file
cannot be included in other source without "-DLOG4CXX_TEST" or "-
DLOG4CXX" being added to the compiler options, else the following
message shows up:
---
#error "log4cxx/private/log4cxx_private.h should only be used
within log4cxx implementation or tests"
---
By implementation, does that mean 'whenever I'd like to use
log4cxx'? Otherwise, the following block in syslogappender.cpp,
which actually invokes the syslog() function doesn't get entered...
Implementation means log4cxx itself. Client code (your code) should
not include log4cxx_private.h or define LOG4CXX.
---
<syslogappender.cpp>
261 #ifdef LOG4CXX_HAVE_SYSLOG
262 if (sw == 0)
263 {
264 std::string sbuf;
265 Transcoder::encode(msg, sbuf);
266
267 // use of "%s" to avoid a security hole
268 ::syslog(syslogFacility | event->getLevel
()->getSyslogEquivalent(),
269 "%s", sbuf.c_str());
270
271 return;
272 }
273 #endif
---
As a stopgap, I "#define LOG4CXX 1", and "#include <log4cxx/private/
log4cxx_private.h>" in the "syslogappender.h" header file before
the "LOG4CXX_HAVE_SYSLOG" precompiler variable gets checked. I'm
assuming there's either something wrong in the way I'm doing
things, or there's something wrong in the header files.
Thanks!
-lev
Both of the actions that you did are directly undoing intentional
checks that check that private implementation details are not exposed
in the public API. There is a judgement call what is publicly
exposed and what is private, so we could consider moving some of the
feature presence macros into a public header file.