Add option to enable json logging

This commit is contained in:
Patrick Niklaus 2015-03-23 00:28:38 +01:00
parent a372ade7ce
commit f89f4bd20b
2 changed files with 18 additions and 3 deletions

View File

@ -27,6 +27,7 @@ if(WIN32 AND MSVC_VERSION LESS 1800)
message(FATAL_ERROR "Building with Microsoft compiler needs Visual Studio 2013 or later (Express version works too)")
endif()
option(ENABLE_JSON_LOGGING "Adds additional JSON debug logging to the response" OFF)
option(WITH_TOOLS "Build OSRM tools" OFF)
option(BUILD_TOOLS "Build OSRM tools" OFF)
@ -298,6 +299,11 @@ include_directories(${ZLIB_INCLUDE_DIRS})
target_link_libraries(osrm-extract ${ZLIB_LIBRARY})
target_link_libraries(osrm-routed ${ZLIB_LIBRARY})
if (ENABLE_JSON_LOGGING)
message(STATUS "Enabling json logging")
add_definitions(-DENABLE_JSON_LOGGING)
endif()
if(WITH_TOOLS OR BUILD_TOOLS)
message(STATUS "Activating OSRM internal tools")
find_package(GDAL)

View File

@ -48,11 +48,20 @@ class Logger
{
static Logger logger;
bool return_logger = true;
#ifdef NDEBUG
return nullptr;
#else
return &logger;
return_logger = false;
#endif
#ifdef ENABLE_JSON_LOGGING
return_logger = true;
#endif
if (return_logger)
{
return &logger;
}
return nullptr;
}
void initialize(const std::string& name)