Loading .gitignore +4 −1 Original line number Diff line number Diff line Loading @@ -61,4 +61,7 @@ install_manifest.txt /tests/tests.VC.VC.opendb /tests/tests.VC.db /tests/tests /tests/logs/file_helper_test.txt /tests/logs/* # idea .idea/ No newline at end of file .travis.yml +1 −0 Original line number Diff line number Diff line Loading @@ -85,6 +85,7 @@ script: - ./"${BIN}" - valgrind --trace-children=yes --leak-check=full ./"${BIN}" - cd $CHECKOUT_PATH/tests; make rebuild; ./tests - cd $CHECKOUT_PATH/tests; STYLE=printf make rebuild; ./tests notifications: email: false CMakeLists.txt +116 −87 Original line number Diff line number Diff line Loading @@ -4,9 +4,14 @@ # cmake_minimum_required(VERSION 3.1) project(spdlog VERSION 1.0.0) project(spdlog VERSION 0.16.2) include(CTest) include(CMakeDependentOption) include(GNUInstallDirs) #--------------------------------------------------------------------------------------- # compiler config #--------------------------------------------------------------------------------------- set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) Loading @@ -14,16 +19,22 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCH set(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS}") endif() #--------------------------------------------------------------------------------------- # spdlog target #--------------------------------------------------------------------------------------- add_library(spdlog INTERFACE) option(SPDLOG_BUILD_EXAMPLES "Build examples" OFF) option(SPDLOG_BUILD_TESTING "Build spdlog tests" ON) cmake_dependent_option(SPDLOG_BUILD_TESTING "Build spdlog tests" ON "BUILD_TESTING" OFF ) target_include_directories( spdlog INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>" "$<INSTALL_INTERFACE:include>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" ) set(HEADER_BASE "${CMAKE_CURRENT_SOURCE_DIR}/include") Loading @@ -36,52 +47,70 @@ if(SPDLOG_BUILD_TESTING) add_subdirectory(tests) endif() ### Install ### # * https://github.com/forexample/package-example set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") set(config_install_dir "lib/cmake/${PROJECT_NAME}") set(include_install_dir "include") set(pkgconfig_install_dir "lib/pkgconfig") set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") set(pkg_config "${generated_dir}/${PROJECT_NAME}.pc") #--------------------------------------------------------------------------------------- # Install/export targets and files #--------------------------------------------------------------------------------------- # set files and directories set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") set(include_install_dir "${CMAKE_INSTALL_INCLUDEDIR}") set(pkgconfig_install_dir "${CMAKE_INSTALL_LIBDIR}/pkgconfig") set(version_config "${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake") set(project_config "${PROJECT_NAME}Config.cmake") set(pkg_config "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc") set(targets_export_name "${PROJECT_NAME}Targets") set(namespace "${PROJECT_NAME}::") # generate package version file include(CMakePackageConfigHelpers) write_basic_package_version_file( "${version_config}" COMPATIBILITY SameMajorVersion ) # Note: use 'targets_export_name' configure_file("cmake/Config.cmake.in" "${project_config}" @ONLY) # configure pkg config file configure_file("cmake/spdlog.pc.in" "${pkg_config}" @ONLY) # install targets install( TARGETS spdlog EXPORT "${targets_export_name}" INCLUDES DESTINATION "${include_install_dir}" ) install(DIRECTORY "include/spdlog" DESTINATION "${include_install_dir}") # install headers install( DIRECTORY "${HEADER_BASE}/${PROJECT_NAME}" DESTINATION "${include_install_dir}" ) # install project version file install( FILES "${project_config}" "${version_config}" FILES "${version_config}" DESTINATION "${config_install_dir}" ) # install pkg config file install( FILES "${pkg_config}" DESTINATION "${pkgconfig_install_dir}" ) # install project config file install( EXPORT "${targets_export_name}" NAMESPACE "${namespace}" DESTINATION "${config_install_dir}" FILE ${project_config} ) # export build directory config file export( EXPORT ${targets_export_name} NAMESPACE "${namespace}" FILE ${project_config} ) # register project in CMake user registry export(PACKAGE ${PROJECT_NAME}) file(GLOB_RECURSE spdlog_include_SRCS "${HEADER_BASE}/*.h") add_custom_target(spdlog_headers_for_ide SOURCES ${spdlog_include_SRCS}) README.md +11 −14 Original line number Diff line number Diff line Loading @@ -8,20 +8,20 @@ Very fast, header only, C++ logging library. [ to your build tree and use a C++11 compiler. #### Or use your favourite package manager: #### Or use your favorite package manager: * Ubuntu: `apt-get install libspdlog-dev` * Homebrew: `brew install spdlog` * FreeBSD: `cd /usr/ports/devel/spdlog/ && make install clean` * Fedora: `yum install spdlog` * Gentoo: `emerge dev-libs/spdlog` * Arch Linux: `pacman -S spdlog-git` * Arch Linux: `yaourt -S spdlog-git` * vcpkg: `vcpkg install spdlog` ## Platforms * Linux, FreeBSD, Solaris * Windows (vc 2013+, cygwin/mingw) * Windows (vc 2013+, cygwin) * Mac OSX (clang 3.5+) * Android Loading @@ -29,6 +29,7 @@ Very fast, header only, C++ logging library. [ below). * Headers only, just copy and use. * Feature rich [call style](#usage-example) using the excellent [fmt](https://github.com/fmtlib/fmt) library. * Optional printf syntax support. * Extremely fast asynchronous mode (optional) - using lockfree queues and other tricks to reach millions of calls/sec. * [Custom](https://github.com/gabime/spdlog/wiki/3.-Custom-formatting) formatting. * Conditional Logging Loading Loading @@ -93,10 +94,6 @@ int main(int, char*[]) console->info("Welcome to spdlog!"); console->error("Some error message with arg{}..", 1); // Conditional logging example auto i = 2; console->warn_if(i != 0, "an important message"); // Formatting examples console->warn("Easy padding in numbers like {:08d}", 12); console->critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42); Loading @@ -104,7 +101,7 @@ int main(int, char*[]) console->info("Positional args are {1} {0}..", "too", "supported"); console->info("{:<30}", "left aligned"); // Use global registry to retrieve loggers spd::get("console")->info("loggers can be retrieved from a global registry using the spdlog::get(logger_name) function"); // Create basic file logger (not rotated) Loading @@ -112,12 +109,12 @@ int main(int, char*[]) my_logger->info("Some log message"); // Create a file rotating logger with 5mb size max and 3 rotated files auto rotating_logger = spd::rotating_logger_mt("some_logger_name", "logs/mylogfile", 1048576 * 5, 3); auto rotating_logger = spd::rotating_logger_mt("some_logger_name", "logs/mylogfile.txt", 1048576 * 5, 3); for (int i = 0; i < 10; ++i) rotating_logger->info("{} * {} equals {:>10}", i, i, i*i); // Create a daily logger - a new file is created every day on 2:30am auto daily_logger = spd::daily_logger_mt("daily_logger", "logs/daily", 2, 30); auto daily_logger = spd::daily_logger_mt("daily_logger", "logs/daily.txt", 2, 30); // trigger flush if the log severity is error or higher daily_logger->flush_on(spd::level::err); daily_logger->info(123.44); Loading @@ -129,9 +126,9 @@ int main(int, char*[]) // Runtime log levels spd::set_level(spd::level::info); //Set global log level to info console->debug("This message shold not be displayed!"); console->debug("This message should not be displayed!"); console->set_level(spd::level::debug); // Set specific logger's log level console->debug("This message shold be displayed.."); console->debug("This message should be displayed.."); // Compile time log levels // define SPDLOG_DEBUG_ON or SPDLOG_TRACE_ON Loading appveyor.yml 0 → 100644 +32 −0 Original line number Diff line number Diff line version: 1.0.{build} image: Visual Studio 2015 environment: matrix: - GENERATOR: '"MinGW Makefiles"' BUILD_TYPE: Debug - GENERATOR: '"MinGW Makefiles"' BUILD_TYPE: Release - GENERATOR: '"Visual Studio 14 2015"' BUILD_TYPE: Debug - GENERATOR: '"Visual Studio 14 2015"' BUILD_TYPE: Release - GENERATOR: '"Visual Studio 14 2015 Win64"' BUILD_TYPE: Debug - GENERATOR: '"Visual Studio 14 2015 Win64"' BUILD_TYPE: Release build_script: - cmd: >- set mkdir build cd build set PATH=%PATH:C:\Program Files\Git\usr\bin;=% set PATH=C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin;%PATH% cmake .. -G %GENERATOR% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% cmake --build . --config %BUILD_TYPE% test: off Loading
.gitignore +4 −1 Original line number Diff line number Diff line Loading @@ -61,4 +61,7 @@ install_manifest.txt /tests/tests.VC.VC.opendb /tests/tests.VC.db /tests/tests /tests/logs/file_helper_test.txt /tests/logs/* # idea .idea/ No newline at end of file
.travis.yml +1 −0 Original line number Diff line number Diff line Loading @@ -85,6 +85,7 @@ script: - ./"${BIN}" - valgrind --trace-children=yes --leak-check=full ./"${BIN}" - cd $CHECKOUT_PATH/tests; make rebuild; ./tests - cd $CHECKOUT_PATH/tests; STYLE=printf make rebuild; ./tests notifications: email: false
CMakeLists.txt +116 −87 Original line number Diff line number Diff line Loading @@ -4,9 +4,14 @@ # cmake_minimum_required(VERSION 3.1) project(spdlog VERSION 1.0.0) project(spdlog VERSION 0.16.2) include(CTest) include(CMakeDependentOption) include(GNUInstallDirs) #--------------------------------------------------------------------------------------- # compiler config #--------------------------------------------------------------------------------------- set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) Loading @@ -14,16 +19,22 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCH set(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS}") endif() #--------------------------------------------------------------------------------------- # spdlog target #--------------------------------------------------------------------------------------- add_library(spdlog INTERFACE) option(SPDLOG_BUILD_EXAMPLES "Build examples" OFF) option(SPDLOG_BUILD_TESTING "Build spdlog tests" ON) cmake_dependent_option(SPDLOG_BUILD_TESTING "Build spdlog tests" ON "BUILD_TESTING" OFF ) target_include_directories( spdlog INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>" "$<INSTALL_INTERFACE:include>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" ) set(HEADER_BASE "${CMAKE_CURRENT_SOURCE_DIR}/include") Loading @@ -36,52 +47,70 @@ if(SPDLOG_BUILD_TESTING) add_subdirectory(tests) endif() ### Install ### # * https://github.com/forexample/package-example set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") set(config_install_dir "lib/cmake/${PROJECT_NAME}") set(include_install_dir "include") set(pkgconfig_install_dir "lib/pkgconfig") set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") set(pkg_config "${generated_dir}/${PROJECT_NAME}.pc") #--------------------------------------------------------------------------------------- # Install/export targets and files #--------------------------------------------------------------------------------------- # set files and directories set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") set(include_install_dir "${CMAKE_INSTALL_INCLUDEDIR}") set(pkgconfig_install_dir "${CMAKE_INSTALL_LIBDIR}/pkgconfig") set(version_config "${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake") set(project_config "${PROJECT_NAME}Config.cmake") set(pkg_config "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc") set(targets_export_name "${PROJECT_NAME}Targets") set(namespace "${PROJECT_NAME}::") # generate package version file include(CMakePackageConfigHelpers) write_basic_package_version_file( "${version_config}" COMPATIBILITY SameMajorVersion ) # Note: use 'targets_export_name' configure_file("cmake/Config.cmake.in" "${project_config}" @ONLY) # configure pkg config file configure_file("cmake/spdlog.pc.in" "${pkg_config}" @ONLY) # install targets install( TARGETS spdlog EXPORT "${targets_export_name}" INCLUDES DESTINATION "${include_install_dir}" ) install(DIRECTORY "include/spdlog" DESTINATION "${include_install_dir}") # install headers install( DIRECTORY "${HEADER_BASE}/${PROJECT_NAME}" DESTINATION "${include_install_dir}" ) # install project version file install( FILES "${project_config}" "${version_config}" FILES "${version_config}" DESTINATION "${config_install_dir}" ) # install pkg config file install( FILES "${pkg_config}" DESTINATION "${pkgconfig_install_dir}" ) # install project config file install( EXPORT "${targets_export_name}" NAMESPACE "${namespace}" DESTINATION "${config_install_dir}" FILE ${project_config} ) # export build directory config file export( EXPORT ${targets_export_name} NAMESPACE "${namespace}" FILE ${project_config} ) # register project in CMake user registry export(PACKAGE ${PROJECT_NAME}) file(GLOB_RECURSE spdlog_include_SRCS "${HEADER_BASE}/*.h") add_custom_target(spdlog_headers_for_ide SOURCES ${spdlog_include_SRCS})
README.md +11 −14 Original line number Diff line number Diff line Loading @@ -8,20 +8,20 @@ Very fast, header only, C++ logging library. [ to your build tree and use a C++11 compiler. #### Or use your favourite package manager: #### Or use your favorite package manager: * Ubuntu: `apt-get install libspdlog-dev` * Homebrew: `brew install spdlog` * FreeBSD: `cd /usr/ports/devel/spdlog/ && make install clean` * Fedora: `yum install spdlog` * Gentoo: `emerge dev-libs/spdlog` * Arch Linux: `pacman -S spdlog-git` * Arch Linux: `yaourt -S spdlog-git` * vcpkg: `vcpkg install spdlog` ## Platforms * Linux, FreeBSD, Solaris * Windows (vc 2013+, cygwin/mingw) * Windows (vc 2013+, cygwin) * Mac OSX (clang 3.5+) * Android Loading @@ -29,6 +29,7 @@ Very fast, header only, C++ logging library. [ below). * Headers only, just copy and use. * Feature rich [call style](#usage-example) using the excellent [fmt](https://github.com/fmtlib/fmt) library. * Optional printf syntax support. * Extremely fast asynchronous mode (optional) - using lockfree queues and other tricks to reach millions of calls/sec. * [Custom](https://github.com/gabime/spdlog/wiki/3.-Custom-formatting) formatting. * Conditional Logging Loading Loading @@ -93,10 +94,6 @@ int main(int, char*[]) console->info("Welcome to spdlog!"); console->error("Some error message with arg{}..", 1); // Conditional logging example auto i = 2; console->warn_if(i != 0, "an important message"); // Formatting examples console->warn("Easy padding in numbers like {:08d}", 12); console->critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42); Loading @@ -104,7 +101,7 @@ int main(int, char*[]) console->info("Positional args are {1} {0}..", "too", "supported"); console->info("{:<30}", "left aligned"); // Use global registry to retrieve loggers spd::get("console")->info("loggers can be retrieved from a global registry using the spdlog::get(logger_name) function"); // Create basic file logger (not rotated) Loading @@ -112,12 +109,12 @@ int main(int, char*[]) my_logger->info("Some log message"); // Create a file rotating logger with 5mb size max and 3 rotated files auto rotating_logger = spd::rotating_logger_mt("some_logger_name", "logs/mylogfile", 1048576 * 5, 3); auto rotating_logger = spd::rotating_logger_mt("some_logger_name", "logs/mylogfile.txt", 1048576 * 5, 3); for (int i = 0; i < 10; ++i) rotating_logger->info("{} * {} equals {:>10}", i, i, i*i); // Create a daily logger - a new file is created every day on 2:30am auto daily_logger = spd::daily_logger_mt("daily_logger", "logs/daily", 2, 30); auto daily_logger = spd::daily_logger_mt("daily_logger", "logs/daily.txt", 2, 30); // trigger flush if the log severity is error or higher daily_logger->flush_on(spd::level::err); daily_logger->info(123.44); Loading @@ -129,9 +126,9 @@ int main(int, char*[]) // Runtime log levels spd::set_level(spd::level::info); //Set global log level to info console->debug("This message shold not be displayed!"); console->debug("This message should not be displayed!"); console->set_level(spd::level::debug); // Set specific logger's log level console->debug("This message shold be displayed.."); console->debug("This message should be displayed.."); // Compile time log levels // define SPDLOG_DEBUG_ON or SPDLOG_TRACE_ON Loading
appveyor.yml 0 → 100644 +32 −0 Original line number Diff line number Diff line version: 1.0.{build} image: Visual Studio 2015 environment: matrix: - GENERATOR: '"MinGW Makefiles"' BUILD_TYPE: Debug - GENERATOR: '"MinGW Makefiles"' BUILD_TYPE: Release - GENERATOR: '"Visual Studio 14 2015"' BUILD_TYPE: Debug - GENERATOR: '"Visual Studio 14 2015"' BUILD_TYPE: Release - GENERATOR: '"Visual Studio 14 2015 Win64"' BUILD_TYPE: Debug - GENERATOR: '"Visual Studio 14 2015 Win64"' BUILD_TYPE: Release build_script: - cmd: >- set mkdir build cd build set PATH=%PATH:C:\Program Files\Git\usr\bin;=% set PATH=C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin;%PATH% cmake .. -G %GENERATOR% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% cmake --build . --config %BUILD_TYPE% test: off