Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
25 changes: 23 additions & 2 deletions README.txt → README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
14 changes: 14 additions & 0 deletions cpplog.pc.cmake
Original file line number Diff line number Diff line change
@@ -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}