Fast C++ logging library.
#include "spdlog/mdc.h"
..
spdlog::mdc::put("mdc_key_1", "mdc_value_1");
spdlog::info("Hello, {}", "World!"); // => [2024-04-26 02:08:05.040] [info] [mdc_key_1:mdc_value_1] Hello, World!
std::string_view
overloads for logger accessor by @BenLeadbetter in https://github.com/gabime/spdlog/pull/3023
Full Changelog: https://github.com/gabime/spdlog/compare/v1.13.0...v1.14.0
Special thanks to @tt4g for helping with community questions and issues.
CMAKE_BUILD_TYPE
only for single-config generators (#2839). Thanks to @moritz-h.spdlog_header_only
in build directory export (#2846). Thanks to @robertmaynard.SPDLOG_TO_VERSION
to compare spdlog version (#2853). Thanks to @kegechen.async_overflow_policy::discard_new
(#2876). Thanks to @walkerlala.syslog_sink.h
's syslog_prio_from_level
protected (#2918). Thanks to @shannonbooth.pthread_threadid_np
for iOS (#2897). Thanks to @lowdesertpunk..git-blame-ignore-revs
to ignore clang-format related commits (#2899). Thanks to @lowdesertpunk.SPDLOG_CONSTEXPR_FUNC
to FMT_CONSTEXPR
(#2901). Thanks to @kkraus14.fd_
is not nullptr in file_helper
to prevent possible crash if disk is full (#2972).systemd_sink.h
(#2919). Thanks to @M010.example.cpp
to fix the vector issue in bin_example
(#2963). Thanks to @zhuzhzh.circular_q::size()
(#2820).circular_q
.policy_max
from cmake_minimum_required(..)
.clang-format
to google style and updated various formatting scripts.Special thanks to @tt4g for helping with community questions and issues.
QTextEdit
widget with some nice colors.#include
to a deprecated fmt header (#2545) .Thanks @kromain.dup_filter_sink
(#2549, #2563). Thanks @zydxhs and @zhuyadong.msvc_sink
(#2573). Thanks @naddu77.SPDLOG_SYSTEM_INCLUDES
) cmake option (#2575). Thanks @dpayne.tcp_client
sink for FreeBSD (#2590). Thanks @segoon.newlib C
library configurations without tm_gmtoff field (#2600). Thanks @igrr.spdlog::sinks::dist_sink
(#2599). Thanks @robinlinden.sync()
function to file_helper (#2343). Thanks @espkk.callback_sink
(#2610). Thanks @maghorbani.systemd sink
(#2619). Thanks @chardin-cpi.apply_logger_env_levels()
(#2648, #2649). Thanks @afshinpir.msvc_sink
(#2651). Thanks @Demonese.systemd_sink
tests in linux pipeline (#2669). Thanks @MyNameIsLame.fflush()
behaviour inconsistency (#2646). Thanks @25077667.Special thanks to @tt4g for helping with community questions and issues.
SOVERSION
#2376pkg-config
generation #2383. Thanks @alexshpilkinnull_mutex
#2385. Thanks @panzhongxianstd::move
#2396. Thanks @polesapartreset_overrun_counter()
function to the async logging #2399 Thanks @bergen4std::chrono::duration
type in flush_every(..)
#2439. Thanks @LucasCholletstopwatch.h
#2434. Thanks @fabianbuettnerSPDLOG_NO_SOURCE_LOC
#2476. Thanks @nigels-comSPDLOG_BUILD_PIC
build option to CMake #2475. Thanks @nigels-comwindows.h
#2495. Thanks @panicghstd::distance
#2509 Thanks @kin4statIsDebuggerPresent()
in msvc_sink
before doing actual work #2408. To use old behavior pass false to the msvc_sink constructor
. Thanks @DominikGrabiec and @sylveonSpecial thanks to @tt4g for helping with community questions and issues.
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);
}
SPDLOG_USE_STD_FORMAT
and use C++20). #2170 Thanks @sylveon .cmake_minimum_required
and policy. #2098. Thanks @reddwarf69 .tweakme.h
compile error under msvcs when SPDLOG_FUNCTION
is defined #2182. Thanks @Light3039 .to_hex
in the same compile unit #2195. Thanks @patrickroocks .std::span
in to_hex
#2228. Thanks @timblechmann .pattern_formatter
really needs it #2246. Thanks @doug1234 .pattern_formatter
: fix reorder-ctor warning #2278. Thanks @adriweb .SPDLOG_FMT_EXTERNAL_HO
#2300. Thanks @adamcalhoon .fopen_s(..)
error handling when PREVENT_CHILD_FD
is defined #2305. Thanks @nUl1.Special thanks to @tt4g for his support in answering community questions and issues.
SPDLOG_LEVEL_NAME_xxx
to always translate to the spdlog
namespace. Thanks @ashley-b for reporting (#2022).thread_pool.h
. Thanks @hbwang15 (#2026).std::distance
usage for possible performance gain. Thanks @neheb (#2030).bin_to_hex.h
in any order with spdlog.h
. Thanks @dmerkushov (#2035).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 !
Fix compiling with C++17: remove constexpr
on level_string_views. Thanks @stevenlunt (#1889).