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

New upstream version 1.2.0

parent 1b70788c
Loading
Loading
Loading
Loading

.clang-tidy

0 → 100644
+28 −0
Original line number Diff line number Diff line
Checks: 'modernize-*,modernize-use-override,google-*,-google-runtime-references,misc-*,clang-analyzer-*'
WarningsAsErrors: ''
HeaderFilterRegex: 'async.h|async_logger.h|common.h|details|formatter.h|logger.h|sinks|spdlog.h|tweakme.h|version.h'
AnalyzeTemporaryDtors: false
FormatStyle:     none

CheckOptions:    
  - key:             google-readability-braces-around-statements.ShortStatementLines
    value:           '1'
  - key:             google-readability-function-size.StatementThreshold
    value:           '800'
  - key:             google-readability-namespace-comments.ShortNamespaceLines
    value:           '10'
  - key:             google-readability-namespace-comments.SpacesBeforeComments
    value:           '2'
  - key:             modernize-loop-convert.MaxCopySize
    value:           '16'
  - key:             modernize-loop-convert.MinConfidence
    value:           reasonable
  - key:             modernize-loop-convert.NamingStyle
    value:           CamelCase
  - key:             modernize-pass-by-value.IncludeStyle
    value:           llvm
  - key:             modernize-replace-auto-ptr.IncludeStyle
    value:           llvm
  - key:             modernize-use-nullptr.NullMacros
    value:           'NULL'
+8 −6
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ addons: &gcc48
  apt:
    packages:
      - g++-4.8
      - valgrind
    sources:
      - ubuntu-toolchain-r-test

@@ -17,7 +16,6 @@ addons: &gcc7
  apt:
    packages:
      - g++-7
      - valgrind
    sources:
      - ubuntu-toolchain-r-test

@@ -25,7 +23,6 @@ addons: &clang35
  apt:
    packages:
      - clang-3.5
      - valgrind
    sources:
      - ubuntu-toolchain-r-test
      - llvm-toolchain-precise-3.5
@@ -34,11 +31,11 @@ addons: &clang6
  apt:
    packages:
      - clang-6.0
      - valgrind
    sources:
      - ubuntu-toolchain-r-test
      - llvm-toolchain-trusty-6.0


matrix:
  include:
    # Test gcc-4.8: C++11, Build=Debug/Release
@@ -81,16 +78,21 @@ matrix:
      os: linux
      addons: *clang6

      # osx
    - env: BUILD_TYPE=Release CPP=11 ASAN=Off TSAN=Off
      os: osx
    



before_script:
  - if [ -n "$GCC_VERSION" ]; then export CXX="g++-${GCC_VERSION}" CC="gcc-${GCC_VERSION}"; fi
  - if [ -n "$CLANG_VERSION" ]; then export CXX="clang++-${CLANG_VERSION}" CC="clang-${CLANG_VERSION}"; fi
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export CXX="clang++" CC="clang"; fi
  - which $CXX
  - which $CC
  - which valgrind
  - $CXX --version
  - cmake --version
  - valgrind --version

script:
  - cd ${TRAVIS_BUILD_DIR}
+13 −4
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
#

cmake_minimum_required(VERSION 3.1)
project(spdlog VERSION 1.1.0 LANGUAGES CXX)
project(spdlog VERSION 1.2.0 LANGUAGES CXX)
include(CTest)
include(CMakeDependentOption)
include(GNUInstallDirs)
@@ -28,7 +28,10 @@ set(CMAKE_CXX_EXTENSIONS OFF)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
    add_compile_options("-Wall")
    add_compile_options("-Wextra")
    add_compile_options("-Wconversion")
    add_compile_options("-pedantic")
    add_compile_options("-Wfatal-errors")
    
endif()

#---------------------------------------------------------------------------------------
@@ -42,11 +45,17 @@ include(cmake/sanitizers.cmake)
add_library(spdlog INTERFACE)
add_library(spdlog::spdlog ALIAS spdlog)

option(SPDLOG_BUILD_EXAMPLES "Build examples" ON)
option(SPDLOG_BUILD_BENCH "Build benchmarks" ON)
# Check if spdlog is being used directly or via add_subdirectory
set(SPDLOG_MASTER_PROJECT OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
  set(SPDLOG_MASTER_PROJECT ON)
endif()

option(SPDLOG_BUILD_EXAMPLES "Build examples" ${SPDLOG_MASTER_PROJECT})
option(SPDLOG_BUILD_BENCH "Build benchmarks" ${SPDLOG_MASTER_PROJECT})

cmake_dependent_option(SPDLOG_BUILD_TESTING
    "Build spdlog tests" ON
    "Build spdlog tests" ${SPDLOG_MASTER_PROJECT}
    "BUILD_TESTING" OFF
)

+57 −21
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
Very fast, header only, C++ logging library. [![Build Status](https://travis-ci.org/gabime/spdlog.svg?branch=master)](https://travis-ci.org/gabime/spdlog)  [![Build status](https://ci.appveyor.com/api/projects/status/d2jnxclg20vd0o50?svg=true)](https://ci.appveyor.com/project/gabime/spdlog)



## Install
#### Just copy the headers:

@@ -20,18 +21,17 @@ Very fast, header only, C++ logging library. [![Build Status](https://travis-ci.
 

## Platforms
 * Linux, FreeBSD, Solaris, AIX
 * Windows (vc 2013+, cygwin)
 * Mac OSX (clang 3.5+)
 * Linux, FreeBSD, OpenBSD, Solaris, AIX
 * Windows (msvc 2013+, cygwin)
 * macOS (clang 3.5+)
 * Android

## Features
* Very fast - performance is the primary goal (see [benchmarks](#benchmarks) below).
* Very fast (see [benchmarks](#benchmarks) below).
* Headers only, just copy and use.
* Feature rich using the excellent [fmt](https://github.com/fmtlib/fmt) library.
* Feature rich formatting, using the excellent [fmt](https://github.com/fmtlib/fmt) library.
* Fast asynchronous mode (optional)
* [Custom](https://github.com/gabime/spdlog/wiki/3.-Custom-formatting) formatting.
* Conditional Logging
* Multi/Single threaded loggers.
* Various log targets:
    * Rotating log files.
@@ -41,7 +41,7 @@ Very fast, header only, C++ logging library. [![Build Status](https://travis-ci.
    * Windows debugger (```OutputDebugString(..)```)
    * Easily extendable with custom log targets  (just implement a single function in the [sink](include/spdlog/sinks/sink.h) interface).
* Severity based filtering - threshold levels can be modified in runtime as well as in compile time.

* Binary data logging.


## Benchmarks
@@ -53,28 +53,26 @@ Below are some [benchmarks](https://github.com/gabime/spdlog/blob/v1.x/bench/ben
*******************************************************************************
Single thread, 1,000,000 iterations
*******************************************************************************
basic_st...		    Elapsed: 0.226664	4,411,806/sec
rotating_st...	 	    Elapsed: 0.214339	4,665,499/sec
daily_st...		    Elapsed: 0.211292	4,732,797/sec
null_st...		    Elapsed: 0.102815	9,726,227/sec

basic_st...             Elapsed: 0.181652       5,505,042/sec
rotating_st...          Elapsed: 0.181781       5,501,117/sec
daily_st...             Elapsed: 0.187595       5,330,630/sec
null_st...              Elapsed: 0.0504704      19,813,602/sec
*******************************************************************************
10 threads sharing same logger, 1,000,000 iterations
*******************************************************************************
basic_mt...		    Elapsed: 0.882268	1,133,441/sec
rotating_mt...              Elapsed: 0.875515	1,142,184/sec
daily_mt...		    Elapsed: 0.879573	1,136,915/sec
null_mt...		    Elapsed: 0.220114	4,543,105/sec
basic_mt...             Elapsed: 0.616035       1,623,284/sec
rotating_mt...          Elapsed: 0.620344       1,612,008/sec
daily_mt...             Elapsed: 0.648353       1,542,369/sec
null_mt...              Elapsed: 0.151972       6,580,166/sec
``` 
#### Asynchronous mode
```
*******************************************************************************
10 threads sharing same logger, 1,000,000 iterations 
*******************************************************************************
async...		Elapsed: 0.429088	2,330,524/sec
async...		Elapsed: 0.411501	2,430,126/sec
async...		Elapsed: 0.428979	2,331,116/sec

async...                Elapsed: 0.350066       2,856,606/sec
async...                Elapsed: 0.314865       3,175,960/sec
async...                Elapsed: 0.349851       2,858,358/sec
```

## Usage samples
@@ -130,7 +128,6 @@ void basic_logfile_example()
    catch (const spdlog::spdlog_ex &ex)
    {
        std::cout << "Log init failed: " << ex.what() << std::endl;
        return 1;
    }
}
```
@@ -158,6 +155,18 @@ void daily_example()

```

---
#### Cloning loggers 
```c++
// clone a logger and give it new name.
// Useful for creating subsystem loggers from some "root" logger
void clone_example()
{
    auto network_logger = spdlog::get("root")->clone("network");
    network_logger->info("Logging network stuff..");
}
```

---
#### Periodic flush
```c++
@@ -167,6 +176,33 @@ spdlog::flush_every(std::chrono::seconds(3));

```

---
#### Binary logging
```c++
// log binary data as hex.
// many types of std::container<char> types can be used.
// ranges are supported too.
// format flags:
// {:X} - print in uppercase.
// {:s} - don't separate each byte with space.
// {:p} - don't print the position on each line start.
// {:n} - don't split the output to lines.

#include "spdlog/fmt/bin_to_hex.h"

void binary_example()
{
    auto console = spdlog::get("console");
    std::array<char, 80> buf;
    console->info("Binary example: {}", spdlog::to_hex(buf));
    console->info("Another binary example:{:n}", spdlog::to_hex(std::begin(buf), std::begin(buf) + 10));
    // more examples:
    // logger->info("uppercase: {:X}", spdlog::to_hex(buf));
    // logger->info("uppercase, no delimiters: {:Xs}", spdlog::to_hex(buf));
    // logger->info("uppercase, no delimiters, no position info: {:Xsp}", spdlog::to_hex(buf));
}

```

---
#### Logger with multi sinks - each with different format and log level
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ int count_lines(const char *filename)
        if ('\n' == ch)
            counter++;
    }
    fclose(infile);

    return counter;
}
Loading