Skip to content

Commit

Permalink
make PROPOSAL run for IceSim
Browse files Browse the repository at this point in the history
  • Loading branch information
sudojan committed Sep 14, 2018
1 parent 84cc668 commit f290848
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 64 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ IF(I3_PROJECTS)
add_definitions(-DICECUBE_PROJECT)
include(cmake/I3_CMakeLists.cmake)
ELSE(I3_PROJECTS)
add_definitions(-DPROPOSAL_STANDALONE)
include(cmake/Standalone_CMakeLists.cmake)
ENDIF(I3_PROJECTS)

Expand Down
128 changes: 64 additions & 64 deletions public/PROPOSAL/Output.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,71 +46,71 @@
#include "TTree.h"
#endif

#if I3_PROJECTS
#include <icetray/I3Logging.h>
#if not PROPOSAL_STANDALONE
#include <icetray/I3Logging.h>
#else
#if LOG4CPLUS_SUPPORT
// Stuff for LOG4CPLUS
#include <boost/preprocessor/array/elem.hpp>
#include <boost/preprocessor/comparison/equal.hpp>
#include <boost/preprocessor/comparison/less.hpp>
#include <boost/preprocessor/config/limits.hpp>
#include <boost/preprocessor/control/if.hpp>
#include <log4cplus/configurator.h>
#include <log4cplus/logger.h>
#include <log4cplus/loggingmacros.h>

#define VA_COUNT(...) VA_COUNT0(__VA_ARGS__, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
#define VA_COUNT0(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, N, ...) N
#define VA_ARG(_i, ...) BOOST_PP_ARRAY_ELEM(_i, (VA_COUNT(__VA_ARGS__), (__VA_ARGS__)))

#define log_error(...) \
BOOST_PP_IF(BOOST_PP_EQUAL(1, VA_COUNT(__VA_ARGS__)), \
LOG4CPLUS_ERROR(Output::getInstance().logger, VA_ARG(0, __VA_ARGS__)), \
LOG4CPLUS_ERROR_FMT(Output::getInstance().logger, __VA_ARGS__))

#define log_fatal(...) \
BOOST_PP_IF(BOOST_PP_EQUAL(1, VA_COUNT(__VA_ARGS__)), \
LOG4CPLUS_FATAL(Output::getInstance().logger, VA_ARG(0, __VA_ARGS__)); \
exit(1), LOG4CPLUS_FATAL_FMT(Output::getInstance().logger, __VA_ARGS__)); \
exit(1)

#define log_warn(...) \
BOOST_PP_IF(BOOST_PP_EQUAL(1, VA_COUNT(__VA_ARGS__)), \
LOG4CPLUS_WARN(Output::getInstance().logger, VA_ARG(0, __VA_ARGS__)), \
LOG4CPLUS_WARN_FMT(Output::getInstance().logger, __VA_ARGS__))

#define log_info(...) \
BOOST_PP_IF(BOOST_PP_EQUAL(1, VA_COUNT(__VA_ARGS__)), \
LOG4CPLUS_INFO(Output::getInstance().logger, VA_ARG(0, __VA_ARGS__)), \
LOG4CPLUS_INFO_FMT(Output::getInstance().logger, __VA_ARGS__))

#define log_trace(...) \
BOOST_PP_IF(BOOST_PP_EQUAL(1, VA_COUNT(__VA_ARGS__)), \
LOG4CPLUS_TRACE(Output::getInstance().logger, VA_ARG(0, __VA_ARGS__)), \
LOG4CPLUS_TRACE_FMT(Output::getInstance().logger, __VA_ARGS__))

#define log_debug(...) \
BOOST_PP_IF(BOOST_PP_EQUAL(1, VA_COUNT(__VA_ARGS__)), \
LOG4CPLUS_DEBUG(Output::getInstance().logger, VA_ARG(0, __VA_ARGS__)), \
LOG4CPLUS_DEBUG_FMT(Output::getInstance().logger, __VA_ARGS__))

#define log_notice(...) \
BOOST_PP_IF(BOOST_PP_EQUAL(1, VA_COUNT(__VA_ARGS__)), \
LOG4CPLUS_NOTICE(Output::getInstance().logger, VA_ARG(0, __VA_ARGS__)), \
LOG4CPLUS_NOTICE_FMT(Output::getInstance().logger, __VA_ARGS__))

#else
#ifndef log_error
#define log_error(fmt, ...) (void)0
#define log_fatal(fmt, ...) (void)0
#define log_warn(fmt, ...) (void)0
#define log_info(fmt, ...) (void)0
#define log_trace(fmt, ...) (void)0
#define log_debug(fmt, ...) (void)0
#define log_notice(fmt, ...) (void)0
#endif
#endif
#if LOG4CPLUS_SUPPORT
// Stuff for LOG4CPLUS
#include <boost/preprocessor/array/elem.hpp>
#include <boost/preprocessor/comparison/equal.hpp>
#include <boost/preprocessor/comparison/less.hpp>
#include <boost/preprocessor/config/limits.hpp>
#include <boost/preprocessor/control/if.hpp>
#include <log4cplus/configurator.h>
#include <log4cplus/logger.h>
#include <log4cplus/loggingmacros.h>

#define VA_COUNT(...) VA_COUNT0(__VA_ARGS__, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
#define VA_COUNT0(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, N, ...) N
#define VA_ARG(_i, ...) BOOST_PP_ARRAY_ELEM(_i, (VA_COUNT(__VA_ARGS__), (__VA_ARGS__)))

#define log_error(...) \
BOOST_PP_IF(BOOST_PP_EQUAL(1, VA_COUNT(__VA_ARGS__)), \
LOG4CPLUS_ERROR(Output::getInstance().logger, VA_ARG(0, __VA_ARGS__)), \
LOG4CPLUS_ERROR_FMT(Output::getInstance().logger, __VA_ARGS__))

#define log_fatal(...) \
BOOST_PP_IF(BOOST_PP_EQUAL(1, VA_COUNT(__VA_ARGS__)), \
LOG4CPLUS_FATAL(Output::getInstance().logger, VA_ARG(0, __VA_ARGS__)); \
exit(1), LOG4CPLUS_FATAL_FMT(Output::getInstance().logger, __VA_ARGS__)); \
exit(1)

#define log_warn(...) \
BOOST_PP_IF(BOOST_PP_EQUAL(1, VA_COUNT(__VA_ARGS__)), \
LOG4CPLUS_WARN(Output::getInstance().logger, VA_ARG(0, __VA_ARGS__)), \
LOG4CPLUS_WARN_FMT(Output::getInstance().logger, __VA_ARGS__))

#define log_info(...) \
BOOST_PP_IF(BOOST_PP_EQUAL(1, VA_COUNT(__VA_ARGS__)), \
LOG4CPLUS_INFO(Output::getInstance().logger, VA_ARG(0, __VA_ARGS__)), \
LOG4CPLUS_INFO_FMT(Output::getInstance().logger, __VA_ARGS__))

#define log_trace(...) \
BOOST_PP_IF(BOOST_PP_EQUAL(1, VA_COUNT(__VA_ARGS__)), \
LOG4CPLUS_TRACE(Output::getInstance().logger, VA_ARG(0, __VA_ARGS__)), \
LOG4CPLUS_TRACE_FMT(Output::getInstance().logger, __VA_ARGS__))

#define log_debug(...) \
BOOST_PP_IF(BOOST_PP_EQUAL(1, VA_COUNT(__VA_ARGS__)), \
LOG4CPLUS_DEBUG(Output::getInstance().logger, VA_ARG(0, __VA_ARGS__)), \
LOG4CPLUS_DEBUG_FMT(Output::getInstance().logger, __VA_ARGS__))

#define log_notice(...) \
BOOST_PP_IF(BOOST_PP_EQUAL(1, VA_COUNT(__VA_ARGS__)), \
LOG4CPLUS_NOTICE(Output::getInstance().logger, VA_ARG(0, __VA_ARGS__)), \
LOG4CPLUS_NOTICE_FMT(Output::getInstance().logger, __VA_ARGS__))

#else
#ifndef log_error
#define log_error(fmt, ...) (void)0
#define log_fatal(fmt, ...) (void)0
#define log_warn(fmt, ...) (void)0
#define log_info(fmt, ...) (void)0
#define log_trace(fmt, ...) (void)0
#define log_debug(fmt, ...) (void)0
#define log_notice(fmt, ...) (void)0
#endif
#endif
#endif

namespace PROPOSAL {
Expand Down

0 comments on commit f290848

Please sign in to comment.