diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5c504ca --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,46 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +PROJECT (CPPLOG) +SET (PROJECT_VERSION 0.1.0) + +INCLUDE(GNUInstallDirs) + +INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR}/include) +SET_TARGET_PROPERTIES (${PROJECT_EXECUTABLES} PROPERTIES LINKER_LANGUAGE CXX) + +# Find and use the system's Boost library +FIND_PACKAGE (Boost REQUIRED COMPONENTS system thread) +INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIR}) +LINK_DIRECTORIES (${Boost_LIBRARY_DIRS}) + +SET (CPPLOG_HEADERS + concurrent_queue.hpp + cpplog.hpp + outputdebugstream.hpp + scribestream.hpp +) + +ADD_DEFINITIONS (-DCPPLOG_THREADING -DCPPLOG_SYSTEM_IDS) + +OPTION (BUILD_TESTS "Build the test executables" OFF) + +IF (BUILD_TESTS) + ADD_EXECUTABLE(cpplog_test "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" ${CPPLOG_HEADERS}) + TARGET_LINK_LIBRARIES(cpplog_test ${Boost_LIBRARIES}) +ENDIF (BUILD_TESTS) + +# Install headers +INSTALL ( + FILES ${CPPLOG_HEADERS} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cpplog +) + +# Install pkg-config file +CONFIGURE_FILE ( + ${CMAKE_CURRENT_SOURCE_DIR}/cpplog.pc.cmake + ${CMAKE_CURRENT_BINARY_DIR}/cpplog.pc @ONLY +) +INSTALL ( + FILES ${CMAKE_BINARY_DIR}/cpplog.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig + COMPONENT pkgconfig +) diff --git a/README.txt b/README.md similarity index 70% rename from README.txt rename to README.md index ccd830f..421f24f 100644 --- a/README.txt +++ b/README.md @@ -1,15 +1,36 @@ +cpplog +====== + A simple, header-only, MIT-licensed C++ logging library. +The layout of this library is based on Google's logging library (http://code.google.com/p/google-glog/), but does not use any code copied from that project. + +## Installation + +```sh +git clone https://github.com/andrew-d/cpplog.git +cd cpplog +mkdir build && cd build +cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr +make && make install +``` + +Note: you can change `-DCMAKE_INSTALL_PREFIX=/usr` to any install prefix. + +## Usage + Basic usage example: +```cpp StdErrLogger log; LOG_WARN(log) << "Log message here" << std::endl; CHECK_EQUAL(log, 1 == 2) << "Some other message" << std::endl; CHECK_STREQ(log, "a", "a") << "Strings should be equal" << std::endl; +``` -The layout of this library is based on Google's logging library (http://code.google.com/p/google-glog/), but does not use any code copied from that project. +## Thanks -Thanks to GitHub's fakechris, there is experimental support for logging to a Scribe node (see: https://github.com/facebook/scribe for more information). It requires Apache Thrift (http://thrift.apache.org/). To use it, #define CPPLOG_WITH_SCRIBE_LOGGER +Thanks to GitHub's fakechris, there is experimental support for logging to a Scribe node (see: https://github.com/facebook/scribe for more information). It requires Apache Thrift (http://thrift.apache.org/). To use it, `#define CPPLOG_WITH_SCRIBE_LOGGER`. NOTE: Tests are relatively complete, but not exhaustive. Please use at your own risk, and feel free to submit bug reports. diff --git a/cpplog.pc.cmake b/cpplog.pc.cmake new file mode 100644 index 0000000..05f236c --- /dev/null +++ b/cpplog.pc.cmake @@ -0,0 +1,14 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@/cpplog +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@/cpplog + +Name: cpplog +Description: A simple, header-only, MIT-licensed C++ logging library. +URL: https://github.com/andrew-d/cpplog +Version: @PROJECT_VERSION@ +Requires: +Conflicts: +Libs: -L${libdir} -lrbdl -Wl,-rpath ${libdir} -lboost_thread-mt -lboost_system-mt +Libs.private: +Cflags: -I${includedir}