Changeset 7727


Ignore:
Timestamp:
Mar 9, 2010, 1:23:20 PM (14 years ago)
Author:
stud-florian
Message:

Added support for compiling without log4cxx. If log4cxx is not present, all logging is sent directly to stdout.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • m4/ax_log4cxx.m4

    r7726 r7727  
    1111# LAST MODIFICATION
    1212#
    13 #   2008-12-11
     13#   2010-03-09
    1414
    1515AC_DEFUN([AX_LOG4CXX],
     
    1717  AC_LANG_PUSH([C++])
    1818
    19   AC_CHECK_HEADERS([[log4cxx/logger.h]],,
    20     [AC_MSG_ERROR([Could not find log4cxx headers (http://logging.apache.org/log4cxx/index.html)])
    21   ])
     19  AC_CHECK_HEADERS([[log4cxx/logger.h]],
     20  [
    2221
    23   AC_MSG_CHECKING([log4cxx library files (version >=0.10.0)])
     22    AC_MSG_CHECKING([log4cxx library files (version >=0.10.0)])
    2423
    25   dnl Save old $LIBS to eventually restore it.
    26   ax_log4cxx_save_libs="$LIBS"
    27   LIBS="$LIBS -llog4cxx"
     24    dnl Save old $LIBS to eventually restore it.
     25    ax_log4cxx_save_libs="$LIBS"
     26    LIBS="$LIBS -llog4cxx"
    2827 
    29   AC_LINK_IFELSE([AC_LANG_PROGRAM(
    30     [[
    31 #include <log4cxx/logger.h>
    32 #include <log4cxx/basicconfigurator.h>
    33     ]], [
    34     log4cxx::BasicConfigurator::configure();
    35     log4cxx::LoggerPtr logger = log4cxx::Logger::getRootLogger();
    36     logger->setLevel(log4cxx::Level::getDebug());
    37     LOG4CXX_INFO(logger, "Simple message text.");])],
    38     dnl Success
    39     AC_MSG_RESULT(yes)
    40     [LIBS="-llog4cxx $LIBS"]
    41     AC_DEFINE(HAVE_LIBLOG4CXX, [1], "Define to 1 if you have log4cxx library installed")
    42     , dnl failed
    43     AC_MSG_RESULT(no)
    44     AC_MSG_FAILURE([[Could not find log4cxx library.
     28    AC_LINK_IFELSE([AC_LANG_PROGRAM(
     29      [[
     30        #include <log4cxx/logger.h>
     31        #include <log4cxx/basicconfigurator.h>
     32      ]], [
     33      log4cxx::BasicConfigurator::configure();
     34      log4cxx::LoggerPtr logger = log4cxx::Logger::getRootLogger();
     35      logger->setLevel(log4cxx::Level::getDebug());
     36      LOG4CXX_INFO(logger, "Simple message text.");])],
     37      dnl Success
     38      AC_MSG_RESULT(yes)
     39      [LIBS="-llog4cxx $LIBS"]
     40      AC_DEFINE(HAVE_LIBLOG4CXX, [1], "Define to 1 if you have log4cxx library installed")
     41      , dnl failed
     42      AC_MSG_RESULT(no)
     43      AC_MSG_ERROR([[Could not find log4cxx library.
    4544Version 0.10.0 or greater is required.
    4645(http://logging.apache.org/log4cxx/index.html)]])
    47     dnl restore old lib state
    48     LIBS="$ax_log4cxx_save_libs")
     46      dnl restore old lib state
     47      LIBS="$ax_log4cxx_save_libs")
    4948   
    50   AC_LANG_POP
     49    AC_LANG_POP
     50  ]
     51
     52  ,[AC_MSG_WARN([Could not find log4cxx headers (http://logging.apache.org/log4cxx/index.html), logging will be directly to STDOUT])])
     53
    5154])
  • source/ariba/utility/logging/Logging.h

    r6832 r7727  
    4242#include <iostream>
    4343#include <cstdlib>
     44
     45#ifdef HAVE_LOG4CXX_LOGGER_H
    4446#include <log4cxx/logger.h>
    4547#include <log4cxx/basicconfigurator.h>
    46 
     48#endif // HAVE_LOG4CXX_LOGGER_H
    4749
    4850#ifdef LOGCOLORS
     
    6466#endif // ENABLE_LOGCOLORS
    6567
    66 #define use_logging_h(x) \
    67         private: static log4cxx::LoggerPtr logger;
    6868
    69 #define use_logging_cpp(x) \
     69#ifdef HAVE_LOG4CXX_LOGGER_H
     70
     71  #define use_logging_h(x) \
     72        private: static log4cxx::LoggerPtr logger;
     73
     74  #define use_logging_cpp(x) \
    7075        log4cxx::LoggerPtr x::logger(log4cxx::Logger::getLogger(#x));
    7176
    72 #define logging_trace(x)  {            LOG4CXX_TRACE(logger,x);                         }
    73 #define logging_debug(x)  {colorDebug; LOG4CXX_DEBUG(logger,x); colorDefault;           }
    74 #define logging_info(x)   {colorInfo;  LOG4CXX_INFO(logger,x);  colorDefault;           }
    75 #define logging_warn(x)   {colorWarn;  LOG4CXX_WARN(logger,x);  colorDefault;           }
    76 #define logging_error(x)  {colorError; LOG4CXX_ERROR(logger,x); colorDefault;           }
    77 #define logging_fatal(x)  {colorError; LOG4CXX_FATAL(logger,x); colorDefault; exit(-1); }
     77  #define logging_trace(x)  {            LOG4CXX_TRACE(logger,x);                         }
     78  #define logging_debug(x)  {colorDebug; LOG4CXX_DEBUG(logger,x); colorDefault;           }
     79  #define logging_info(x)   {colorInfo;  LOG4CXX_INFO(logger,x);  colorDefault;           }
     80  #define logging_warn(x)   {colorWarn;  LOG4CXX_WARN(logger,x);  colorDefault;           }
     81  #define logging_error(x)  {colorError; LOG4CXX_ERROR(logger,x); colorDefault;           }
     82  #define logging_fatal(x)  {colorError; LOG4CXX_FATAL(logger,x); colorDefault; exit(-1); }
     83
     84#else // HAVE_LOG4CXX_LOGGER_H
     85
     86  #define use_logging_h(x)
     87
     88  #define use_logging_cpp(x)
     89
     90  #define logging_stdout(x) std::cout << x << std::endl;
     91
     92  #define logging_trace(x)
     93  #define logging_debug(x)  {colorDebug; logging_stdout(x); colorDefault;           }
     94  #define logging_info(x)   {colorInfo;  logging_stdout(x);  colorDefault;           }
     95  #define logging_warn(x)   {colorWarn;  logging_stdout(x);  colorDefault;           }
     96  #define logging_error(x)  {colorError; logging_stdout(x); colorDefault;           }
     97  #define logging_fatal(x)  {colorError; logging_stdout(x); colorDefault; exit(-1); }
     98
     99#endif // HAVE_LOG4CXX_LOGGER_H
    78100
    79101#endif //LOGGING_H__
  • source/ariba/utility/system/StartupWrapper.cpp

    r5993 r7727  
    3939#include "StartupWrapper.h"
    4040#include "ariba/config.h"
     41
     42#ifdef HAVE_LOG4CXX_LOGGER_H
     43#include <log4cxx/logger.h>
     44#include <log4cxx/basicconfigurator.h>
     45#endif // HAVE_LOG4CXX_LOGGER_H
    4146
    4247namespace ariba {
     
    9398        // configure the logging
    9499        //
    95 
     100       
     101#ifdef HAVE_LOG4CXX_LOGGER_H
    96102        log4cxx::BasicConfigurator::configure();
    97103
     
    109115        }
    110116#endif //HAVE_MAEMO
     117#endif //HAVE_LOG4CXX_LOGGER_H
    111118}
    112119
Note: See TracChangeset for help on using the changeset viewer.