Fast C++ logging library.

Overview

spdlog

Very fast, header-only/compiled, C++ logging library. Build Status  Build status Release

Install

Header only version

Copy the source folder to your build tree and use a C++11 compiler.

Static lib version (recommended - much faster compile times)

$ git clone https://github.com/gabime/spdlog.git
$ cd spdlog && mkdir build && cd build
$ cmake .. && make -j

see example CMakeLists.txt on how to use.

Platforms

  • Linux, FreeBSD, OpenBSD, Solaris, AIX
  • Windows (msvc 2013+, cygwin)
  • macOS (clang 3.5+)
  • Android

Package managers:

  • Homebrew: brew install spdlog
  • MacPorts: sudo port install spdlog
  • FreeBSD: cd /usr/ports/devel/spdlog/ && make install clean
  • Fedora: dnf install spdlog
  • Gentoo: emerge dev-libs/spdlog
  • Arch Linux: pacman -S spdlog
  • vcpkg: vcpkg install spdlog
  • conan: spdlog/[>=1.4.1]
  • conda: conda install -c conda-forge spdlog

Features

  • Very fast (see benchmarks below).
  • Headers only or compiled
  • Feature rich formatting, using the excellent fmt library.
  • Asynchronous mode (optional)
  • Custom formatting.
  • Multi/Single threaded loggers.
  • Various log targets:
    • Rotating log files.
    • Daily log files.
    • Console logging (colors supported).
    • syslog.
    • Windows debugger (OutputDebugString(..))
    • Easily extendable with custom log targets (just implement a single function in the sink interface).
  • Log filtering - log levels can be modified in runtime as well as in compile time.
  • Support for loading log levels from argv or from environment var.
  • Backtrace support - store debug messages in a ring buffer and display later on demand.

Usage samples

Basic usage

#include "spdlog/spdlog.h"

int main() 
{
    spdlog::info("Welcome to spdlog!");
    spdlog::error("Some error message with arg: {}", 1);
    
    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");
    
    spdlog::set_level(spdlog::level::debug); // Set global log level to debug
    spdlog::debug("This message should be displayed..");    
    
    // change log pattern
    spdlog::set_pattern("[%H:%M:%S %z] [%n] [%^---%L---%$] [thread %t] %v");
    
    // Compile time log levels
    // define SPDLOG_ACTIVE_LEVEL to desired level
    SPDLOG_TRACE("Some trace message with param {}", 42);
    SPDLOG_DEBUG("Some debug message");
}

Create stdout/stderr logger object

#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)");
}

Basic file logger

#include "spdlog/sinks/basic_file_sink.h"
void basic_logfile_example()
{
    try 
    {
        auto logger = spdlog::basic_logger_mt("basic_logger", "logs/basic-log.txt");
    }
    catch (const spdlog::spdlog_ex &ex)
    {
        std::cout << "Log init failed: " << ex.what() << std::endl;
    }
}

Rotating files

#include "spdlog/sinks/rotating_file_sink.h"
void rotating_example()
{
    // Create a file rotating logger with 5mb size max and 3 rotated files
    auto max_size = 1048576 * 5;
    auto max_files = 3;
    auto logger = spdlog::rotating_logger_mt("some_logger_name", "logs/rotating.txt", max_size, max_files);
}

Daily files

#include "spdlog/sinks/daily_file_sink.h"
void daily_example()
{
    // Create a daily logger - a new file is created every day on 2:30am
    auto logger = spdlog::daily_logger_mt("daily_logger", "logs/daily.txt", 2, 30);
}

Backtrace support

// Loggers can store in a ring buffer all messages (including debug/trace) and display later on demand.
// When needed, call dump_backtrace() to see them

spdlog::enable_backtrace(32); // Store the latest 32 messages in a buffer. Older messages will be dropped.
// or my_logger->enable_backtrace(32)..
for(int i = 0; i < 100; i++)
{
  spdlog::debug("Backtrace message {}", i); // not logged yet..
}
// e.g. if some error happened:
spdlog::dump_backtrace(); // log them now! show the last 32 messages

// or my_logger->dump_backtrace(32)..

Periodic flush

// periodically flush all *registered* loggers every 3 seconds:
// warning: only use if all your loggers are thread safe ("_mt" loggers)
spdlog::flush_every(std::chrono::seconds(3));

Stopwatch

// Stopwatch support for spdlog
#include "spdlog/stopwatch.h"
void stopwatch_example()
{
    spdlog::stopwatch sw;    
    spdlog::debug("Elapsed {}", sw);
    spdlog::debug("Elapsed {:.3}", sw);       
}

Log binary data in 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.
// {:a} - show ASCII if :n is not set.

#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

// create logger with 2 targets with different log levels and formats.
// the console will show only warnings or errors, while the file will log all.
void multi_sink_example()
{
    auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
    console_sink->set_level(spdlog::level::warn);
    console_sink->set_pattern("[multi_sink_example] [%^%l%$] %v");

    auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>("logs/multisink.txt", true);
    file_sink->set_level(spdlog::level::trace);

    spdlog::logger logger("multi_sink", {console_sink, file_sink});
    logger.set_level(spdlog::level::debug);
    logger.warn("this should appear in both console and file");
    logger.info("this message should not appear in the console, only in the file");
}

Asynchronous logging

#include "spdlog/async.h"
#include "spdlog/sinks/basic_file_sink.h"
void async_example()
{
    // default thread pool settings can be modified *before* creating the async logger:
    // spdlog::init_thread_pool(8192, 1); // queue with 8k items and 1 backing thread.
    auto async_file = spdlog::basic_logger_mt<spdlog::async_factory>("async_file_logger", "logs/async_log.txt");
    // alternatively:
    // auto async_file = spdlog::create_async<spdlog::sinks::basic_file_sink_mt>("async_file_logger", "logs/async_log.txt");   
}

Asynchronous logger with multi sinks

#include "spdlog/sinks/stdout_color_sinks.h"
#include "spdlog/sinks/rotating_file_sink.h"

void multi_sink_example2()
{
    spdlog::init_thread_pool(8192, 1);
    auto stdout_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt >();
    auto rotating_sink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>("mylog.txt", 1024*1024*10, 3);
    std::vector<spdlog::sink_ptr> sinks {stdout_sink, rotating_sink};
    auto logger = std::make_shared<spdlog::async_logger>("loggername", sinks.begin(), sinks.end(), spdlog::thread_pool(), spdlog::async_overflow_policy::block);
    spdlog::register_logger(logger);
}

User defined types

// user defined types logging by implementing operator<<
#include "spdlog/fmt/ostr.h" // must be included
struct my_type
{
    int i;
    template<typename OStream>
    friend OStream &operator<<(OStream &os, const my_type &c)
    {
        return os << "[my_type i=" << c.i << "]";
    }
};

void user_defined_example()
{
    spdlog::get("console")->info("user defined type: {}", my_type{14});
}

User defined flags in the log pattern

// Log patterns can contain custom flags.
// the following example will add new flag '%*' - which will be bound to a <my_formatter_flag> instance.
#include "spdlog/pattern_formatter.h"
class my_formatter_flag : public spdlog::custom_flag_formatter
{
public:
    void format(const spdlog::details::log_msg &, const std::tm &, spdlog::memory_buf_t &dest) override
    {
        std::string some_txt = "custom-flag";
        dest.append(some_txt.data(), some_txt.data() + some_txt.size());
    }

    std::unique_ptr<custom_flag_formatter> clone() const override
    {
        return spdlog::details::make_unique<my_formatter_flag>();
    }
};

void custom_flags_example()
{    
    auto formatter = std::make_unique<spdlog::pattern_formatter>();
    formatter->add_flag<my_formatter_flag>('*').set_pattern("[%n] [%*] [%^%l%$] %v");
    spdlog::set_formatter(std::move(formatter));
}

Custom error handler

void err_handler_example()
{
    // can be set globally or per logger(logger->set_error_handler(..))
    spdlog::set_error_handler([](const std::string &msg) { spdlog::get("console")->error("*** LOGGER ERROR ***: {}", msg); });
    spdlog::get("console")->info("some invalid message to trigger an error {}{}{}{}", 3);
}

syslog

#include "spdlog/sinks/syslog_sink.h"
void syslog_example()
{
    std::string ident = "spdlog-example";
    auto syslog_logger = spdlog::syslog_logger_mt("syslog", ident, LOG_PID);
    syslog_logger->warn("This is warning that will end up in syslog.");
}

Android example

#include "spdlog/sinks/android_sink.h"
void android_example()
{
    std::string tag = "spdlog-android";
    auto android_logger = spdlog::android_logger_mt("android", tag);
    android_logger->critical("Use \"adb shell logcat\" to view this message.");
}

Load log levels from env variable or from argv

#include "spdlog/cfg/env.h"
int main (int argc, char *argv[])
{
    spdlog::cfg::load_env_levels();
    // or from command line:
    // ./example SPDLOG_LEVEL=info,mylogger=trace
    // #include "spdlog/cfg/argv.h" // for loading levels from argv
    // spdlog::cfg::load_argv_levels(argc, argv);
}

So then you can:

$ export SPDLOG_LEVEL=info,mylogger=trace
$ ./example

Benchmarks

Below are some benchmarks done in Ubuntu 64 bit, Intel i7-4770 CPU @ 3.40GHz

Synchronous mode

[info] **************************************************************
[info] Single thread, 1,000,000 iterations
[info] **************************************************************
[info] basic_st         Elapsed: 0.17 secs        5,777,626/sec
[info] rotating_st      Elapsed: 0.18 secs        5,475,894/sec
[info] daily_st         Elapsed: 0.20 secs        5,062,659/sec
[info] empty_logger     Elapsed: 0.07 secs       14,127,300/sec
[info] **************************************************************
[info] C-string (400 bytes). Single thread, 1,000,000 iterations
[info] **************************************************************
[info] basic_st         Elapsed: 0.41 secs        2,412,483/sec
[info] rotating_st      Elapsed: 0.72 secs        1,389,196/sec
[info] daily_st         Elapsed: 0.42 secs        2,393,298/sec
[info] null_st          Elapsed: 0.04 secs       27,446,957/sec
[info] **************************************************************
[info] 10 threads, competing over the same logger object, 1,000,000 iterations
[info] **************************************************************
[info] basic_mt         Elapsed: 0.60 secs        1,659,613/sec
[info] rotating_mt      Elapsed: 0.62 secs        1,612,493/sec
[info] daily_mt         Elapsed: 0.61 secs        1,638,305/sec
[info] null_mt          Elapsed: 0.16 secs        6,272,758/sec

Asynchronous mode

[info] -------------------------------------------------
[info] Messages     : 1,000,000
[info] Threads      : 10
[info] Queue        : 8,192 slots
[info] Queue memory : 8,192 x 272 = 2,176 KB 
[info] -------------------------------------------------
[info] 
[info] *********************************
[info] Queue Overflow Policy: block
[info] *********************************
[info] Elapsed: 1.70784 secs     585,535/sec
[info] Elapsed: 1.69805 secs     588,910/sec
[info] Elapsed: 1.7026 secs      587,337/sec
[info] 
[info] *********************************
[info] Queue Overflow Policy: overrun
[info] *********************************
[info] Elapsed: 0.372816 secs    2,682,285/sec
[info] Elapsed: 0.379758 secs    2,633,255/sec
[info] Elapsed: 0.373532 secs    2,677,147/sec

Documentation

Documentation can be found in the wiki pages.


Thanks to JetBrains for donating product licenses to help develop spdlog

Comments
  • Provide option to use spdlog as a (static) library

    Provide option to use spdlog as a (static) library

    For a reasonable sized project, the logger is very likely to be all over the place.

    Rebuilding the whole project because an implementation detail changed would be a pain.

    Could we have a compile-time option (eg SPDLOG_LIBRARY or SPDLOG_HEADER_ONLY) that would allow somebody to choose between header-only or precompiled?

    I noticed cppformat uses a similar approach and I'd really appreciate that option.

    I can provide that if you're up for it.

    enhancement help wanted 
    opened by gregoire-astruc 52
  • Can you comment on this test by the maker of g3log?

    Can you comment on this test by the maker of g3log?

    https://kjellkod.wordpress.com/2015/06/30/the-worlds-fastest-logger-vs-g3log/

    He makes an interesting point that could lead to further optimisation of g3log.

    opened by ruipacheco 49
  • spdlog 1.8.5 fails to build with libfmt 8.0.0

    spdlog 1.8.5 fails to build with libfmt 8.0.0

    Trying to build spdlog 1.8.5 with libfmt 8.0.0 fails with this error:

    ninja -v -j5 -l0
    [1/8] /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DFMT_LOCALE -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dspdlog_EXPORTS -I/var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include  -O2 -march=native -pipe -fuse-linker-plugin -flto -Wl,-flto -ftree-vectorize -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-common -fPIC -std=c++11 -MD -MT CMakeFiles/spdlog.dir/src/file_sinks.cpp.o -MF CMakeFiles/spdlog.dir/src/file_sinks.cpp.o.d -o CMakeFiles/spdlog.dir/src/file_sinks.cpp.o -c /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/file_sinks.cpp
    [2/8] /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DFMT_LOCALE -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dspdlog_EXPORTS -I/var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include  -O2 -march=native -pipe -fuse-linker-plugin -flto -Wl,-flto -ftree-vectorize -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-common -fPIC -std=c++11 -MD -MT CMakeFiles/spdlog.dir/src/async.cpp.o -MF CMakeFiles/spdlog.dir/src/async.cpp.o.d -o CMakeFiles/spdlog.dir/src/async.cpp.o -c /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/async.cpp
    [3/8] /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DFMT_LOCALE -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dspdlog_EXPORTS -I/var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include  -O2 -march=native -pipe -fuse-linker-plugin -flto -Wl,-flto -ftree-vectorize -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-common -fPIC -std=c++11 -MD -MT CMakeFiles/spdlog.dir/src/stdout_sinks.cpp.o -MF CMakeFiles/spdlog.dir/src/stdout_sinks.cpp.o.d -o CMakeFiles/spdlog.dir/src/stdout_sinks.cpp.o -c /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/stdout_sinks.cpp
    [4/8] /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DFMT_LOCALE -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dspdlog_EXPORTS -I/var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include  -O2 -march=native -pipe -fuse-linker-plugin -flto -Wl,-flto -ftree-vectorize -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-common -fPIC -std=c++11 -MD -MT CMakeFiles/spdlog.dir/src/color_sinks.cpp.o -MF CMakeFiles/spdlog.dir/src/color_sinks.cpp.o.d -o CMakeFiles/spdlog.dir/src/color_sinks.cpp.o -c /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/color_sinks.cpp
    [5/8] /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DFMT_LOCALE -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dspdlog_EXPORTS -I/var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include  -O2 -march=native -pipe -fuse-linker-plugin -flto -Wl,-flto -ftree-vectorize -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-common -fPIC -std=c++11 -MD -MT CMakeFiles/spdlog.dir/src/cfg.cpp.o -MF CMakeFiles/spdlog.dir/src/cfg.cpp.o.d -o CMakeFiles/spdlog.dir/src/cfg.cpp.o -c /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/cfg.cpp
    [6/8] /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DFMT_LOCALE -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dspdlog_EXPORTS -I/var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include  -O2 -march=native -pipe -fuse-linker-plugin -flto -Wl,-flto -ftree-vectorize -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-common -fPIC -std=c++11 -MD -MT CMakeFiles/spdlog.dir/src/spdlog.cpp.o -MF CMakeFiles/spdlog.dir/src/spdlog.cpp.o.d -o CMakeFiles/spdlog.dir/src/spdlog.cpp.o -c /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/spdlog.cpp
    FAILED: CMakeFiles/spdlog.dir/src/spdlog.cpp.o 
    /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DFMT_LOCALE -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dspdlog_EXPORTS -I/var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include  -O2 -march=native -pipe -fuse-linker-plugin -flto -Wl,-flto -ftree-vectorize -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-common -fPIC -std=c++11 -MD -MT CMakeFiles/spdlog.dir/src/spdlog.cpp.o -MF CMakeFiles/spdlog.dir/src/spdlog.cpp.o.d -o CMakeFiles/spdlog.dir/src/spdlog.cpp.o -c /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/spdlog.cpp
    In file included from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/spdlog.cpp:9:
    /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/common-inl.h: In constructor ‘spdlog::spdlog_ex::spdlog_ex(const string&, int)’:
    /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/common-inl.h:63:50: error: cannot convert ‘const string’ {aka ‘const std::__cxx11::basic_string<char>’} to ‘const char*’
       63 |     fmt::format_system_error(outbuf, last_errno, msg);
          |                                                  ^~~
          |                                                  |
          |                                                  const string {aka const std::__cxx11::basic_string<char>}
    In file included from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/fmt/fmt.h:26,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/common.h:36,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/spdlog.h:12,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/spdlog-inl.h:7,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/spdlog.cpp:8:
    /usr/include/fmt/format.h:2262:46: note:   initializing argument 3 of ‘void fmt::v7::format_system_error(fmt::v7::detail::buffer<char>&, int, const char*)’
     2262 |                                  const char* message) FMT_NOEXCEPT;
          |                                  ~~~~~~~~~~~~^~~~~~~
    In file included from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/pattern_formatter-inl.h:10,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/spdlog.cpp:13:
    /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/details/fmt_helper.h: In function ‘void spdlog::details::fmt_helper::pad2(int, spdlog::memory_buf_t&)’:
    /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/details/fmt_helper.h:57:23: warning: ‘fmt::v7::appender fmt::v7::format_to(fmt::v7::basic_memory_buffer<char, SIZE, Allocator>&, fmt::v7::format_string<T ...>, T&& ...) [with T = {int&}; long unsigned int SIZE = 250; Allocator = std::allocator<char>; fmt::v7::format_string<T ...> = fmt::v7::basic_format_string<char, int&>]’ is deprecated [-Wdeprecated-declarations]
       57 |         fmt::format_to(dest, "{:02}", n);
          |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    In file included from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/fmt/fmt.h:26,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/common.h:36,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/spdlog.h:12,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/spdlog-inl.h:7,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/spdlog.cpp:8:
    /usr/include/fmt/format.h:2790:21: note: declared here
     2790 | FMT_DEPRECATED auto format_to(basic_memory_buffer<char, SIZE, Allocator>& buf,
          |                     ^~~~~~~~~
    ninja: build stopped: subcommand failed.
    

    build.log

    opened by candrews 34
  • error C2039: 'registry': is not a member of ':spedlog::details'

    error C2039: 'registry': is not a member of ':spedlog::details'

    I recently moved to a new Windows 10 PC and had to reconfigure my environment. Unfortunately I don't have the version of spdlog I was using previously, so I went with the latest available (1.3.1) in vcpkg. I had no issues previously trying to compile.

    The application uses a few other dependencies that are all installed via vcpkg and have no issues compiling, so I don't think it is a referencing problem.

    I am using Visual Studio 2017 with UCRT version 10.0.17134.0.

    These are the errors I am getting:

    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\spdlog.h(55): error C2039: 'registry': is not a member of 'spdlog::details'
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\details\periodic_worker.h(21): note: see declaration of 'spdlog::details'
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\spdlog.h(55): error C3083: 'registry': the symbol to the left of a '::' must be a type
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\spdlog.h(55): error C2039: 'instance': is not a member of 'spdlog::details'
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\details\periodic_worker.h(21): note: see declaration of 'spdlog::details'
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\spdlog.h(55): error C3861: 'instance': identifier not found
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\spdlog.h(61): error C2039: 'registry': is not a member of 'spdlog::details'
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\details\periodic_worker.h(21): note: see declaration of 'spdlog::details'
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\spdlog.h(61): error C3083: 'registry': the symbol to the left of a '::' must be a type
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\spdlog.h(61): error C2039: 'instance': is not a member of 'spdlog::details'
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\details\periodic_worker.h(21): note: see declaration of 'spdlog::details'
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\spdlog.h(61): error C3861: 'instance': identifier not found
    
    opened by ccarv 30
  • Issue with creating a Asynchronous log.

    Issue with creating a Asynchronous log.

    std::shared_ptrspdlog::logger my_logger; my_logger = spdlog::basic_logger_mtspdlog::async_factory("async_file_logger", "logs/async_log.txt");

    Having an issue with the following code. It is just never returning from the basic_logger_mt call. Looks to me like it is somewhere around the thread pool creation. The logger is being created in a dll plugin that is being loaded from the main exe. I thought it might be the windows issue with application deadlock, but this is not happening on exit.

    Any Ideas ?

    opened by evandam1999 30
  • Compile error with VS2017 community

    Compile error with VS2017 community

    When I imported spdlog to my project, it always compiled error with following details you can see below. Could you help me? The head file I included just called #include "spdlog/spdlog.h".

    1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\algorithm(5386): error C2676: 二进制“<”:“const _Ty”不定义该运算符或到预定义运算符可接收的类型的转换 1> with 1> [ 1> _Ty=std::chrono::durationstd::chrono::system_clock::rep,std::chrono::system_clock::period 1> ] 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\algorithm(5385): note: 参见对正在编译的函数 模板 实例化“const _Ty &std::max<std::chrono::durationstd::chrono::system_clock::rep,std::chrono::system_clock::period>(const _Ty &,const _Ty &) noexcept()”的引用 1> with 1> [ 1> _Ty=std::chrono::durationstd::chrono::system_clock::rep,std::chrono::system_clock::period 1> ] 1>xxx\libraries\spdlog-1.x\include\spdlog\details\pattern_formatter-inl.h(872): note: 编译 类 模板 成员函数 "void spdlog::details::elapsed_formatter<Padder,std::chrono::seconds>::format(const spdlog::details::log_msg &,const tm &,spdlog::memory_buf_t &)" 时 1> with 1> [ 1> Padder=spdlog::details::null_scoped_padder 1> ] 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\type_traits(616): note: 参见对正在编译的 类 模板 实例化 "spdlog::details::elapsed_formatter<Padder,std::chrono::seconds>" 的引用 1> with 1> [ 1> Padder=spdlog::details::null_scoped_padder 1> ] 1>xxx\libraries\spdlog-1.x\include\spdlog\details\pattern_formatter-inl.h(1203): note: 参见对正在编译的 类 模板 实例化 "std::is_convertible<spdlog::details::elapsed_formatter<Padder,std::chrono::seconds> *,_Ty *>" 的引用 1> with 1> [ 1> Padder=spdlog::details::null_scoped_padder, 1> _Ty=spdlog::details::flag_formatter 1> ]

    opened by caibf 29
  • spdlog/fmt/fmt.h triggers assert in libfmt

    spdlog/fmt/fmt.h triggers assert in libfmt

    After either spdlog or libfmt update the OpenRoad FreeBSD port now fails to build:

    In file included from /wrkdirs/usr/ports/cad/openroad/work/OpenROAD-2.0/src/TritonRoute/src/gr/FlexGRCMap.cpp:29:
    In file included from /wrkdirs/usr/ports/cad/openroad/work/OpenROAD-2.0/src/TritonRoute/src/gr/FlexGRCMap.h:37:
    In file included from /wrkdirs/usr/ports/cad/openroad/work/OpenROAD-2.0/src/TritonRoute/src/frBaseTypes.h:41:
    In file included from /wrkdirs/usr/ports/cad/openroad/work/OpenROAD-2.0/src/utl/include/utl/Logger.h:46:
    In file included from /usr/local/include/spdlog/spdlog.h:12:
    In file included from /usr/local/include/spdlog/common.h:36:
    In file included from /usr/local/include/spdlog/fmt/fmt.h:25:
    /usr/local/include/fmt/core.h:1727:3: error: static_assert failed due to requirement 'formattable' "Cannot format an argument. To make type T formattable provide a formatter<T> specialization: https://fmt.dev/latest/api.html#udt"
      static_assert(
      ^
    /usr/local/include/fmt/core.h:1853:23: note: in instantiation of function template specialization 'fmt::v8::detail::make_arg<true, fmt::v8::basic_format_context<fmt::v8::appender, char>, fmt::v8::detail::type::custom_type, const fr::frMinstepTypeEnum &, 0>' requested here
            data_{detail::make_arg<
                          ^
    

    Full log (IPv6 URL).

    It appears that the cause is a version of libfmt bundled with spdlog.

    Such bundling can not work, please remove it.

    Please advise how to fix the port.

    FreeBSD 13

    Thanks.

    opened by yurivict 28
  • HELP! Do not know how to use a custom sink for logging.

    HELP! Do not know how to use a custom sink for logging.

    Hi, I am trying to create a custom sink that would target Oracle DB. I tried to follow the example of sqlite_lite and it is something I would like to use as format and replace the code to target Oracle DB. (link to sqlite_sink: https://github.com/PedroRod/sqlite_sink/blob/master/sqlite_sink.h)

    Now the issues I am facing are (disclaimer: I am a total newbie at C++)

    1. I do not know how to use the custom sink using a logger. Therefore, how do I create a logger that will use my sink to process the log message and send it to oracle? And where in the code do I create logger that uses my custom sink, in the main code or in the custom sink's header file? I tried the following codes (found it in the wiki) in the main code of the project where I created basic_logger_mt for testing spdlog: auto sink = std::make_sharedspdlog::sinks::oracle_sink(); auto my_logger = std::make_sharedspdlog::logger("mylogger", sink); I cannot test if this creates a logger using my custom sink because of the 2nd issue.

    2. In one of my attempts I received the error in MS VS "spdlog::sinks::oracle_sink': cannot instantiate abstract class". I do not understand why that is happening and I cannot test my sink because of it.

    image

    1. On line 11 of the sqlite_sink example "class sqlite_sink : public sink" is being used whereas the spdlog wiki tells to use "class sqlite_sink : public basic_sink". Which on should I use for my custom function, 'sink' or 'basic_sink'.

    2. I am aiming to use my custom sink to log details from various parts of a large project that contains multiple .cpp files. Therefore, I would also like to know if I have to make any additions to the sqlite_sink sink to make it capable of achieving this.

    Thanks!

    The custom sink I created by customizing the sqlite_sink if anyone wants to take a look at my failure till now

    `using namespace oracle::occi; namespace spdlog { namespace sinks { using namespace oracle::occi; class oracle_sink : public sink { private: Environment *env; Connection *conn; Statement *stmt;

    	public:
    		explicit oracle_sink(const std::string& databaseName)
    		{
    			env = Environment::createEnvironment();
    
    			//createConnection(username, password, connectionstring)
    			conn = env->createConnection(password, login_name, targetdatabase);
    			stmt = conn->createStatement("INSERT INTO EVENT_LOG VALUES (:1, :2, :3, :4, :5, :6, :7, :8)");
    
    
    		}
    
    		~oracle_sink()
    		{
    			conn->terminateStatement(stmt);
    			env->terminateConnection(conn);
    			Environment::terminateEnvironment(env);
    		}
    
    
    		//void bind_to_statement(const details::log_msg& msg) const
    		//{
    		//	//getting time 
    		//	stmt->setTimestamp(1, )
    
    		//		//PID varchar(10 BYTE)
    		//		stmt->setString(2, );
    
    		//	//username varchar(256 BYTE)
    		//	stmt->setString(3, );
    
    		//	//Severity varchar(10 BYTE)
    		//	stmt->setString(4, );
    
    		//	//THREAD_NAME varchar(100 BYTE)
    		//	stmt->setString(5, );
    
    		//	//LOGGER varchar(10BYTE)
    		//	stmt->setString(6, );
    
    		//	//MESSAGE varchar(10BYTE)
    		//	stmt->setString(7, );
    
    		//	//PID CLOB
    		//	stmt->setString(8, );
    
    
    		/*}*/
    
    		void log(const details::log_msg& msg) override
    		{
    			auto time = std::chrono::system_clock::to_time_t(msg.time);
    			char time_str[26];
    			ctime_s(time_str, sizeof(time_str), &time);
    
    			//THREAD_NAME varchar(100 BYTE)
    			stmt->setString(5, time_str);
    
    			stmt->executeUpdate();
    
    			/*sqlite3_reset(_query_stmt);
    			sqlite3_clear_bindings(_query_stmt);*/
    		}
    
    	};
    }
    

    }`

    opened by fahmidshibib 27
  • A short guide to setting up JSON logging with spdlog

    A short guide to setting up JSON logging with spdlog

    I haven't seen any json examples anywhere with spdlog so I thought I'd share how we did it. It's not hard to have human-readable and json-based machine-readable logs. I've edited this as per @gabime's response below, you don't need to use custom formatters, you can just call set_pattern(...) directly as below.

    
       //Set up the opening brace and an array named "log"
       //we're setting a global format here but as per the docs you can set this on an individual log as well
       spdlog::set_pattern(set_pattern("{\n \"log\": [");
       auto mylogger = spdlog::basic_logger_mt("json_logger", "mylog.json");
       mylogger->info("");//this initializes the log file with the opening brace and the "log" array as above
       //We have some extra formatting on the log level %l below to keep color coding when dumping json to the console and we use a full ISO 8601 time/date format
       std::string jsonpattern = {"{\"time\": \"%Y-%m-%dT%H:%M:%S.%f%z\", \"name\": \"%n\", \"level\": \"%^%l%$\", \"process\": %P, \"thread\": %t, \"message\": \"%v\"},"};
       spdlog::set_pattern(jsonpattern);
    

    Then, log whatever you like as normal, for example:

    
       mylogger->info(“We have started.”);
    

    This will give you a log entry structured like this, although it will all be on one line:

    {
         "time": "2021-01-10T13:44:14.567117-07:00",
         "name": "json_logger",
         "level": "info",
         "process": 6828,
         "thread": 23392,
         "message": "We have started."
    }
    

    You have to make sure yourself whatever you put in your log messages is valid json, you can make those as complex as you need with a complete json object if necessary. Most C++ json libraries have the ability to dump out a std::string that can be parsed as json and can then be passed as an argument to spdlog, or you can just do plain text messages like this example.

    When you're finished logging, you have to close out the "log" array. We also drop the log to clean it up ourselves:

    auto mylogger = spdlog::get("json_logger");
    //All we're doing below is setting the same log format, without the "," at the end
    std::string jsonlastlogpattern = { "{\"time\": \"%Y-%m-%dT%H:%M:%S.%f%z\", \"name\": \"%n\", \"level\": \"%^%l%$\", \"process\": %P, \"thread\": %t, \"message\": \"%v\"}" };
    spdlog::set_pattern(jsonlastlogpattern);
    //below is our last log entry
    mylogger->info("Finished.");
    //set the last pattern to close out the "log" json array and the closing brace
    spdlog::set_pattern("]\n}");
    //this writes out the closed array to the file
    mylogger->info("");
    spdlog::drop("json_logger");
    

    You end up with a log file that looks something like this (our setup and drop is done on a different thread from actual work, hence the different thread ids) :

    {
       "log": [
          {
             "time": "2021-01-10T13:44:14.567117-07:00",
             "name": "json_logger",
             "level": "info",
             "process": 6828,
             "thread": 23392,
             "message": "We have started."
          },
          {
             "time": "2021-01-10T13:44:23.932518-07:00",
             "name": "json_logger",
             "level": "info",
             "process": 6828,
             "thread": 8048,
             "message": "We are doing something."
          },
          {
             "time": "2021-01-10T13:44:26.927726-07:00",
             "name": "json_logger",
             "level": "info",
             "process": 6828,
             "thread": 8048,
             "message": "Look a number 123.456"
          },
          {
             "time": "2021-01-10T13:44:29.631340-07:00",
             "name": "json_logger",
             "level": "info",
             "process": 6828,
             "thread": 23392,
             "message": "Finished."
          }
       ]
    }
    

    You have to watch what minimum log level you have enabled in your compile, if you've disabled "info" then you'll need to use a higher severity to set up the initial json and close it out at the end. We're also going to develop a custom sink based on the new Boost::JSON so we can have a fast, in-memory JSON log as well for real-time processing.

    opened by damienhocking 24
  • Is there a way to cleanly use spdlog after main() (i.e. in static / global objects' destructors)?

    Is there a way to cleanly use spdlog after main() (i.e. in static / global objects' destructors)?

    Hello (and thanks for your work on spdlog),

    Is there an endorsed way of logging from global / static objects' destructors (that is, after main() is done)? Specifically, I want to use a rotating, async logger, and have a static Singleton that's supposed to manage spdlog. The static object's destructor will do a drop_all() and no other objects are supposed to be using spdlog after that.

    I know that the recommended way is to call drop_all() (or shutdown()? I've seen both being recommended, and not together - should I just use one of them? both? if both, I assume drop_all() before shutdown()?).

    Anyway, I'm seeing what appears to me to be the right order of construction and destruction, that is ~thread_pool() and ~registry run after my Singletons' destructors, but I am losing a bunch of messages (pretty much all that's logged after main() doesn't show up - I've tried sleep()s before drop_all() with no success). That doesn't occur when I am using the default stdout spdlog logger.

    Long story short, is there a recommended way to be able to go about achieving this, or is logging after main() just not done under any circumstances? And for debugging, what other spdlog globals should I be watching out for (are there any others, other than registry and thread_pool)?

    opened by rzvncj 24
  • Modify travis-ci, fix compilation issues

    Modify travis-ci, fix compilation issues

    Hey, I got some time and cleaned up travis-ci, as you can see thread sanitizer detected some issues, address sanitizer also reported a leak.

    Current issues:

    • Always building with -O3 (is that really an issue though?)
    • Always building with c++11
    • Valgrind is run on examples only
    • ASAN and TSAN are not run at all

    Possible improvements:

    • Move tsan/asan handling to CMake

    Added:

    • Release/Debug job for gcc 7 and clang 3.5
    • Debug asan gcc 7 job
    • Debug tsan gcc 7 job
    • Disabled extensions
    • Added a spdlog::spdlog alias for tests

    Removed:

    • Valgrind workaround, the current version is 3.10.1
    • install_libcxx
    • Makefiles

    Fixed:

    • examples build ( fixes #783 )
    • multisink build

    Workarounds:

    • gcc7 with tsan and asan needs gold linker, otherwise linking fails becase of unrecognized option '--push-state'
    opened by DanielChabrowski 24
  • C2338: Cannot format an argument. To make type T formattable provide a formatter<T> specialization.

    C2338: Cannot format an argument. To make type T formattable provide a formatter specialization.

    Before I start, I know that this issue already exists. But, I am quite stupid and don't know what to do. I am currently following The Cherno's game engine series and am on the Event System episode.

    This class gives me the error:

    class EventDispatcher
    {
    	template<typename T>
    	using EventFn = std::function<bool(T&)>;
    public:
    	EventDispatcher(Event& event)
    		: m_Event(event)
    	{
    	}
    	
    	template<typename T>
    	bool Dispatch(EventFn<T> func)
    	{
    		if (m_Event.GetEventType() == T::GetStaticType())
    		{
    			m_Event.m_Handled = func(*(T*)&m_Event);
    			return true;
    		}
    		return false;
    	}
    private:
    	Event& m_Event;
    };
    

    Tell me if I need to give more information please.

    opened by ItsNovaAndCrap 2
  • sometimes,export json has bug

    sometimes,export json has bug

    string s = "{\"nlu\":{\"input\":\"suzhou\",\"res\":\"aicar.0.8.16\",\"semantics\":{\"request\":{\"slotcount\":3,\"slots\":[{\"name\":\"intent\",\"value\":\"daohang\"},{\"name\":\"start\",\"pos\":[1,2],\"rawpinyin\":\"su zhou\",\"rawvalue\":\"number\",\"value\":\"suzhou\"},{\"name\":\"destination\",\"pos\":[3,5],\"rawpinyin\":\"bei jing\",\"rawvalue\":\"beijing\",\"value\":\"beijing\"}],\"task\":\"daohang\"}},\"skill\":\"SK_1\",\"skillId\":\"10000000289\",\"systime\":17.782958984375,\"version\":\"2017.2.13.16:38:28\"}}";
    cout << s << endl;
    
    mylog.Logger->info(s);
    

    the cout can print right but logger : [*** LOG ERROR #0001 ***] [2023-01-03 19:21:49] [cdmserver] {unmatched '}' in format string}

    opened by zxz970104 11
  • Daily rotation does not remove oldest files if one day is missing

    Daily rotation does not remove oldest files if one day is missing

    If for any reason one of the old files is missing (e.g., because one day the application has not logged), the oldest file is no more removed. For example, having these files:

    myapp_2022-11-25.log
    myapp_2022-11-24.log
    myapp_2022-11-23.log
    myapp_2022-11-21.log
    myapp_2022-11-20.log
    

    myapp_2022-11-21.log and myapp_2022-11-20.log won't be never deleted.

    This function causes the issue:

    https://github.com/gabime/spdlog/blob/v1.x/include/spdlog/sinks/daily_file_sink.h#L183

    void init_filenames_q_()
    {
        using details::os::path_exists;
    
        filenames_q_ = details::circular_q<filename_t>(static_cast<size_t>(max_files_));
        std::vector<filename_t> filenames;
        auto now = log_clock::now();
        while (filenames.size() < max_files_)
        {
            auto filename = FileNameCalc::calc_filename(base_filename_, now_tm(now));
            if (!path_exists(filename))  // <---------------- stop at the first file missing
            {
                break;
            }
            filenames.emplace_back(filename);
            now -= std::chrono::hours(24);    // <-------- goes backward 24h
        }
        for (auto iter = filenames.rbegin(); iter != filenames.rend(); ++iter)
        {
            filenames_q_.push_back(std::move(*iter));
        }
    }
    

    I guess one fix could be to change the function so that it enumerates the files with the right pattern and remove the oldest one based on the file timestamp.

    opened by daniele77 4
  • Undefined symbols for architecture x86_64:

    Undefined symbols for architecture x86_64: "___builtin_addcll" on Mac using intel compiler

    I'm trying to compile spdlog with intel oneapi and gnu compiler on different platforms. Here are the results.

    |System|Intel onapi Compiler|Status| |-------|---------|-------| |Linux |icc/icx |Good | |Win10 |icl/icx |Good | |Mac |icc |Fail |

    |System|GNU Compiler|Status| |-------|---------|-------| |Linux |gnu |Good | |Win10 |gnu(mingw64 with msys2) |Good | |Mac |gnu12(homebrew) |Good |

    So only the intel classic compiler on Mac fails. It fails when linking the example

    [1/1] Linking CXX executable example/example
    FAILED: example/example 
    : && /opt/intel/oneapi/compiler/2022.0.0/mac/bin/intel64/icpc -O3 -DNDEBUG -Wl,-search_paths_first -Wl,-headerpad_max_install_names  example/CMakeFiles/example.dir/example.cpp.o -o example/example  libspdlog.a && :
    Undefined symbols for architecture x86_64:
      "___builtin_addcll", referenced from:
          __ZN3fmt2v96detail9dragonbox10to_decimalIdEENS2_10decimal_fpIT_EES5_ in libspdlog.a(bundled_fmtlib_format.cpp.o)
    ld: symbol(s) not found for architecture x86_64
    ninja: build stopped: subcommand failed.
    

    There are also some warnings that I don't see on other platforms, such as this one:

    [8/10] Building CXX object CMakeFiles/spdlog.dir/src/spdlog.cpp.o
    /Users/xcheng/Documents/spdlog/include/spdlog/fmt/bundled/core.h(3055): warning #3924: attribute namespace "clang" is unrecognized
            FMT_FALLTHROUGH;
            ^
              detected during:
                instantiation of "auto fmt::v9::detail::parse_format_specs<T,ParseContext>(ParseContext &)->decltype((<expression>)) [with T=fmt::v9::remove_cvref_t<int &>={int}, ParseContext=fmt::v9::detail::compile_parse_context<fmt::v9::remove_cvref_t<const char &>={char}, fmt::v9::detail::error_handler>]" at line 2954
                instantiation of "fmt::v9::detail::format_string_checker<Char, ErrorHandler, Args...>::format_string_checker(fmt::v9::basic_string_view<Char>, ErrorHandler) [with Char=fmt::v9::remove_cvref_t<const char &>={char}, ErrorHandler=fmt::v9::detail::error_handler, Args=<fmt::v9::remove_cvref_t<int &>={int}>]" at line 3008
                instantiation of "void fmt::v9::detail::check_format_string<Args...,S,<unnamed>>(S) [with Args=<int &>, S=FMT_COMPILE_STRING, <unnamed>=0]" at line 3162
                instantiation of "fmt::v9::basic_format_string<Char, Args...>::basic_format_string(const S &) [with Char=char, Args=<int &>, S=FMT_COMPILE_STRING, <unnamed>=0]" at line 110 of "/Users/xcheng/Documents/spdlog/include/spdlog/details/fmt_helper.h"
    

    Maybe this is intel compiler's problem? I just want to report this and see if anybody can reproduce this problem.

    opened by billcxx 1
  • Fail to create logger using daily_logger_format_mt()

    Fail to create logger using daily_logger_format_mt()

    I try to create a logger with daily_logger_format_mt(), referencing to daily_filename_format_calculator's annotation in sinks/daily_file_sink.h. But I failed, and error happens when daily_file_sink::file_helper_.open() invoked, which errno = 22.

    My question is: Is it the annotation wrong or my creating method wrong, when using daily_logger_format_mt()?

    My environment:

    • OS Win10x64
    • IDE VS2022 Community

    daily_filename_format_calculator's annotation(from daily_file_sink L44 ):

    /*
     * Generator of daily log file names with strftime format.
     * Usages:
     *    auto sink =  std::make_shared<spdlog::sinks::daily_file_format_sink_mt>("myapp-%Y-%m-%d:%H:%M:%S.log", hour, minute);"
     *    auto logger = spdlog::daily_logger_format_mt("loggername, "myapp-%Y-%m-%d:%X.log", hour,  minute)"
     *
     */
    struct daily_filename_format_calculator
    {...}
    

    My creating case: add this line to daily_example() of example.cpp

    auto logger = spdlog::daily_logger_format_mt("loggername", "logs/myapp-%Y-%m-%d:%X.log", 2, 30);
    

    Console output result (error message):

    ...
    Log initialization failed: Failed opening file myapp-2022-11-04:16:25:57.log for writing: invalid argument
    

    I guess pattern flag "%X" means "%H:%M:%S". But colon(":") is not a valid character for a filename under Window10x64. After I using "%H_%M" instead of ":" , no error happens.

    opened by fortunely 2
  • [question] When will CMAKE_SYSTEM_NAME be evaluated to

    [question] When will CMAKE_SYSTEM_NAME be evaluated to "CYGWIN" or "MSYS"?

    Problem Description

    I saw this if() statement in the spdlog project.

    if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN" OR CMAKE_SYSTEM_NAME MATCHES "MSYS")
        set(CMAKE_CXX_EXTENSIONS ON)
    endif()
    

    Therefore, I tried to print CMAKE_SYSTEM_NAME when using Cygwin or MSYS compilers. However, it turns out that CMake will print Windows value for both.

    Demonstration

    • Example CMakeLists.txt

      cmake_minimum_required(VERSION 3.20)
      project(cmake-windows LANGUAGES C CXX)
      message("CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}")
      
    • Example CMakePresets.json

      Click to expand
      {
        "version": 5,
        "configurePresets": [
          {
            "name": "msys2-gcc-x64-ninja-debug",
            "displayName": "MSYS2 GCC x64 (Ninja) Debug",
            "description": "Using GCC x64 compiler with \"Ninja\" geneartor on MSYS2 - Debug",
            "generator": "Ninja",
            "binaryDir": "${sourceDir}/build/${presetName}",
            "installDir": "${sourceDir}/install/${presetName}",
            "environment": {
              "PATH": "C:\\msys64\\usr\\bin;$penv{PATH}"
            },
            "cacheVariables": {
              "CMAKE_C_COMPILER": "gcc.exe",
              "CMAKE_CXX_COMPILER": "g++.exe",
              "CMAKE_BUILD_TYPE": "Debug"
            }
          },
          {
            "name": "cygwin-gcc-x64-ninja-debug",
            "displayName": "Cygwin GCC x64 (Ninja) Debug",
            "description": "Using GCC x64 compiler with \"Ninja\" geneartor on Cygwin - Debug",
            "generator": "Ninja",
            "environment": {
              "PATH": "C:\\cygwin64\\bin;$penv{PATH}"
            },
            "binaryDir": "${sourceDir}/build/${presetName}",
            "installDir": "${sourceDir}/install/${presetName}",
            "cacheVariables": {
              "CMAKE_C_COMPILER": "gcc.exe",
              "CMAKE_CXX_COMPILER": "g++.exe",
              "CMAKE_BUILD_TYPE": "Debug"
            }
          }
        ]
      }
      
    • Demo of GCC/MSYS2 compilers

      Click to expand
      F:\GitRepo\cmake-msys-cygwin>cmake --preset msys2-gcc-x64-ninja-debug
      Preset CMake variables:
      
        CMAKE_BUILD_TYPE="Debug"
        CMAKE_CXX_COMPILER="g++.exe"
        CMAKE_C_COMPILER="gcc.exe"
        CMAKE_INSTALL_PREFIX:PATH="F:/GitRepo/cmake-msys-cygwin/install/msys2-gcc-x64-ninja-debug"
      
      Preset environment variables:
      
        PATH="C:\msys64\usr\bin;C:\Python\Python310\Scripts\;C:\Python\Python310\;C:\Program Files\Eclipse Foundation\jdk-8.0.302.8-hotspot\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\dotnet\;C:\Program Files\CMake\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\gsudo\;C:\Program Files\NASM;C:\Program Files\Git\cmd;C:\Program Files\Typora;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build;C:\Program Files (x86)\Pulse Secure\VC142.CRT\X64\;C:\Program Files (x86)\Pulse Secure\VC142.CRT\X86\;C:\Program Files (x86)\Common Files\Pulse Secure\TNC Client Plugin\;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Program Files\MySQL\MySQL Shell 8.0\bin\;C:\Users\hwhsu1231\AppData\Local\Microsoft\WindowsApps;C:\Users\hwhsu1231\.dotnet\tools;"
      
      -- The C compiler identification is GNU 11.3.0
      -- The CXX compiler identification is GNU 11.3.0
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: C:/msys64/usr/bin/gcc.exe - skipped
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Check for working CXX compiler: C:/msys64/usr/bin/g++.exe - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      CMAKE_SYSTEM_NAME = Windows
      -- Configuring done
      -- Generating done
      -- Build files have been written to: F:/GitRepo/cmake-msys-cygwin/build/msys2-gcc-x64-ninja-debug
      
    • Demo of GCC/Cygwin compilers

      Click to expand
      F:\GitRepo\cmake-msys-cygwin>cmake --preset cygwin-gcc-x64-ninja-debug 
      Preset CMake variables:
      
        CMAKE_BUILD_TYPE="Debug"
        CMAKE_CXX_COMPILER="g++.exe"
        CMAKE_C_COMPILER="gcc.exe"
        CMAKE_INSTALL_PREFIX:PATH="F:/GitRepo/cmake-msys-cygwin/install/cygwin-gcc-x64-ninja-debug"
      
      Preset environment variables:
      
        PATH="C:\cygwin64\bin;C:\Python\Python310\Scripts\;C:\Python\Python310\;C:\Program Files\Eclipse Foundation\jdk-8.0.302.8-hotspot\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\dotnet\;C:\Program Files\CMake\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\gsudo\;C:\Program Files\NASM;C:\Program Files\Git\cmd;C:\Program Files\Typora;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build;C:\Program Files (x86)\Pulse Secure\VC142.CRT\X64\;C:\Program Files (x86)\Pulse Secure\VC142.CRT\X86\;C:\Program Files (x86)\Common Files\Pulse Secure\TNC Client Plugin\;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Program Files\MySQL\MySQL Shell 8.0\bin\;C:\Users\hwhsu1231\AppData\Local\Microsoft\WindowsApps;C:\Users\hwhsu1231\.dotnet\tools;"
      
      -- The C compiler identification is GNU 11.3.0
      -- The CXX compiler identification is GNU 11.3.0
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: C:/cygwin64/bin/gcc.exe - skipped
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Check for working CXX compiler: C:/cygwin64/bin/g++.exe - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      CMAKE_SYSTEM_NAME = Windows
      -- Configuring done
      -- Generating done
      -- Build files have been written to: F:/GitRepo/cmake-msys-cygwin/build/cygwin-gcc-x64-ninja-debug
      
    opened by hwhsu1231 2
Releases(v1.11.0)
  • v1.11.0(Nov 2, 2022)

    • Update to fmt lib version 9.1.0 #2346, #2485, #2512, #2517 . Thanks @sylveon, @YunchengLiu, @tt4g, @tycho and @vitaut
    • Fix template instantiation warning #2336 . Thanks @aengusjiang
    • Event handlers improvements #2342, #2375 . Thanks @espkk and @kslattery
    • Allow modifying the used Android buffer ID #2358. Thanks @tiolan
    • Fix clone in async test #2364. Thanks @stkw0
    • Custom formatting optimization #2365. Thanks @conr2d
    • Fix C++14 builds for gcc 4.x (#2333) #2372 . Thanks @kslattery
    • Add minor version to CMake's SOVERSION #2376
    • Allow compilation with FMT_ENFORCE_COMPILE_STRING #2381. Thanks @john4744
    • Fix pkg-config generation #2383. Thanks @alexshpilkin
    • Remove unused code from null_mutex #2385. Thanks @panzhongxian
    • Fix redundant std::move #2396. Thanks @polesapart
    • Remove the empty file if in first period in hourly logger #2386. Thanks @panzhongxian
    • Add reset_overrun_counter() function to the async logging #2399 Thanks @bergen4
    • Set C++20 in CMake when SPDLOG_USE_STD_FORMAT option is turned on #2402. Thanks @cookcocck
    • Fix mingw test #2415. Thanks @neheb
    • Support for any std::chrono::duration type in flush_every(..) #2439. Thanks @LucasChollet
    • Fix implicit casting of level_enum #2443. Thanks @ibmibmibm
    • Comment fix #2445. Thanks @Hish15
    • Fix gcc 4.x build #2449. Thanks @Simon-Janos
    • Add openSUSE installation instructions #2468. Thanks @LorenDB
    • Fixed missing include file in stopwatch.h #2434. Thanks @fabianbuettner
    • Support for omitting source info by defining SPDLOG_NO_SOURCE_LOC #2476. Thanks @nigels-com
    • Added SPDLOG_BUILD_PIC build option to CMake #2475. Thanks @nigels-com
    • Fix include windows.h #2495. Thanks @panicgh
    • Workaround gcc 12 warnings #2498, #2499 . Thanks @offa
    • Migrate to Github Actions CI #2500. Thanks @offa
    • Replace iterator difference with std::distance #2509 Thanks @kin4stat
    • Export targets file to build directory at configure time #2514, #2515. Thanks @puneetmatharu
    • MongoDB sink improvements #2519. Thanks @sandorzm
    • Fix shadow warning in dist_sink #2431. Thanks @MohammadKanan for reporting.
    • Fixed msvc warning C4800 in win_eventlog_sink
    • Check IsDebuggerPresent() in msvc_sink before doing actual work #2408. To use old behavior pass false to the msvc_sink constructor. Thanks @DominikGrabiec and @sylveon

    Special thanks to @tt4g for helping with community questions and issues.

    Source code(tar.gz)
    Source code(zip)
  • v1.10.0(Apr 4, 2022)

    • Bump fmt to version 8.1.1.
    • Added file event handlers #2165, #2169 Thanks @seker. You can get callbacks from spdlog before/after log file has been opened or closed. This is useful for cleanup procedures or for adding something to the start/end of the log files. Example:
      void file_events_example()
      {
        // pass the spdlog::file_event_handlers to file sinks for open/close log file notifications
        spdlog::file_event_handlers handlers;
        handlers.before_open = [](spdlog::filename_t filename) { spdlog::info("Before opening {}", filename); };
        handlers.after_open = [](spdlog::filename_t filename, std::FILE *fstream) { fputs("After opening\n", fstream); };
        handlers.before_close = [](spdlog::filename_t filename, std::FILE *fstream) { fputs("Before closing\n", fstream); };
        handlers.after_close = [](spdlog::filename_t filename) { spdlog::info("After closing {}", filename); };
        auto my_logger = spdlog::basic_logger_st("some_logger", "logs/events-sample.txt", true, handlers);        
      }
    
    • Fixed rotating file sink: when disk is full log rotation resulted zero size log files. #2261. (thanks @kishorekrd for reporting).
    • Added new udp_sink #2090. Thanks @CJLove
    • (Experimental) Option to depend on std::format instead of fmtlib (set SPDLOG_USE_STD_FORMAT and use C++20). #2170 Thanks @sylveon .
    • Improved file name for hourly file sink #2047. Thanks @seker .
    • Added code location information for error handler #2048. Thanks @D-r-P-3-p-p-3-r .
    • Fixed qt_sinks ctor #2056. Thanks @mguludag .
    • List Debian instructions in the README #2057. Thanks @mr-c ,
    • Updated to latest Travis CI Build Status #2094. Thanks @jspraul .
    • Fixed unhandled errors in udp sink. #2096. Thanks @mmarkeloff .
    • CMake improvement regarding cmake_minimum_required and policy. #2098. Thanks @reddwarf69 .
    • Fixed mongo_sink compile in older gcc versions #2102 . Thanks @yzz-ihep .
    • Remove mutable keyword from mutex_ member in of sinks. #2140 . Thanks @sunlong169 .
    • Fix typos #2171. Thanks @rex4539 .
    • Fixed udp sink build on FreeBSD #2172. Thanks @keith-dev .
    • Avoid c-style casting in stdout sinks. #2179. Thanks @ibmibmibm .
    • Fixed tweakme.h compile error under msvcs when SPDLOG_FUNCTION is defined #2182. Thanks @Light3039 .
    • Fixed compiling errors on AIX #2181. Thanks @lisr .
    • Fixed runtime when build with -fsanitize=cfi #1972. Thanks @bansan85 .
    • Remove extraneous semicolon #2190. Thanks @sylveon.
    • Added example how to replace default logger. #2194. Thanks @rioki .
    • Fixed usage of ranges and to_hex in the same compile unit #2195. Thanks @patrickroocks .
    • Reduce warnings with pedantic compiler -Wuseless-cast #2216. Thanks @vnepogodin .
    • Support using std::span in to_hex #2228. Thanks @timblechmann .
    • Reset current size if rotated files on open #2234. Thanks @SpriteOvO .
    • Allow forward-declaration of level_enum #2245. Thanks @daverigby .
    • Call localtime() only if pattern_formatter really needs it #2246. Thanks @doug1234 .
    • Removed unneeded spaces from code. #2249. Thanks @PixelParas .
    • Added a few missing files/directories to the gitignore #2255. Thanks @LeonBrands .
    • Fixed issue #2201 (Pattern width is not applied for missing source information). #2269. Thanks @kyuheon-kr .
    • Limit max number of rotating files to 200000. (Fixed #1905). Thanks @surfycui (#2273)
    • pattern_formatter: fix reorder-ctor warning #2278. Thanks @adriweb .
    • Fixed spdlogConfig.cmake when built with SPDLOG_FMT_EXTERNAL_HO #2300. Thanks @adamcalhoon .
    • Fixed fopen_s(..) error handling when PREVENT_CHILD_FD is defined #2305. Thanks @nUl1.
    • Fixed compiler error when building on Windows with #define UNICODE #2317. Thanks @risa2000 .
    • Added option to enable formatting of systemd sink #2324, #2320. Thanks @Delgan .
    • Added optional "ident" argument to systemd sink constructor #2328. Thanks @Delgan .

    Special thanks to @tt4g for his support in answering community questions and issues.

    Source code(tar.gz)
    Source code(zip)
  • v1.9.2(Aug 12, 2021)

    • Fixed clang compiler errors when using spdlog in c++20. Thanks @dkavolis (#2037, #2034).
    • Fixed the Qt sinks to accurately trim the newline chars. Thanks @MadMax411 (#2015).
    • Improved and simplified Qt sinks implementation. Thanks @mguludag (#2016, #2018).
    • Fixed macro SPDLOG_LEVEL_NAME_xxx to always translate to the spdlog namespace. Thanks @ashley-b for reporting (#2022).
    • Fixed typo in readme. Thanks @p-ranav (#2024).
    • Fixed the MongoDB sink compilation in c++11. Thanks @jabartek (#2025).
    • Fixed double include of same file in thread_pool.h . Thanks @hbwang15 (#2026).
    • Ensure that the CMake exported package is relocatable. Thanks @daverigby (#2029).
    • Remove std::distance usage for possible performance gain. Thanks @neheb (#2030).
    • Support of inclusion of bin_to_hex.h in any order with spdlog.h. Thanks @dmerkushov (#2035).
    • Fixed install instructions for "header only" dir. Thanks @madeso (#2036).
    Source code(tar.gz)
    Source code(zip)
  • v1.9.1(Jul 27, 2021)

    • Support for {fmt}'s compile time validation of format strings (#2008). Thanks @dkavolis ! In C++20:

      spdlog::info("{:d}", "bad format_arg"); // should not compile
      

      In C++14/17 - format string can be validated at compile time using FMT_STRING:

      spdlog::info(FMT_STRING("{:d}"), "bad format_arg");  // should not compile
      
    • Fixed compilation error in Clang 13 with C++20 (#2011, #2013) Thanks @sjanel !

    Source code(tar.gz)
    Source code(zip)
  • v1.9.0(Jul 20, 2021)

    What's new

    • Support for {fmt} lib version 8.x.
    • New MongoDB sink #1981 . Thanks @mguludag.
    • New QTextEdit and QPlainTextEdit sinks #1986. Thanks @mguludag.

    Fixes and Improvements

    • Fixed #1790 (build failed with v140_xp, v141_xp toolset flags ). Thanks @LonghronShen.
    • Fixed #1916 (fix Xcode compiler warning). Thanks @haifengkao.
    • Made mutex member variable mutable #1918. Thanks @matt77hias.
    • Changed c-style casts to reinterpret casts in tcp_client #1924. Thanks @ lnovey .
    • Fix #533 . Rethrnow non std exceptions.
    • Avoid harmless warning about unreachable statement in MSVS build #1930. Thanks @vadz.
    • Fixed warning about testing _WIN64 which might be undefined #1931. THanks @vadz.
    • Small code improvement (std::find) #1933. Thanks @neheb .
    • Added support for CMake policy CMP0077 #1946. Thanks @JB-55,
    • Allow compilation with nvc++ (and possibly PGI) #1958. Thanks @mlund .
    • Fixed C++20 build resulting in deprecated implicit copy assignment operator warning #1961. Thanks @JB-55.
    • Fix signed/unsigned mismatch in VS #1970 . Thanks @bansan85.
    • Use std::function for the global error handler #1971. Thanks @SpriteOvO .
    • Fixed dup sink compile warnings in older compilers with back_inserter.
    • Added a color-terminal type #1984 to the color terminals list - to show colors in in RISC-V64 machines. Thanks @hctym1995.
    Source code(tar.gz)
    Source code(zip)
  • v1.8.5(Mar 25, 2021)

  • v1.8.4(Mar 25, 2021)

  • v1.8.3(Mar 24, 2021)

    • New hourly file sink . Creates new file every hour. Can be limited to retain only the last N files. Thanks @BVonk (#1763).
    • New daily sink filename custom formatting. Users now can pass custom strftime pattern to the log filename. For example: daily_logger_format_mt("loggername", "log-%Y%m%d:%H:%M.txt", hours, minutes);. Thanks @fawdlstty (#1847).
    • Fix windows event sink log compilation with UNICODE preprocessor. Thanks @iko1 (#1760).
    • Add SPDLOG_DISABLE_DEFAULT_LOGGER as a CMake option. Thanks @shimaowo (#1765, #1766).
    • Improve color terminal detection. Thanks @dominicpoeschko (#1768).
    • Prevent windows color sink to leak windows headers into user code Thanks @Ryan-rsm-McKenzie (#1771).
    • Ensure SPDLOG_FMT_EXTERNAL is honored in the bench program. Thanks @Ryan-rsm-McKenzie (#1773).
    • Skip CMake module mode when finding fmt. Thanks @Ryan-rsm-McKenzie (#1774).
    • Better support for "/" separators on Windows, and improve wchar filename test coverage. Thanks @sylveon (#1787).
    • Open files with "ab" mode even if truncating to better support logrotate(8). Thanks @graydon (#1795).
    • Fix compiling error and typo in hourly file sink. Thanks @sillykelvin (#1805).
    • Add constexpr to SPDLOG_LEVEL_NAMES declaration. Thanks @gv-me (#1798).
    • Initializer list style consistency. Thanks @ChristianPanov (#1807).
    • Fix call to non-constexpr function (#1811).
    • Better numeric_limits<>::max/min fix when SPDLOG_WCHAR_TO_UTF8_SUPPORT is defined. Thanks @NukeULater (#1819).
    • Fix to prevent MSVC warning flags to propagate to CUDA. Thanks @prateek9623 (#1825, #1829).
    • Fix windows stdout_sink raising exception when used GUI Windows Apps that lack a console. Thanks @dgehri for reporting (#1828).
    • Simplified wincolor sink code and intensify the red and yellow colors.
    • Set default value to registry::err_handler_ to resolve Klocwork warning. . Thanks @jneruda (#1835).
    • Formatter bench: Fix compilation by avoiding function name decay mechanics. Thanks @MathiasMagnus (#1846).
    • Add build2 package support in readme. Thanks @Klaim (#1851).
    • Make sure __cplusplus is defined under msvc CMakeLists.txt
    • Fixed VS2019 W4 cast warning (#1876).
    • Fix warning whe the compilation flag -Wswitch-default is present. Thanks @imsherlock (#1882).
    Source code(tar.gz)
    Source code(zip)
  • v1.8.2(Dec 11, 2020)

    • Bump fmt to version 7.1.3
    • Download automatically googlebenchmark for bench tests (#1709) Thanks @kitattyor.
    • Add CPack debian package settings (#1712) and fix typo in comment (#1711). Thanks @ChristofKaufmann.
    • Perfect forwarding fmt arguments (#1726). Thanks @dkavolis.
    • Fix dup_filter_sink to log current log call's level, instead of the filtered log call's level (#1710). Thanks @Tridacnid for reporting.
    • Ability to get size of messages queue of async thread pool (#1735) Thanks @o2gy84.
    • Add missing include (#1742). Thanks @jwittbrodt.
    • Updated bin_to_hex example in the readme (#1744). Thanks @ArnaudBienner.
    • Fix async periodic flush test (#1749). Thanks @bluescarni.
    Source code(tar.gz)
    Source code(zip)
  • v1.8.1(Sep 30, 2020)

    • Fixed load_env_levels() and load_argv_levels() #1680 (thanks @Tridacnid ).
    • Fixed stdout sink that produced extra carriage returns on Windows #1675 (thanks @chris-t-w ).
    • Fixed msvc_sink including windows.h #1667 (thanks @Ryan-rsm-McKenzie).
    • Fixed stopwatch's clock to use chrono::steady_clock #1676 (thanks @SuperWig).
    • Added support for Rcpp (R cpp compiler) #1685 (thanks @eddelbuettel).
    Source code(tar.gz)
    Source code(zip)
  • v1.8.0(Sep 1, 2020)

    • Upgraded bundled fmt to version 7.0.3.
    • New stopwatch utility for quick & easy logging of elapsed time:
    #include "spdlog/stopwatch.h"
    void stopwatch_example()
    {
        spdlog::stopwatch sw;    
        // do some work..
        spdlog::debug("Elapsed: {} seconds", sw);    // =>  "Elapsed 0.005116733 seconds"
        spdlog::debug("Elapsed: {:.3} seconds", sw);  // =>  "Elapsed 0.005 seconds"
    }
    
    • Raised CMake requirement to 3.10 and cleanup CMakeLists.txt (#1624). Thanks @tambry.
    • Added get_level() and should_log() functions to the spdlog:: namespace (#1628). Thanks @eyalroz.
    • Fixed tcp_client for macOS (#1640). Thanks @dkruempe.
    • Fixed cfg::load_env_levels() function declaration (#1651). Thanks @bareya.
    • Updated Fedora install info in the readme (#1653). Thanks @gk6k6k.
    • Fixed #1617 (aligned function pattern flag is broken). Thanks @VelocityRa for reporting.
    • Fixed #1581 (compiling under msys in win10).
    Source code(tar.gz)
    Source code(zip)
  • v1.7.0(Jul 9, 2020)

    • Support for using external fmt version 7.x (bundled version is 6.2.1). Thanks @candrews .(22bee8128a4150ce37cf761ed9a609ad891848a6).
    • Fixed to_hex segmentation fault (#1611, 19f280466195f347f3f2c474556a6be0b343a7fb). Thanks @vitaut, @xvitaly, @kekePower and @lgbaldoni.
    • Support for FMT_STRING compile time checking. Thanks @Tridacnid (30ee6904011cdfc57c7f7b72997aed9cb15a74df).
    • Fixed shared library building failure on Windows with non MSVC. Thanks @podsvirov (fe97a03033c8731ded971ca0a6c86cebd2b047b6).
    • Fixed mingw testcase. Thanks @podsvirov (075dcee0429932ae9fd23d72d1cb2c5c2dda3efe).
    • Clean CMakeLists.txt. Thanks @Pospelove (cf55e5d4f8af102d80011b0cc048a002e2090c2c).
    Source code(tar.gz)
    Source code(zip)
  • v1.6.1(May 26, 2020)

    • Fixed deadlock in daily_file_sink that happened while cleaning older files. Thanks @IIFE for reporting(#1570) and for fixing(#1571).

    • Fixed ringbuffer_sink::last_raw() and ringbuffer_sink::last_formatted() that didn't return latest elements. Thanks @vekkuli for reporting and fixing (#1563).

    • Fixed missing symbol wstr_to_utf8buf(..) in windows dll build. Thanks @haquocviet for reporting (#1569).

    • Bumped bundled fmt to version 6.2.1.

    Source code(tar.gz)
    Source code(zip)
  • v1.6.0(May 15, 2020)

    What's new

    • Load log levels from environment variable SPDLOG_LEVEL :
    #include "spdlog/cfg/env.h"
    ...
    spdlog::cfg::load_env_levels(); 
    
    $ # set log level to debug
    $  SPDLOG_LEVEL=debug && ./example
    
    $ # set to info except for mylogger which is set to trace:
    $ SPDLOG_LEVEL=info,mylogger=trace  && ./example
    
    $ # turn off all logging except for mylogger which is set to debug::
    $ SPDLOG_LEVEL=off,mylogger=debug && ./example
    
    • Load log levels from argv (e.g. ./example SPDLOG_LEVEL=debug):
    #include "spdlog/cfg/argv.h"
    ...
    spdlog::cfg::load_argv_levels(argc, argv);
    
    
    • New windows eventlog sink . Thanks @ban-dana (#1418).

    • New tcp sink that sends log messages in tcp to a remote server. Thanks @Proheeler (#1426).

    • Extend spdlog with your own flags in the log pattern. See wiki for details.

    • Support for building spdlog as dll under windows. Thanks vejmartin (#1467, 3b732783482568081fd3e274ce2e793a89aded92, 5b3a18319e1759a6244ef1e80ab22f71f4811ab1).

    • Bump the bundled fmt version to 6.2.0 .

    Fixes and Improvements

    • Prevent race condition when SPDLOG_PREVENT_CHILD_FD is defined. Thanks @dominicpoeschko (#1423).

    • Fix race condition in the filename() function in the file sinks. Thanks @tt4g (#1430, #1431).

    • Fix ansicolor_sink::set_color(..) - can cause memory violation if user provides a custom color code that points to stack memory (#1540, 0b36d4e360ad89b30bf9c57d208542a0486cc587). Thanks @caizongchao for reporting.

    • Fix potential buffer overflow in color_sinks if creating multiple color sinks in the same logger and one of them has a pattern without color flags (#1452, 64de8807e269cc5d562bdcf981ee8f5de7bd6168). Thanks @dominicpoeschko for reporting.

    • Optimize cases when string_view is passed to the logger to avoid unnecessary fmt::format. Thanks dominicpoeschko (#1424) .

    • Support for max files in daily logger - delete oldest files after creating the daily file. Thanks @ruoshui1314 (#1394).

    • Fix deprecated warning with C++14 and external fmt lib (#1439). Thanks @ClausKlein for reporting.

    • Optimize colos sinks to use std::array instead of map to find color codes (695912c7cf1b3ce59401f73bd7b18a666a77cda6, 4b7c05903b99718accbb4eaa93b25a0686307479). Thanks @qis for the suggestion.

    • Fix Win32 event log sink compilation. Thanks @Crunkle (#1444).

    • Don't include windows.h in common.h. Thanks @ghost (#1453).

    • Resolve erroneous clang-tidy warning about using a moved from pointer. Thanks @Ruffel (#1457).

    • Fixed numerous clang-tidy warnings.

    • Added options to to_hex to output hex like hexdump. Thanks @ngugcx (#1472).

    • Fix Windows setenv check. Thanks @Crunkle (#1475).

    • Removed the 'SPDLOG_NO_NAME` macro in tweakme.h and cmake.

    • Added a forward declaration header spdlog\fwd.h . Thanks @horenmar for the suggestion (#1481).

    • Moved throw to dedicated function to optimize compile-time and runtime-performance. Thanks @horenmar for the suggestion (#1483).

    • Fix a build issue when SPDLOG_PREVENT_CHILD_FD is defined. Thanks @Naios (#1487).

    • Fix issue with using external fmt (#1480). Thanks @nalinigans for reporting.

    • Minor performance optimizations in pattern formatter (ca9c83f824270a7ee1d183f29faa01262f810fd6, 76389e057fca1ea158d79785f668808a088d5d3a, 7766bc25d116e5d14de1e95dfb548f6e2e0c3680, d38bd138cd5f12b3c6fbd2d70506fff54fb39962)

    • Fixed on Android compilation #1527. Thanks @Bizyroth for reporting.

    • Add log function to the logger API to allow logging with custom timepoint. #1521 - Thanks @ron003 .

    • Fix missing exported symbol when building spdlog.dll in windows (#1535, 348c4380d695ee9d177360ce8804e4468bf0902f). Thanks @plmzod for reporting.

    • Dropped meson support.

    • Fix typos and tabs in the code. Thanks @waywardmonkeys (#1536) .

    • CMake: Fix GNUInstallDirs include location Thanks @vitlav (#1407).

    • CMake: workaround for Unknown extension ".c" for file issue . Thanks @niamster (#1442).

    • CMake: Support CPack RPM generation. Thanks @tcraigtyler (#1451).

    • CMake: Disabled extra warnings generation by default. Use SPDLOG_BUILD_WARNINGS=ON to enable again. Thanks @Glamhoth (#1503 02802af97f9552ce511896a112bab0ab1ffbe99a, 644073300243261a2605c36d7c79692f0fcddf0d, 1f7f1c1ffb60c8a58fe0523f8cf0c96932904aef)

    • CMake: Support for precompiled headers with SPDLOG_ENABLE_PCH flag. Thanks @OlivierLDff (#1484).

    • CMake: Add /WX MSVC compiler option for only if mscv compiler is used. Thanks @trondhe (#1495).

    • CMake: Set minimum version of fmt to 5.3.0. Thanks @Montellese (#1525).

    • CMake: Fix tabs, whitespaces and eol. Thanks @waywardmonkeys (#1537).

    • Tests: removed duplicate entry for count_lines(). Thanks @emmenlau (#1417).

    • Tests: don't run spdlog-utests and spdlog-utests-ho in parallel. Thanks @tt4g (#1421).

    • Tests: Enable running the tests against an installed copy of spdlog. Thanks @mr-c (#1422).

    • Tests: Support empty SPDLOG_EOL. Thanks @emmenlau (#1414).

    • README: add conda as a supported package manager . Thanks @avrahamshukron (#1473).

    • README: Replace yaourt withyay` pacakge manage for archlinux. Thanks @zyansheep (#1494).

    Source code(tar.gz)
    Source code(zip)
  • v1.5.0(Jan 13, 2020)

    New features

    • Added ringbuffer sink. Thanks @eudoxos (#1307).
    • Auto create the required logging directories if they do not exist (9b7812a0f22f4743ee1618c7d879c8f30004253d).
    • Update bundled fmt to version 6.1.2.
    • Added the optional ! modifier to truncate the result if the field size exceeds the specified width (see wiki for details).

    Fixes and improvements

    • Fix build failure on clang 7 with libc++. Thanks @jktjkt (a03f9eb1561e738b9111e731d5f183c5b6093d71).
    • Fix some spelling errors. Thanks @flopp .
    • Fix - compilation when using external fmt library. Thanks @dvhwgumby for reporting (#1273).
    • Fix location of CMake config info. Thanks @dvhwgumby for reporting (#1274)
    • Fix missing include (9a68bd8cc8d721cc1c3a988c62229679df7b88be).
    • CMake code duplication improvement. Thanks @bencsikandrei (#1283)
    • CMake improvments in tests . Thanks @Andrei-Florin BENCSIK (2cc620ef33f7299e0c0ff05c629df7ccf0d35ce8)
    • Remove unused variable. Thanks @masmullin2000 (#1285)
    • Fix tests to Use _FILE_OFFSET_BITS=64 when building on Linux 32-bit systems. Thanks @yipdw (#1288).
    • Improve systemd journald support. Thanks @jktjkt (#1292).
    • Improve log macros. Thanks @pck (#1294).
    • Removed lazy argument evaluation from macros (#163).
    • Some micro optimizations (79468cf, 3ee4f28, bf40855).
    • Correctly guard SetHandleInformation API call to better support compiling for UWP. Thanks @sylveon (#1296).
    • Exclude from compilation prevent_child_fd() if SPDLOG_PREVENT_CHILD_FD not defined (57085c8)
    • CMake - Added tweakme options to CMakeLists.txt (18edb8b).
    • Removed SPDLOG_NO_DATETIME option.
    • Fix meson tests build . Thanks vedranmiletic fore reporting (#1295, c081919, 4a4f13b, 436ce16).
    • Use #include" <spdlog/.*> instead of spdlog/.* across the codebase. Thanks @RedDwarf69 (#1304).
    • Fix struct tm doesn't have tm_gmtoff in ISO C. Thanks @lancesun (ff3e6c7248a0bfb1d44e72fd0f822320178263bc, #1306)
    • Always cache gmt offset (de2c07a).
    • Optimize backtracer operator= (255f7f2).
    • Fix some clang-tidy warnings (93008b2, bff8572, 3999613).
    • Fix compiler error in os-inl.h min/max on Windows (#1302).
    • Remove redundant semicolon. Thanks @inhzus (#1311).
    • Fix compiler warnings. Thanks @0x8000-0000 (#1331).
    • Fix missing include header in `spdlog/sinks/daily_file_sink.h. Thanks @afoolsbag for reporting (#1332).
    • Fix elapsed time larger than 6 digits ignores alignment width. Thanks @ivan236634452 for reporting (#1327).
    • Set version for shared library in meson build. Thanks @lgbaldoni (#1337).
    • Improved dist_sink ctor. Thanks @mmakhalaf for reporting (#1298).
    • Fix #1325. Added SPDLOG_FMT_EXTERNAL_HO option. Thanks @steffenb7333 for reporting.
    • Fix #1340 (missing include). Thanks @jeanga for reporting.
    • Fix compile on Win10 with Cygwin. Thanks @frfrankkopp and @tt4g (#1347).
    • Fixed #1348. Thanks @ficzerepeti for reporting.
    • CMakeLists.txt allow overriding the cpp standard to higher than 11
    • Fix a small problem in the basic example. Thanks @mike239x (#1367).
    • Fix invalid meson option. Thanks @segfault-magnet (#1370).
    • meson: add fallback to fmt dependency #1378. Thanks @idanko
    • Update docs: spdlog now available in conan center, bincrafters repo is deprecated #1387. Thanks @gocarlos .
    Source code(tar.gz)
    Source code(zip)
  • v1.4.2(Oct 8, 2019)

    Fix some issues discovered by users:

    • Set additional CPACK variables for RPM generator (#1246). Thanks @tcraigtyler.
    • Fix compile when SPDLOG_WCHAR_FILENAMES is defined (#1249 ).
    • Fix stdout color sink under Windows to better handle cases when no console available (#1250).
    • Fix windows compile error where std::max is overriden by a macro. (#1251, #1252). Thanks @bsergean.
    • CMakeLists.txt: Moved the installed lib to CMAKE_INSTALL_LIBDIR (#1253). Thanks @DasRoteSkelett.
    • CMakeLists.txt: Fixed pkg-config generation (cf2bf488a22373b46eee36513335ff0e44355abc, fb70eca0a31f65953551eb646039205a4d94172c). Thanks @SammyEnigma.
    Source code(tar.gz)
    Source code(zip)
  • v1.4.1(Sep 23, 2019)

    Fix few issues discovered by users of 1.4.0

    • Added pkgconfig file to CMake install - Thanks @orbea for reporting and fixing (#1237 #1238).
    • Fix regression in wchar support under windows. Thanks @Bak-Jin-Hyeong for reporting and fixing (#1239 #1240).
    • CMake: Do not install bundled fmt if SPDLOG_FMT_EXTERNAL is defined. Thanks @orbea (#1241).
    Source code(tar.gz)
    Source code(zip)
  • v1.4.0(Sep 21, 2019)

    Improvements

    • spdlog can now be compiled as a static or shared lib (thanks @DavidZemon for the help). Using the compiled lib improves greatly compile times when using spdlog and is very recommended.
      $ cd spdlog && mkdir build && cd build
      # Build is static lib (pass -DSPDLOG_BUILD_SHARED=ON for building as shared lib)
      $ cmake .. && make -j
      
    • Upgraded to the latest and greatest fmt library version 6.0.0. Thanks @tgpfeiffer (and to @vitaut for fmt!).
    • Support for -fno-exceptions (disabled by default). Enabling this will replace all throw() statements in spdlog with std::abort(). To enable, pass -DSPDLOG_NO_EXCEPTIONS=ON to CMake before building spdlog.
    • support for building spdlog with meson. Thanks @mensinda
    • Backtrace support - store debug/trace messages in a ring buffer to display later on demand. Very useful (thanks @MathijsV for the idea):
    
    spdlog::enable_backtrace(32); // create ring buffer with capacity of 32  messages
    // or my_logger->enable_backtrace(32)..
    for(int i = 0; i < 100; i++)
    {
      spdlog::debug("Backtrace message {}", i); // not logged yet.. 
    }
    // e.g. if some error happened:
    spdlog::dump_backtrace(); // log them now! show the last 32 messages
    // or my_logger->dump_backtrace(32)..
    
    • Systemd support. Thanks @WarShoe (#1027)
    • Support for cleaning old files in daily_logger.
    • Numerous CMake build improvements. Thanks @DavidZemon , @jktjkt , @ksergey , @mnemotic , @cneumann , @dpacbach , @FrancoisChabot , @myd7349 , @matt77hias
    • Better support for various Unix BSDs (DragonFly, NetBSD, FreeBSD, OpenBSD). Thanks @jbeich (#1234)
    • Provide source location support for systemd sink. Thanks @jbelloncastro (#1122)
    • Added fmt::(w)string_view support. Thanks @matt77hias (#1139)
    • Add option to force color output without TTY . Thanks @psalz (#1175)
    • Add more overloads to spdlog::log and spdlog::logger::log. Thanks @sylveon (@1169)
    • Add public API spdlog::initialize_logger for create loggers manually. Thanks @tt4g (#1035)
    • Expose should_do_colors_ in ansicolor_sink.h. Thanks Florian Wörter (#1022)
    • Add tweak support for user short level names. Thanks @MFornander (#996)
    • Add method to filesinks to return filename. Thanks @markniebur (#978)
    • rotating_sink: Add option to rotate on open. Thanks @pwm1234 (#958)
    • Allow filename/line number at all levels. Add function name %! support. Thanks @possiblyhuman (#956)
    • New dups_filter sink -duplicate message removal sink. It will skip a message if previous one is identical and less than "max_skip_duration" old.
    • New '%o', '%i', '%u', '%O' format flags - Display elapsed time in mills/micros/nanos/seconds since previous message.
    • Some minor pattern formatter performance improvements.

    Fixes

    • Fix Wundef in os-inl.h. Thanks @AMS21 (#1189)
    • Fix use of old style cast in os-inl.h. Thanks @AMS21 (#1164)
    • Prevent NEAR and FAR macro definitions from leaking on Windows platforms. Thanks @PeterTh (#1142)
    • Fix syslog output. Thanks @mattiasj-axis (#1140)
    • Fix msg.time in daily_file_sink. Thanks @s-shin (#1129)
    • Fix missing include for null_mutex in rotating_file_sink.h. Thanks @casperevan (#1120)
    • Fix warning: redundant move in return statement. Thanks @MarkKoester (#1119)
    • Fix use of incomplete type in stdout sinks. Thanks @DanielChabrowski (#1118)
    • Fix deprecation warnings in filename_to_str and improve performance of wbuf_to_utf8buf. Thanks @sylveon (#1127)
    • Update README.md. Thanks @martinkrammer (#1057)
    • Remove extra semicolon. Thanks @Jerry-Ma (#1202)
    • Fix unexpected log macro expansion. Thanks @db-panda (#1055)
    • Namespace qualify stat functions. Thanks @p-po (#1045)
    • Fix typo in Android logger. Thanks @romainthomas (#994)
    • Remove unnecessary log function. Thanks @DanielChabrowski (#988)
    • Allow custom formatter in sink's ctor. Thanks @DanielChabrowski (#986)
    • Fix shadowed parameter. Thanks @ZGCDDoo (#984)
    • Update log_msg.h. Thanks @scribam (#969)
    • Fix #benchmark link error. Thanks @myd7349 (#962)
    • Fix typo in file_helper.h. Thanks @brridder (#955)
    Source code(tar.gz)
    Source code(zip)
  • v1.3.1(Jan 18, 2019)

    Fix few issues found by 1.3.0 users:

    • Fix google benchmark link error when compiling the bechmarks. Thanks @myd7349 (#961, f4c737ef4253d309453606a3c81861dfd572411e)
    • Fix spdlog not printing message if SPDLOG_NO_THREAD_ID is defined. Thanks @scribam (#970, f4c737ef4253d309453606a3c81861dfd572411e)
    • Fix depending on the order of inclusion of spdlog.h. Thanks @gocarlos (#959, 23fdc0eae426ac2efadf9f4bb1f43caae1667bc7)
    Source code(tar.gz)
    Source code(zip)
  • v1.3.0(Jan 11, 2019)

    Improvements

    • Upgraded to the latest and greatest fmt library version 5.3.0.

    • New API for default logger spdlog::trace(..), spdlog::debug(..), spdlog::info(..), etc. For convenience, spdlog now creates a default global logger (to stdout, colored and multithreaded). It can be used easily by calling spdlog::info(..), spdlog::debug(..), etc directly without any preparations.

      It's instance can be replaced to any other logger (shared_ptr):

      spdlog::set_default_logger(some_other_logger);
      spdlog::info("Use the new default logger");
      
    • Alignment support in log patterns. Each pattern flag can be aligned by prepending a width number(upto 128). Use-(left align) or = (center align) to control the align side:

      | align | meaning| example | result| | :------ | :-------: | :-----: | :-----: | |%<width><flag>|Align to the right|%8l|"    info"| |%-<width><flag>|Align to the left|%-8l|"info    "| |%=<width><flag>|Align to the center|%=8l|"  info  "|

    • Support for logging source filename, line number, and function name (thanks @possiblyhuman for contributing to this effort)

      | flag | meaning| example | | :------ | :-------: | :-----: | |%@|Source file and line (use SPDLOG_TRACE(..),SPDLOG_INFO(...) etc.)|my_file.cpp:123| |%s|Source file (use SPDLOG_TRACE(..),SPDLOG_INFO(...) etc.)|my_file.cpp| |%#|Source line (use SPDLOG_TRACE(..),SPDLOG_INFO(...) etc.)|123| |%!|Source function (use SPDLOG_TRACE(..),SPDLOG_INFO(...) etc. see tweakme for pretty-print)|my_func|

    • Support for compile time check of log levels using #define SPDLOG_ACTIVE_LEVEL <level>. Use LOG_TRACE(..), LOG_DEBUG(..), LOG_INFO(..), etc. to enable. Those macros check at compile time the log level and translate to empty statement if the log level is not high enough. Even if a log macro evaluate to a log call, the macro will check at runtime the level before evaluating its arguments. So for example the following won't evaluate some_costly_function() because the logger's level is error:

      #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG
      #include "spdlog/spdlog.h"
       ..
       spdlog::set_level(error);
       SPDLOG_DEBUG("Some costly arg: {}", some_costly_function());
      
    • CMake improvements. Thanks @dpacbach (85b4d7c, f5dc166 ).

    • Numerous small performance optimizations.

    • Global option that disables global registration of loggers set_automatic_registration(bool). Thanks @pabloariasal (#892).

    • Optimize logging of C strings by using string_view to avoid unnecessary copy. Thanks @peergynt (cb71fea0f6c9bb5722ca59e9b7917328217cfe5d).

    • Use google benchmark to test latencies.

    Fixes

    • logger::error_handler() should be const (#881, thanks @shoreadmin for reporting)
    • Cleanup header file: remove log_msg.h include from fmt_helper.h. Thanks @peergynt (1b391ccd062e013f6e0a991a3f37c3ce31eab87d)
    • Fix log_msg constructor doesn't initialize all fields (#888. Thanks @curiouserrandy for reporting).
    • Change log_msg&& to log_msg& params. Thanks @rwen2012 (794a636dd3cebd59e49ef3a0bfaf8bfffc729bdd)
    • Fix typo in Android example. Thanks @ZaMaZaN4iK (f5a27250b1c701bb3317fa2ad6332fd893f26ab1)
    • Fix Compiling error VS2017 #902 (Thanks @JaNurz for reprting).
    • Fix thread id is prefixed with zeros #908 (Thanks @klrakiranpradeep for reporting).
    • Fix OSX build. Thanks @DanielChabrowski (c7f42d1a4a1fe94ad11031a00858abdce2385cb2).
    • Fix and optimize usage of fmt::internal::count_digits(..) for better support 32/64 bits. Thanks @DanielChabrowski (c7f42d1a4a1fe94ad11031a00858abdce2385cb2, f1ab6feba2fcd7d05aae8022787eeb76dbef41eb).
    • Better handling of rotation errors (b64e4464a77caca658982b8fe919db05c4f29f36).
    • Fix exceptions on file size calculation on Windows XP x64 and Windows Server 2003 x64. Thanks @lestera (#926).
    • Do not attempt to default operator= when it is implicitly deleted. Thanks @dpacbach (63a475d88c2bf5be21bf6abd4a487909862e97de).
    • Make an implicit cast from int --> uint32_t explicit. Thanks @dpacbach (a6152ebadd676d7f5a3a50e49eb995aa05d97112).
    • Enable testing in the Travis config file. Thanks @dpacbach (f5dc16603ee97b77f9945e29b4f4864afdde2652).
    • Fix the text alignment in the example. Thanks @bzindovic (d6086da4856df510657ffe4ef6b894e902b4b83).
    • Fix typos. Thanks @peergynt (ce8cf1e152b3b51f4121f6b58ddcf3797090a1f4).
    • Fix handling of external fmt lib in cmake. Thanks @cneumann (084bc72d90ccc829b8605297cbef4ef6cc3093b9).
    • Fix VC WinRT compilation. Thanks @taniey for reporting (@948).
    • Fix typo in file_helper.h. Thanks @brridder (fb702f989ff7141c71712e9d2c6a3fd642f7c206).
    Source code(tar.gz)
    Source code(zip)
  • v1.2.1(Oct 17, 2018)

  • v1.2.0(Oct 7, 2018)

    Improvements

    • Upgraded to latest fmt version 5.2.1.
    • Binary data logging using spdlog::to_hex(binary_data). Many types of std::container<char> can be logged in hex. See usage examples.
    • Added logger->clone() to ease the creation of new loggers from an existing one.
    • Numerous micro optimizations across the lib.
    • Added set_sinks method to dist_sink for atomic updating set of sinks in dist_sink. Thanks @jwnimmer-tri .
    • Improved CmakeLists.txt to better handle third-party usage. Thanks @taketwo .

    Fixes

    • Fixed wchar logging (supported only in windows. #851 , #764).
    • Fixed registry test. Thanks @DanielChabrowski .
    • Removed invalid files from tests.sln. Thanks @yhchen .
    • Some fixes to console_globals.h includes. Thanks @DanielChabrowski
    • Don't deny access to log files from other processes under windows. Thanks @eruiz.
    • Pessimizing move remove. Thanks @maciekgajewski
    • ansicolor_sink.h - add missing sink include. Thanks @AlexanderDalshov .
    • Improved rotating sink error handling.
    • Fixed Readme. Thanks @blackball .
    • Fixed some clang tidy warnings.
    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Aug 15, 2018)

    Bug fixes

    • Fixed android sink compilation. Thanks @rajesh-p .
    • Fixed race condition in async-factory.
    • Fixed bug in spdlog_ex implementation .Thanks @gajanak for reporting.
    • Fixed race condition in the unit tests.
    • Fixed compiler warnings under OSX. Thanks @baishuai .

    Improvements

    • Some micro optimizations.
    • Improve and fix CMake issues. Thanks @DanielChabrowski .
    • Improve and fix travis-ci issues. Thanks @DanielChabrowski .
    • Added overrun_counter() to the async thread pool queue - returns # of messages overrun under the overrun_oldest mode. Thanks @indiosmo .
    • Fixed some clang tidy warnings.
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Aug 5, 2018)

    Version 1.0.0 is a major release with numerous features and improvements. It contains some breaking API changes that are not compatible with 0.x versions (see below).

    Highlights

    • Include what you need: Reduce compilation times by including only the minimum required. Users can now to include only the actual sinks/features they need from spdlog/sinks folder.

    • Upgrade to fmt lib version 5.1 - thanks @vitaut for this great lib.

    • Support for custom formatting per sink - each sink can have it's own formatting and level using sink->set_pattern(..) or sink->set_formatter(..).

    • async logging - thread pool - async loggers now share a global thread pool by default. Creating and destroying async loggers is cheap now. This is in contrast to previous versions were creating async loggers was expensive, since each logger instance had its own worker thread and queue. The global thread pool and can be configured using spdlog::init_thread_pool(queue_size, worker_threads) or created directly using make_shared.

    • periodic flusher: spdlog::flush_every(seconds) to periodically flush all registered loggers.

    • Improved performance - by caching some recently used values in the pattern formatter.

    • Ability to add sinks to a logger after its creation (but it is not thread safe to do so - so use with caution).

    Breaking changes

    • Include what you need. For example to use basic_logger add #include "spdlog/sinks/basic_file_sink.h" (see example in readme).

    • To use async loggers - include "spdlog/async.h"

    • Replaced set_async_mode(..) with factory template. For example:

     auto logger= spdlog::rotating_logger_mt<spdlog::async_factory>(...);
    
    • Removed printf support.

    • Removed warmup/teardown functions from async.

    • Custom sinks inheriting from sinks::base_sink need to format (if needed) the message before sending to their target. For example

    void sink_it_(const details::log_msg &msg) override
    {
      fmt::memory_buffer formatted;
      sink::formatter_->format(msg, formatted);
      // sink the formatted
      ...   
    }
    
    • Added clone() virtual function to the formatter interface.

    • Removed support for #define SPDLOG_NO_REGISTRY_MUTEX

    Change log

    See here the complete list of changes.

    Source code(tar.gz)
    Source code(zip)
  • v0.17.0(May 21, 2018)

    Summary

    • Improvements in color output impl - thanks @Qix-
    • Fixed spelling - thanks @rcarmich
    • New function to convert level_enum from string - thanks @fegomes
    • Support for custom EOL per formatter - thanks Emad William Farag
    • Make set_color public in wincolor_sink to retain configurability - thanks Benjamin Schindler
    • Fix compilation error with GCC 8 - thanks @ColinDuquesnoy
    • CMake improvements - thanks @DanielChabrowski , @grzadr and @yisonPylkita
    • Bumped bundled fmt version to 4.1.0
    • Fixed tests for older gcc compilers
    • Moved to clang source code formatter - thanks @DanielChabrowski
    • Fixed many clang-tidy warnings - thanks @DanielChabrowski
    • Fix implicit conversion warnings - thanks @tbastos
    • Added Added: g3log, log4cplus, log4cpp, p7. Changes: boost, easylogging, g2log to bench - thanks @kasru
    • Support for color formatting. using the %^ and %$ format flags.
    • Added new sink to contrib: step_logger - thanks @Puasonych
    • Replaced the lockfree queue with bounded, locked queue - this greatly improves CPU usage and memory footprint in async mode (with some cost to latency due to the mutex locking).
    Source code(tar.gz)
    Source code(zip)
  • v0.16.3(Jan 12, 2018)

    Summary

    • Fix sleep issue (#609) under MSVC that happens when changing the clock backwards (pull #610) - Thanks @joaomoreno
    • Ensure that marcos always expand to expressions (pull #604) - Thanks @sam-lunt
    • Add global flush_on function (pull #605) - Thanks @sam-lunt
    • Fix conversion warning (#595, pull #596) - Thanks @Broekman
    Source code(tar.gz)
    Source code(zip)
  • v0.16.2(Dec 22, 2017)

  • v0.16.1(Dec 20, 2017)

    Summary

    Quick fix release:

    • Fixed the version strings to 0.16.1 in spdlog.h and CMakeLists.txt
    • Fixed compiler warning in tests - Thanks @horar
    Source code(tar.gz)
    Source code(zip)
  • v0.16.0(Dec 19, 2017)

    Summary

    • Rotating and daily log files keep their extension (e.g "mylog.3.txt" and not "mylog.txt.3")
    • Optional support for printf formatting (enabled using #define SPDLOG_FMT_PRINTF) - Thanks @fogo
    • Async log: increased sleep to to 500ms the worker in loop when the queue is empty
    • Fixed thread safety bug in flush() - added lock on flush in base_sink
    • Breaking change: Removed all *_if functions (trace_if, debug_if, info_if,..) because they are redundant and confusing way to preform simple if
    • Swallow only std::exceptions. report about, and re-throw other, unexpected exception types.
    • Support msvc_sink on all windows compiler (windebug-sink) - Thanks @jpcima
    • Added facilty param for syslog - Thanks @adubovikov
    • correct include path for sink/syslog_sink.h - Thanks @jpcima
    • Fix include paths - Thanks @daylanKifky
    • Some fixes in the async queue size estimation - Thanks @Subenle
    • Fixed cygwin support
    • Adding additional build environments for AppVeyor- Thanks @rkollataj
    • Fix warnings which are caused by C style cast - Thanks @knowledge4igor
    • Make short month names match in length - Thanks @berkus
    • Fix typos in code and comments - Thanks @berkus
    • Fixed missing i_formatter implementation
    • Fix SPDLOG_WCHAR_TO_UTF8_SUPPORT wchar_t logging - Thanks @hestad
    • Added formatter for unix epoch time in seconds (%E format flag) - Thanks @jasonbeach
    • Compiler-dependent line numbering in SPDLOG_TRACE - Thanks @elelel
    • Improved cmake and CMakeLists.txt - Thanks @mrpelotazo and @Lectem
    Source code(tar.gz)
    Source code(zip)
  • v0.14.0(Aug 19, 2017)

    Summary

    • Upgraded the bundled fmt lib to version 4.0.0
    • Fixed crash in async logger in older gcc version 4.8.5 (268222e496d32e3c6f450f7242655cf014dc93e8).
    • Fixed various sanitizer warnings.
    • Improved Android support (#422, #427).
    • Add an optional final qualifier to types (#425) for potential compiler optimisations.
    • Support for Alpine Linux (#435, #436).
    • Add wide string to utf8 string support (#442).
    • Don't use color escape codes if terminal doesn't support them bd25f59a423ac40a0eba4206ad295b3e2cef7dfc .
    • Optional message counter feature (#445).
    • Fix OSX builds of details/os.h (#447).
    • Fix vs 2015 build error (#449).
    • UTC support (#451).
    • MinGw build fix (#456).
    • Add create_async factory functions for async loggers (#459).
    • Conditional logging implementation (#460).
    • More meaningful thread id for OSX (#463).
    • Add set_color to ansicolor_sink (#465).
    • Ability to override log level names in the log messages (#473).
    • Added TRACE_IF and DEBUG_IF macro definitions when TRACE_ON and DEBUG.
    • Fixed background color bug in windows terminal (#484).
    • Gentoo support (#502).
    • Fixed warning for missing enumeration value in tests (#488, #490).
    • Fixed numerous typos in code and comments.

    Many thanks to the contributors to this release:

    • @odeits
    • @vitaut
    • @eliaskosunen
    • Oleksii Mandrychenko
    • @theamirocohen
    • @jcelerier
    • @alzix
    • @bahostetterlewis
    • @sidyhe
    • @stonedreamforest
    • @ThePhD
    • @rkollataj
    • Carsten Neumann
    • @asit-dhal
    • @sheldonlyr
    • @SWIFTingAround
    • @p-alik
    • @snapbug
    • @vgabi94
    • @gg7
    Source code(tar.gz)
    Source code(zip)
Owner
Gabi Melman
Gabi Melman
Reckless logging. Low-latency, high-throughput, asynchronous logging library for C++.

Introduction Reckless is an extremely low-latency, high-throughput logging library. It was created because I needed to perform extensive diagnostic lo

Mattias Flodin 445 Dec 20, 2022
Colorful Logging is a simple and efficient library allowing for logging and benchmarking.

Colorful-Logging "Colorful Logging" is a library allowing for simple and efficient logging as well for benchmarking. What can you use it for? -Obvious

Mateusz Antkiewicz 1 Feb 17, 2022
Fast C++ logging library.

spdlog Very fast, header-only/compiled, C++ logging library. Install Header only version Copy the source folder to your build tree and use a C++11 com

Gabi Melman 16.6k Jan 1, 2023
A Fast and Convenient C++ Logging Library for Low-latency or Real-time Environments

xtr What is it? XTR is a C++ logging library aimed at applications with low-latency or real-time requirements. The cost of log statements is minimised

null 10 Jul 17, 2022
Yet another logging library.

Blackhole - eating your logs with pleasure Blackhole is an attribute-based logger with strong focus on gaining maximum performance as possible for suc

Evgeny Safronov 191 Dec 20, 2022
A lightweight C++ logging library

Loguru: a lightweight and flexible C++ logging library. At a glance Documentation Documentation can be found at https://emilk.github.io/loguru/index.h

Emil Ernerfeldt 1.5k Jan 7, 2023
Portable, simple and extensible C++ logging library

Plog - portable, simple and extensible C++ logging library Pretty powerful logging library in about 1000 lines of code Introduction Hello log! Feature

Sergey Podobry 1.6k Dec 29, 2022
Asynchronous Low Latency C++ Logging Library

Quill Asynchronous Low Latency C++ Logging Library Introduction Features Performance Supported Platforms And Compilers Basic Usage CMake Integration D

Odysseas Georgoudis 677 Dec 20, 2022
Cute Log is a C++ Library that competes to be a unique logging tool.

Cute Log Cute Log is a C++ Library that competes to be a unique logging tool. Version: 2 Installation Click "Code" on the main repo page (This one.).

null 3 Oct 13, 2022
fmtlog is a performant fmtlib-style logging library with latency in nanoseconds.

fmtlog fmtlog is a performant asynchronous logging library using fmt library format. Features Faster - lower runtime latency than NanoLog and higher t

Meng Rao 443 Jan 6, 2023
Minimalistic logging library with threads and manual callstacks

Minimalistic logging library with threads and manual callstacks

Sergey Kosarevsky 20 Dec 5, 2022
logog is a portable C++ library to facilitate logging of real-time events in performance-oriented applications

logog is a portable C++ library to facilitate logging of real-time events in performance-oriented applications, such as games. It is especially appropriate for projects that have constrained memory and constrained CPU requirements.

John Byrd 46 Oct 21, 2020
Boost Logging library

Boost.Log, part of collection of the Boost C++ Libraries, provides tools for adding logging to libraries and applications. Directories build - Boost.L

Boost.org 157 Dec 22, 2022
C++ implementation of the Google logging module

Google Logging Library The Google Logging Library (glog) implements application-level logging. The library provides logging APIs based on C++-style st

Google 5.9k Jan 9, 2023
log4cplus is a simple to use C++ logging API providing thread-safe, flexible, and arbitrarily granular control over log management and configuration. It is modelled after the Java log4j API.

% log4cplus README Short Description log4cplus is a simple to use C++17 logging API providing thread--safe, flexible, and arbitrarily granular control

null 1.4k Jan 4, 2023
Uberlog - Cross platform multi-process C++ logging system

uberlog uberlog is a cross platform C++ logging system that is: Small Fast Robust Runs on Linux, Windows, OSX MIT License Small Two headers, and three

IMQS Software 15 Sep 29, 2022
Fast binary logger for C++

Highlights Logs messages in a compact binary format Fast Hundreds of millions of logs per second Average latency of 2-7 ns for basic data types See be

Pranav 175 Dec 23, 2022
Reckless logging. Low-latency, high-throughput, asynchronous logging library for C++.

Introduction Reckless is an extremely low-latency, high-throughput logging library. It was created because I needed to perform extensive diagnostic lo

Mattias Flodin 445 Dec 20, 2022