From 2dac7179b9aca9dd84811f9812c0f3f6f7450df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Mon, 11 May 2015 15:37:28 +0200 Subject: [PATCH] Add logging service --- juci/CMakeLists.txt | 3 ++- juci/logging.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 juci/logging.h diff --git a/juci/CMakeLists.txt b/juci/CMakeLists.txt index 625d06a..c98f47e 100644 --- a/juci/CMakeLists.txt +++ b/juci/CMakeLists.txt @@ -3,6 +3,7 @@ set(project_name juci) set(module juci_to_python_api) project (${project_name}) +add_definitions(-DBOOST_LOG_DYN_LINK) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/") @@ -52,7 +53,7 @@ endif() #Boost_INCLUDE_DIRS - Boost include directories #Boost_LIBRARY_DIRS - Link directories for Boost libraries #Boost_LIBRARIES - Boost component libraries to be linked -find_package(Boost 1.5 REQUIRED COMPONENTS python timer system filesystem) +find_package(Boost 1.55 COMPONENTS python thread log system filesystem REQUIRED) #If boost is not found if(${Boost_FOUND}) diff --git a/juci/logging.h b/juci/logging.h new file mode 100644 index 0000000..7046990 --- /dev/null +++ b/juci/logging.h @@ -0,0 +1,28 @@ +#ifndef JUCI_LOGGING_H_ +#define JUCI_LOGGING_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + + +using namespace boost::log; + +#define TRACE(x) BOOST_LOG_TRIVIAL(trace) << __func__ << "(" << __LINE__ << "): " << #x << "=<" << x << ">\n"; +#define DEBUG(x) BOOST_LOG_TRIVIAL(debug) << __func__ << "(" << __LINE__ << "): " << #x << "=<" << x << ">\n"; +#define INFO(x) BOOST_LOG_TRIVIAL(info) << __func__ << "(" << __LINE__ << "): " << #x << "=<" << x << ">\n"; +#define WARNING(x) BOOST_LOG_TRIVIAL(warning) << __func__ << "(" << __LINE__ << "): " << #x << "=<" << x << ">\n"; +#define ERROR(x) BOOST_LOG_TRIVIAL(error) << __func__ << "(" << __LINE__ << "): " << #x << "=<" << x << ">\n"; +#define FATAL(x) BOOST_LOG_TRIVIAL(fatal) << __func__ << "(" << __LINE__ << "): " << #x << "=<" << x << ">\n"; + +void init() { + add_file_log("juci.log"); +} + + +#endif // JUCI_LOGGING_H_