diff --git a/LCS/Common/include/Common/LofarLog4Cxx.h b/LCS/Common/include/Common/LofarLog4Cxx.h new file mode 100644 index 0000000000000000000000000000000000000000..8764705b97deda754c500b505f389293295d2621 --- /dev/null +++ b/LCS/Common/include/Common/LofarLog4Cxx.h @@ -0,0 +1,403 @@ +//# LofarLog4Cxx.h: Interface to the log4cxx logging package +//# +//# Copyright (C) 2007 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +#ifndef LOFAR_COMMON_LOG4CXX_H +#define LOFAR_COMMON_LOG4CXX_H + +// \file +// Interface to the log4cxx logging package. + +//# Never #include <config.h> or #include <lofar_config.h> in a header file! +#include <Common/lofar_iostream.h> +#include <Common/lofar_string.h> +#include <Common/Exception.h> + +//# Includes +#include <log4cxx/logger.h> +#include <log4cxx/propertyconfigurator.h> + +namespace LOFAR { + + // \ingroup Common + // \addtogroup LofarLogger + // @{ + + //# -------------------- Initialisation of the logger module ------------------- + // + // \name Initialisation of the logger module + // Before you can use any function of the logger module you should initialize + // the module with an appropriate properties-file. There are two functions + // available for this: + // @{ + // + // Only initializes the logger module. +#define INIT_LOGGER(filename) \ +do { \ + ::LOFAR::lofarLoggerInitNode(); \ + if (!strstr(filename, ".log_prop")) { \ + log4cxx::PropertyConfigurator::configure \ + (log4cxx::File(filename + std::string(".log_prop"))); \ + } else { \ + log4cxx::PropertyConfigurator::configure \ + (log4cxx::File(filename)); \ + } \ +} while(0) + +#define INIT_VAR_LOGGER(filename,logfile) INIT_LOGGER(filename) + +#define INIT_LOGGER_AND_WATCH(filename,watchinterval) \ +do { \ + ::LOFAR::lofarLoggerInitNode(); \ + if (!strstr(filename, ".log_prop")) { \ + log4cxx::PropertyConfigurator::configureAndWatch \ + (log4cxx::File(filename + std::string(".log_prop")), watchinterval); \ + } else { \ + log4cxx::PropertyConfigurator::configureAndWatch \ + (log4cxx::File(filename), watchinterval); \ + } \ +} while(0) + + //@} + + //# -------------------- Log Levels for the Operator messages ------------------ + //# + //# LOG_FATAL(_STR) (message | stream) + //# LOG_ERROR(_STR) (message | stream) + //# LOG_WARN(_STR) (message | stream) + //# LOG_INFO(_STR) (message | stream) + // + // \name Log Levels for the Operator messages + // + // The LofarLogger utility can log messages on six different levels: + // <tt>FATAL - ERROR - WARN - INFO - DEBUG - TRACE</tt>. + // There are strict rules how to use these levels so please read the programmer + // manual of the LofarLogger before using it. + // + // For every level there are two calls made, <tt>LOG_\<level\></tt> and + // <tt>LOG_\<level\>_STR</tt>. + // The first form expects a string as an argument, the second form a stream. + // The stream version allows you to use the operator<< but it is MUCH slower + // than its string counterpart. + // To simplifly the usage of strings you can call the global function + // 'formatString' that accepts printf like arguments and returns a string. + // + // The functions \c LOG_FATAL till \c LOG_INFO produce messages that are meant + // for the operators. The message may NOT contain any 'inside' information, + // they should tell: + // - WHAT situation has arisen + // - WHY this situation is a fault situation + // - HOW the situation should be solved (when appropriate) + // + // @{ + + // Should be used when an unrecoverable exception occures. +#define LOG_FATAL(message) LofarLog(Fatal,message) + // Should be used when an unrecoverable exception occures. +#define LOG_FATAL_STR(stream) LofarLogStr(Fatal,stream) + + // Should be used in case of recoverable exceptions and illegal start parms. +#define LOG_ERROR(message) LofarLog(Error,message) + // Should be used in case of recoverable exceptions and illegal start parms. +#define LOG_ERROR_STR(stream) LofarLogStr(Error,stream) + + // Should be used when an unexpected situation occured that could be solved by + // the software itself. +#define LOG_WARN(message) LofarLog(Warn,message) + // Should be used when an unexpected situation occured that could be solved by + // the software itself. +#define LOG_WARN_STR(stream) LofarLogStr(Warn,stream) + + // Should be used to notify operator startup and normal termination of + // programs. It can also be used for other 'global' actions. +#define LOG_INFO(message) LofarLog(Info,message) + // Should be used to notify operator startup and normal termination of + // programs. It can also be used for other 'global' actions. +#define LOG_INFO_STR(stream) LofarLogStr(Info,stream) + + // @} + + //# ------------------------- Debug Levels for the Integrator ------------------------- + //# + //# LOG_DEBUG(_STR) (message | stream) + //# + // \name Debug Levels for the Integrator + // + // %Debug information is primarilry meant for the integrator/user of your moudule. + // Note that the user of your module is often a developer. The messages contain + // information about the I/O boundaries of a software module. They should be + // clear to someone who does not have detailed inside information. + // + // The debug messages can still be present in the final 'production' version of + // your module, so don't overload your program with it. + // + // @{ + +#ifdef DISABLE_DEBUG_OUTPUT +#define LOG_DEBUG(message) +#define LOG_DEBUG_STR(stream) +#else + + // Use this macro for plain and 'printf' like messages. +#define LOG_DEBUG(message) LofarLog(Debug,message) + + // Use this macro for operator<< messages + // \note the 'printf' counterparts are MUCH faster and produce less code! +#define LOG_DEBUG_STR(stream) LofarLogStr(Debug,stream) + +#endif // DISABLE_DEBUG_OUTPUT + + // @} + + //# ----------------------- Trace Levels for the Programmer -------------------- + //# + //# ALLOC_TRACER_CONTEXT + //# INIT_TRACER_CONTEXT (scope, contextname) + //# ALLOC_TRACER_ALIAS (parent) + //# LOG_TRACE_<type>(_STR) (stream) + //# + //# Where <type> = LOOP, VAR, CALC, COND, STAT, OBJ, RTTI or FLOW + //# + // \name Trace Levels for the Programmer + // + // The trace level is split up into five additive sublevels to be able to + // control the amount of output generated on this trace level. Again there are + // strict guidelines how to use the levels in order to improve maintenance of + // the source (by other developers). + // + // Tracing is implemented different from the other levels to get maximum speed + // for the decision whether of not to log a message. The fact remains though + // that the string-form of the calls stay much faster than their stream-form + // counterparts. + // + // Unlike the other loglevels the trace level will not be present anymore in the + // final production code. + // + // @{ + +#ifdef ENABLE_TRACER + +#define LOG_TRACE_LOOP(message) LofarLogTrace(1, message) +#define LOG_TRACE_VAR(message) LofarLogTrace(2, message) +#define LOG_TRACE_CALC(message) LofarLogTrace(3, message) +#define LOG_TRACE_COND(message) LofarLogTrace(4, message) +#define LOG_TRACE_STAT(message) LofarLogTrace(5, message) +#define LOG_TRACE_OBJ(message) LofarLogTrace(6, message) +#define LOG_TRACE_RTTI(message) LofarLogTrace(7, message) +#define LOG_TRACE_FLOW(message) LofarLogTrace(8, message) +#define LOG_TRACE_LOOP_STR(stream) LofarLogTraceStr(1, stream) +#define LOG_TRACE_VAR_STR(stream) LofarLogTraceStr(2, stream) +#define LOG_TRACE_CALC_STR(stream) LofarLogTraceStr(3, stream) +#define LOG_TRACE_COND_STR(stream) LofarLogTraceStr(4, stream) +#define LOG_TRACE_STAT_STR(stream) LofarLogTraceStr(5, stream) +#define LOG_TRACE_OBJ_STR(stream) LofarLogTraceStr(6, stream) +#define LOG_TRACE_RTTI_STR(stream) LofarLogTraceStr(7, stream) +#define LOG_TRACE_FLOW_STR(stream) LofarLogTraceStr(8, stream) +#define TRACE_LEVEL_LOOP 1 +#define TRACE_LEVEL_VAR 2 +#define TRACE_LEVEL_CALC 3 +#define TRACE_LEVEL_COND 4 +#define TRACE_LEVEL_STAT 5 +#define TRACE_LEVEL_OBJ 6 +#define TRACE_LEVEL_RTTI 7 +#define TRACE_LEVEL_FLOW 8 + +#define LofarLogTrace(level,message) \ + do { \ + if (getTraceLogger()->isDebugEnabled()) { \ + getTraceLogger()->forcedLog (log4cxx::Level::getDebug(), \ + message, \ + LOG4CXX_LOCATION); \ + } \ + } while(0) + +// \internal +// Internal macro used by the LOG_TRACE_<level>_STR macros. +#define LofarLogTraceStr(level,stream) \ + do { \ + if (getTraceLogger()->isDebugEnabled()) { \ + std::ostringstream lfr_log_oss; \ + lfr_log_oss << stream; \ + getTraceLogger()->forcedLog (log4cxx::Level::getDebug(), \ + lfr_log_oss.str(), \ + LOG4CXX_LOCATION); \ + } \ + } while(0) + + //# + //# LOG_TRACE_LIFETIME(_STR) (level,message | stream) + //# + + // Create a TraceLogger object that will output your message during construct + // and destruction. Your message is preceeded with "ENTER:" or "EXIT:". +#define LOG_TRACE_LIFETIME(level,message) \ + ::LOFAR::LifetimeLogger _tmpLifetimeTraceObj(level, getTraceLogger(), \ + ::LOFAR::formatString("%s: %s", AUTO_FUNCTION_NAME, message), \ + __FILE__, __LINE__); + + // Create a TraceLogger object that will output your message during construct + // and destruction. Your message is preceeded with "ENTER:" or "EXIT:". +#define LOG_TRACE_LIFETIME_STR(level,stream) \ + std::ostringstream lfr_log_oss; \ + lfr_log_oss << AUTO_FUNCTION_NAME << ": " << stream; \ + ::LOFAR::LifetimeLogger _tmpLifetimeTraceObj(level, \ + getTraceLogger(), \ + lfr_log_oss.str(), \ + __FILE__, __LINE__); + + //# ----------- implementation details tracer part ------------- + + +#else // ENABLE_TRACER + //# Define dummies if tracing is disabled. +#define LOG_TRACE_LOOP(message) +#define LOG_TRACE_VAR(message) +#define LOG_TRACE_CALC(message) +#define LOG_TRACE_COND(message) +#define LOG_TRACE_STAT(message) +#define LOG_TRACE_OBJ(message) +#define LOG_TRACE_RTTI(message) +#define LOG_TRACE_FLOW(message) +#define LOG_TRACE_LOOP_STR(stream) +#define LOG_TRACE_VAR_STR(stream) +#define LOG_TRACE_CALC_STR(stream) +#define LOG_TRACE_COND_STR(stream) +#define LOG_TRACE_STAT_STR(stream) +#define LOG_TRACE_OBJ_STR(stream) +#define LOG_TRACE_RTTI_STR(stream) +#define LOG_TRACE_FLOW_STR(stream) +#define TRACE_LEVEL_LOOP 0 +#define TRACE_LEVEL_VAR 0 +#define TRACE_LEVEL_CALC 0 +#define TRACE_LEVEL_COND 0 +#define TRACE_LEVEL_STAT 0 +#define TRACE_LEVEL_OBJ 0 +#define TRACE_LEVEL_RTTI 0 +#define TRACE_LEVEL_FLOW 0 + +#define LOG_TRACE_LIFETIME(level,message) +#define LOG_TRACE_LIFETIME_STR(level,stream) + +#endif // ENABLE_TRACER + +#define LofarInitTracingModule +#define ALLOC_TRACER_CONTEXT +#define ALLOC_TRACER_ALIAS(other) +#define INIT_TRACER_CONTEXT(scope,contextname) + + //@} + + //#------------------------ Assert and FailWhen ------------------------------- + //# + //# THROW (exception,stream) + //# (DBG)ASSERT (condition,stream) + //# (DBG)FAILWHEN (condition,stream) + //# + //# Note: only THROW needs to be defined here, the others are build on THROW + //# in the LofarLogger.h file. + // + // \name Throw + // @{ + // + // This macro first sends a logrequest to logger <tt>\<module\>.EXCEPTION</tt> + // before executing the real throw. +#undef THROW +#define THROW(exc,stream) \ + do { \ + std::ostringstream lfr_log_oss; \ + lfr_log_oss << stream; \ + log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(LOFARLOGGER_FULLPACKAGE ".EXCEPTION"); \ + LOG4CXX_DEBUG (logger, lfr_log_oss.str()); \ + throw (exc(lfr_log_oss.str(), __HERE__)); \ + } while(0) + + // @} + + //# ----------- implementation details generic part ------------- + +#ifndef DOXYGEN_SHOULD_SKIP_THIS + // \internal + // \name Internal macro's for standard logging functions + // @{ +#define LofarLog(type,message) \ + do { \ + log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(LOFARLOGGER_FULLPACKAGE); \ + if (logger->is##type##Enabled()) { \ + logger->forcedLog (log4cxx::Level::get##type(), message, \ + LOG4CXX_LOCATION); \ + } \ + } while(0) + + // \internal +#define LofarLogStr(type,stream) \ + do { \ + std::ostringstream lfr_log_oss; \ + lfr_log_oss << stream; \ + LofarLog(type, lfr_log_oss.str()); \ + } while(0) + // @} +#endif // DOXYGEN_SHOULD_SKIP_THIS + + void lofarLoggerInitNode(void); + + + // The LifetimeLogger class produces TRACE messages when an instance of this + // class is created and when it is destroyed. + class LifetimeLogger + { + public: + LifetimeLogger(int, + const log4cxx::LoggerPtr& logger, + const std::string& msg, + const char* file=0, int line=-1) + : itsLogger(logger), itsMsg(msg), + itsFile(file), itsLine(line) + { + itsLogger->forcedLog(log4cxx::Level::getDebug(), + "ENTER: " + itsMsg, + log4cxx::spi::LocationInfo(itsFile, 0, itsLine)); + } + + ~LifetimeLogger() + { + itsLogger->forcedLog(log4cxx::Level::getDebug(), + "EXIT: " + itsMsg, + log4cxx::spi::LocationInfo(itsFile, 0, itsLine)); + } + + private: + log4cxx::LoggerPtr itsLogger; + std::string itsMsg; + const char* itsFile; + int itsLine; + }; + + + // @} + +// The 'mother' of all trace-loggers is stored here. +extern log4cxx::LoggerPtr theirTraceLoggerRef; +// Function to return the 'mother' of all trace-loggers. +inline log4cxx::LoggerPtr& getTraceLogger() { return theirTraceLoggerRef; } + +} // namespace LOFAR + +#endif // file read before diff --git a/LCS/Common/include/Common/LofarLogger.h b/LCS/Common/include/Common/LofarLogger.h index ecac7452257c3e45cc96a53713cd932a1ddff439..9120eaffe68c6e3951795c904f06e5c5b3b726b9 100644 --- a/LCS/Common/include/Common/LofarLogger.h +++ b/LCS/Common/include/Common/LofarLogger.h @@ -31,11 +31,13 @@ //# Dependent of the availability of the log4Cplus package one set of macro's //# or the other set of macro's is included. -#ifdef HAVE_LOG4CPLUS +#if defined(HAVE_LOG4CPLUS) # include <Common/LofarLog4Cplus.h> +#elif defined(HAVE_LOG4CXX) +# include <Common/LofarLog4Cxx.h> #else # include <Common/LofarLogCout.h> -#endif //HAVE_LOG4CPLUS +#endif namespace LOFAR { @@ -97,12 +99,12 @@ EXCEPTION_CLASS(AssertError,Exception); #define ASSERT(cond) \ if (!(cond)) THROW(::LOFAR::AssertError, "Assertion: " #cond) -// If the condition of assert is NOT met a logrequest is sent to the logger +// If the condition of assert is NOT met, a logrequest is sent to the logger // <tt>\<module\>.EXCEPTION</tt> and an AssertError exception is thrown. #define ASSERTSTR(cond,stream) \ if (!(cond)) THROW(::LOFAR::AssertError, "Assertion: " #cond "; " << stream) -// If the condition of failwhen is met a logrequest is sent to the logger +// If the condition of failwhen is met, a logrequest is sent to the logger // <tt>\<module\>.EXCEPTION</tt> and an AssertError exception is thrown. #define FAILWHEN(cond) \ if (cond) THROW(::LOFAR::AssertError, "Failtest: " #cond) diff --git a/LCS/Common/include/Common/Makefile.am b/LCS/Common/include/Common/Makefile.am index 9322fb6c4642ec135ee22427b291d504bd9a8a71..12f12b2e3dd3386a62106e5a5f58ba291726341e 100644 --- a/LCS/Common/include/Common/Makefile.am +++ b/LCS/Common/include/Common/Makefile.am @@ -31,6 +31,7 @@ pkginclude_HEADERS = \ lofar_list.h \ LofarLocators.h \ LofarLog4Cplus.h \ + LofarLog4Cxx.h \ LofarLogCout.h \ LofarLogger.h \ lofar_map.h \ diff --git a/LCS/Common/src/LofarLogger.cc b/LCS/Common/src/LofarLogger.cc index a29c8bd820ac850a2d1fcbe1dc8e2e657aa57f9a..cce38675a6d216c47f80af513bca3b19452ae880 100644 --- a/LCS/Common/src/LofarLogger.cc +++ b/LCS/Common/src/LofarLogger.cc @@ -29,6 +29,11 @@ #include <libgen.h> // basename #include <Common/LofarLogger.h> +#if defined(HAVE_LOG4CXX) +# include <log4cxx/ndc.h> +#endif + + namespace LOFAR { //#------------------------- Internal implementation ----------------------------- @@ -59,12 +64,14 @@ void lofarLoggerInitNode(void) { // construct loggerId and register it. snprintf(loggerId, MAXLEN-1, "%s@%s", basename(applName), hostName); -#ifdef HAVE_LOG4CPLUS +#if defined(HAVE_LOG4CPLUS) log4cplus::getNDC().push(loggerId); -#endif // HAVE_LOG4CPLUS +#elif defined(HAVE_LOG4CXX) + log4cxx::NDC::push(loggerId); +#endif } -#ifdef HAVE_LOG4CPLUS +#if defined(HAVE_LOG4CPLUS) using namespace log4cplus; //# ------------------------ implement the five trace levels ------------------------ @@ -114,9 +121,14 @@ LogLevel string2TraceLevel (const tstring& lname) { return NOT_SET_LOG_LEVEL; // not found } -LOFAR::LoggerReference theirTraceLoggerRef("TRC"); // create the tracelogger +LOFAR::LoggerReference theirTraceLoggerRef("TRC"); // create the tracelogger + +#elif defined(HAVE_LOG4CXX) + +log4cxx::LoggerPtr theirTraceLoggerRef(log4cxx::Logger::getLogger("TRC")); + +#endif -#endif // HAVE_LOG4CPLUS // initTracemodule // diff --git a/LCS/Common/test/Makefile.am b/LCS/Common/test/Makefile.am index 2faf5cd91581deb33ffae33e1cc46c09857148b0..167d86ba2dc535628bf50f08496c1ae78cf6ae70 100644 --- a/LCS/Common/test/Makefile.am +++ b/LCS/Common/test/Makefile.am @@ -1,9 +1,3 @@ -check_PROGRAMS = testLogger tAllocator tDataConvert \ - tFileLocator tStringUtil tStreamUtil \ - tHexdump testSocket tComplex tProcess \ - tRunOnNode tTimer tNumeric tSingleton \ - tObjectFactory - # programs to run through supplied checktools CHECKTOOLPROGS = testLogger tAllocator tDataConvert \ tFileLocator tStringUtil tStreamUtil \ @@ -11,6 +5,8 @@ CHECKTOOLPROGS = testLogger tAllocator tDataConvert \ tRunOnNode tTimer tNumeric tSingleton \ tObjectFactory +check_PROGRAMS = $(CHECKTOOLPROGS) + TESTSCRIPTS = testLogger.sh tAllocator.sh tDataConvert.sh \ tFileLocator.sh tStringUtil.sh tStreamUtil.sh \ tHexdump.sh testSocket.sh tComplex.sh tProcess.sh \ @@ -21,6 +17,7 @@ TESTS = $(TESTSCRIPTS) EXTRA_DIST = $(TESTSCRIPTS) \ testLogger.log_prop testLogger.debug \ + testLogger.in_log4cxx.log_prop \ tDataConvert.stdout \ tStringUtil.stdout \ tStreamUtil.stdout \ diff --git a/LCS/Common/test/testLogger.cc b/LCS/Common/test/testLogger.cc index dc962528778b29108d15d18977b3997e8046eb69..ee26d77809a57d94f9162357e0df4fa5b5e37845 100644 --- a/LCS/Common/test/testLogger.cc +++ b/LCS/Common/test/testLogger.cc @@ -121,7 +121,7 @@ int main (int, char *argv[]) { // Read in the log-environment configuration // We should always start with this. //INIT_LOGGER_AND_WATCH("testLogger", 10000); - INIT_LOGGER("testLogger"); + INIT_LOGGER("testLogger.in_log4cxx"); // Show operator were are on the air LOG_INFO (formatString("Program %s has started", argv[0])); @@ -187,12 +187,12 @@ int main (int, char *argv[]) { LOG_INFO("We now set the Threshold of the TRACE logger to " "TRACE_LEVEL_VAR so the loop counter don't show up anymore"); -#ifdef HAVE_LOG4CPLUS +#if defined(HAVE_LOG4CPLUS) // You normally do this by editing your propertyfile. log4cplus::Logger::getInstance("TRC").setLogLevel(TRACE_LEVEL_VAR); -#else +#elif !defined(HAVE_LOG4CXX) getLFDebugContext().setLevel(TRACE_LEVEL_VAR); -#endif // HAVE_LOG4CPLUS +#endif for (int i = 0; i < 5; ++i) { LOG_TRACE_LOOP(formatString("Loop counter = %d", i)); diff --git a/LCS/Common/test/testLogger.in_log4cxx.log_prop b/LCS/Common/test/testLogger.in_log4cxx.log_prop new file mode 100644 index 0000000000000000000000000000000000000000..89d9135e5fe844c352214ce0f9074a7a1f3aceb3 --- /dev/null +++ b/LCS/Common/test/testLogger.in_log4cxx.log_prop @@ -0,0 +1,10 @@ +# log4cxx property file to be used with the demo program testLogger. + +# Configure the rootLogger +log4j.rootLogger=DEBUG, STDOUT +# Define the STDOUT appender +log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender +log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout +log4j.appender.STDOUT.layout.ConversionPattern=%-5p [%x]%c{3} - %m%n + +log4j.logger.LCS.Common=DEBUG diff --git a/autoconf_share/lofar_general.m4 b/autoconf_share/lofar_general.m4 index 8e60e4f87dcdd47c70f227f707a643c7283d0da2..d3877f9ddce7d942378ba26b66cfd11fbc353098 100644 --- a/autoconf_share/lofar_general.m4 +++ b/autoconf_share/lofar_general.m4 @@ -50,7 +50,7 @@ lofar_CHECK_PRETTY_FUNCTION([]) lofar_CHECK_INSTALL_IF_MODIFIED([]) lofar_QATOOLS([]) lofar_DOCXX([]) -lofar_LOG4CPLUS([]) +lofar_LOGGER([]) dnl ]) diff --git a/autoconf_share/lofar_logger.m4 b/autoconf_share/lofar_logger.m4 index 38ca174ba80265f63c1a985a20cc0fe1ce27e2d0..6507592c4b736d5a9f33389a159acb8e7fac8d71 100644 --- a/autoconf_share/lofar_logger.m4 +++ b/autoconf_share/lofar_logger.m4 @@ -21,19 +21,48 @@ # $Id$ +# lofar_LOGGER +# +# Macro to check for logger (log4cplus, log4cxx or none) +# +AC_DEFUN([lofar_LOGGER],dnl +[dnl +lofar_HEADER_LOG4CPLUS([])dnl +lofar_HEADER_LOG4CXX([])dnl +[ +enable_logger=0 +if test "$enable_log4cplus" = "yes"; then + enable_logger=${enable_logger}1 +fi +if test "$enable_log4cxx" = "yes"; then + enable_logger=${enable_logger}1 +fi +if test $enable_logger -gt 1; then +] + AC_MSG_ERROR([Cannot use more than one LOGGER implementation.]) +[fi] +]) + + # lofar_LOG4CPLUS # # Macro to check for LOG4CPLUS installation # -# lofar_LOG4CPLUS(option) -# option 0 means that Log4cplus++ is optional, otherwise mandatory. +AC_DEFUN([lofar_HEADER_LOG4CPLUS],dnl +[dnl +AC_PREREQ(2.13)dnl +lofar_EXTERNAL(log4cplus,0,log4cplus/logger.h,,) +enable_log4cplus=$enable_external +]) + + +# lofar_LOG4CXX # -# e.g. lofar_LOG4CPLUS(1) -# ------------------------- +# Macro to check for LOG4CXX installation # -AC_DEFUN([lofar_LOG4CPLUS],dnl +AC_DEFUN([lofar_HEADER_LOG4CXX],dnl [dnl AC_PREREQ(2.13)dnl -ifelse($1, [], [lfr_option=0], [lfr_option=$1]) -lofar_EXTERNAL(log4cplus,[$lfr_option],log4cplus/logger.h,,) +lofar_EXTERNAL(log4cxx,0,log4cxx/logger.h,,) +enable_logger=$enable_external ]) diff --git a/autoconf_share/variants b/autoconf_share/variants index 5f26870786e1ceaa2442319195efd59daf9669f4..ec05b8c06ef5e6789e7a594812ed3ebebca73f16 100644 --- a/autoconf_share/variants +++ b/autoconf_share/variants @@ -23,7 +23,7 @@ nolog4cplus.variant.conf: $(standard) $(debug) --without-log4cplus insure.variant.conf: $(standard) --with-insuretools --with-cppflags="-D__INSURE__" insure.variant.make: QA=insure -standard.var: $(lofar_root) $(aipspp) $(sockets) $(threads) $(sse) $(shmem) $(searchpath) $(python) +standard.var: $(lofar_root) $(aipspp) $(sockets) $(threads) $(sse) $(shmem) $(searchpath) $(python) --without-log4cxx lofar_root.var: