Commit 813e61d2 authored by Michael R. Crusoe's avatar Michael R. Crusoe 🏳️‍🌈
Browse files

New upstream version 1.3.0

parent d2aec18a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments:  true
SortIncludes:    true
SortIncludes:    false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
+1 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ script:
      -DCMAKE_CXX_STANDARD=$CPP \
      -DSPDLOG_BUILD_EXAMPLES=ON \
      -DSPDLOG_BUILD_BENCH=OFF \
      -DSPDLOG_BUILD_TESTS=ON \
      -DSPDLOG_SANITIZE_ADDRESS=$ASAN \
      -DSPDLOG_SANITIZE_THREAD=$TSAN
  - make VERBOSE=1 -j2
+23 −14
Original line number Diff line number Diff line
@@ -4,8 +4,7 @@
#

cmake_minimum_required(VERSION 3.1)
project(spdlog VERSION 1.2.0 LANGUAGES CXX)
include(CTest)
project(spdlog VERSION 1.3.0 LANGUAGES CXX)
include(CMakeDependentOption)
include(GNUInstallDirs)

@@ -53,11 +52,12 @@ endif()

option(SPDLOG_BUILD_EXAMPLES "Build examples" ${SPDLOG_MASTER_PROJECT})
option(SPDLOG_BUILD_BENCH "Build benchmarks" ${SPDLOG_MASTER_PROJECT})
option(SPDLOG_BUILD_TESTS "Build tests" ${SPDLOG_MASTER_PROJECT})
option(SPDLOG_FMT_EXTERNAL "Use external fmt library instead of bundled" OFF)

cmake_dependent_option(SPDLOG_BUILD_TESTING
    "Build spdlog tests" ${SPDLOG_MASTER_PROJECT}
    "BUILD_TESTING" OFF
)
if(SPDLOG_FMT_EXTERNAL)
    find_package(fmt REQUIRED CONFIG)
endif()

target_include_directories(
    spdlog
@@ -66,13 +66,19 @@ target_include_directories(
    "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)

if(SPDLOG_FMT_EXTERNAL)
    target_compile_definitions(spdlog INTERFACE SPDLOG_FMT_EXTERNAL)
    target_link_libraries(spdlog INTERFACE fmt::fmt)
endif()

set(HEADER_BASE "${CMAKE_CURRENT_SOURCE_DIR}/include")

if(SPDLOG_BUILD_EXAMPLES)
    add_subdirectory(example)
endif()

if(SPDLOG_BUILD_TESTING)
if(SPDLOG_BUILD_TESTS)
    include(CTest)
    add_subdirectory(tests)
endif()

@@ -88,7 +94,8 @@ 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(project_config "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake")
set(targets_config "${PROJECT_NAME}Targets.cmake")
set(pkg_config "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc")
set(targets_export_name "${PROJECT_NAME}Targets")
set(namespace "${PROJECT_NAME}::")
@@ -101,6 +108,8 @@ write_basic_package_version_file(

# configure pkg config file
configure_file("cmake/spdlog.pc.in" "${pkg_config}" @ONLY)
# configure spdlogConfig.cmake file
configure_file("cmake/Config.cmake.in" "${project_config}" @ONLY)

# install targets
install(
@@ -114,9 +123,9 @@ install(
    DESTINATION "${include_install_dir}"
)

# install project version file
# install project config and version file
install(
    FILES "${version_config}"
    FILES "${project_config}" "${version_config}"
    DESTINATION "${config_install_dir}"
)

@@ -126,19 +135,19 @@ install(
    DESTINATION "${pkgconfig_install_dir}"
)

# install project config file
# install targets config file
install(
    EXPORT "${targets_export_name}"
    NAMESPACE "${namespace}"
    DESTINATION "${config_install_dir}"
    FILE ${project_config}
    FILE ${targets_config}
)

# export build directory config file
# export build directory targets file
export(
    EXPORT ${targets_export_name}
    NAMESPACE "${namespace}"
    FILE ${project_config}
    FILE ${targets_config}
)

# register project in CMake user registry
+31 −30
Original line number Diff line number Diff line
@@ -77,42 +77,43 @@ async... Elapsed: 0.349851 2,858,358/sec

## Usage samples

#### Basic usage
```c++
#include "spdlog/spdlog.h"
#include "spdlog/sinks/stdout_color_sinks.h"
void stdout_example()
int main() 
{
    // create color multi threaded logger
    auto console = spdlog::stdout_color_mt("console");
    console->info("Welcome to spdlog!");
    console->error("Some error message with arg: {}", 1);

    auto err_logger = spdlog::stderr_color_mt("stderr");
    err_logger->error("Some error 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);
    console->info("Support for floats {:03.2f}", 1.23456);
    console->info("Positional args are {1} {0}..", "too", "supported");
    console->info("{:<30}", "left aligned");
    spdlog::info("Welcome to spdlog!");
    spdlog::error("Some error message with arg: {}", 1);
    
    spdlog::get("console")->info("loggers can be retrieved from a global registry using the spdlog::get(logger_name)");
    spdlog::warn("Easy padding in numbers like {:08d}", 12);
    spdlog::critical("Support for int: {0:d};  hex: {0:x};  oct: {0:o}; bin: {0:b}", 42);
    spdlog::info("Support for floats {:03.2f}", 1.23456);
    spdlog::info("Positional args are {1} {0}..", "too", "supported");
    spdlog::info("{:<30}", "left aligned");
    
    // Runtime log levels
    spdlog::set_level(spdlog::level::info); // Set global log level to info
    console->debug("This message should not be displayed!");
    console->set_level(spdlog::level::trace); // Set specific logger's log level
    console->debug("This message should be displayed..");
    spdlog::set_level(spdlog::level::debug/ Set global log level to debug
    spdlog::debug("This message should be displayed..");    
    
    // Customize msg format for all loggers
    // change log pattern
    spdlog::set_pattern("[%H:%M:%S %z] [%n] [%^---%L---%$] [thread %t] %v");
    console->info("This an info message with custom format");
    
    // Compile time log levels
    // define SPDLOG_DEBUG_ON or SPDLOG_TRACE_ON
    SPDLOG_TRACE(console, "Enabled only #ifdef SPDLOG_TRACE_ON..{} ,{}", 1, 3.23);
    SPDLOG_DEBUG(console, "Enabled only #ifdef SPDLOG_DEBUG_ON.. {} ,{}", 1, 3.23);
    // define SPDLOG_ACTIVE_LEVEL to desired level
    SPDLOG_TRACE("Some trace message with param {}", {});
    SPDLOG_DEBUG("Some debug message");
        
}
```
#### create stdout/stderr logger object
```c++
#include "spdlog/spdlog.h"
#include "spdlog/sinks/stdout_color_sinks.h"
void stdout_example()
{
    // create color multi threaded logger
    auto console = spdlog::stdout_color_mt("console");    
    auto err_logger = spdlog::stderr_color_mt("stderr");    
    spdlog::get("console")->info("loggers can be retrieved from a global registry using the spdlog::get(logger_name)");
}
```
---
@@ -305,7 +306,7 @@ void syslog_example()
---
#### Android example 
```c++
#incude "spdlog/sinks/android_sink.h"
#include "spdlog/sinks/android_sink.h"
void android_example()
{
    std::string tag = "spdlog-android";
+4 −2
Original line number Diff line number Diff line
@@ -26,7 +26,9 @@ build_script:

    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 .. -G %GENERATOR% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DSPDLOG_BUILD_BENCH=OFF

    cmake --build . --config %BUILD_TYPE%
test: off

test_script:
- ctest -VV -C "%BUILD_TYPE%"
Loading