Releases: gabime/spdlog
Version 1.6.0
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, 3b73278, 5b3a183).
-
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, 0b36d4e). 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, 64de880). 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 ofmap
to find color codes (695912c, 4b7c059). Thanks @qis for the suggestion. -
Fix Win32 event log sink compilation. Thanks @Crunkle (#1444).
-
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 likehexdump
. Thanks @ngugcx (#1472). -
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 (ca9c83f, 76389e0, 7766bc2, d38bd13)
-
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, 348c438). 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 02802af, 6440733, 1f7f1c1) -
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).
-
README: add conda as a supported package manager . Thanks @avrahamshukron (#1473).
-
README: Replace
yaourt with
yay` pacakge manage for archlinux. Thanks @zyansheep (#1494).
Version 1.5.0
New features
- Added ringbuffer sink. Thanks @eudoxos (#1307).
- Auto create the required logging directories if they do not exist (9b7812a).
- 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 (a03f9eb).
- 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 (9a68bd8).
- CMake code duplication improvement. Thanks @bencsikandrei (#1283)
- CMake improvments in tests . Thanks @Andrei-Florin BENCSIK (2cc620e)
- 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 ofspdlog/.*
across the codebase. Thanks @reddwarf69 (#1304). - Fix struct tm doesn't have tm_gmtoff in ISO C. Thanks @LanceSun (ff3e6c7, #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 .
Version 1.4.2
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 (cf2bf48, fb70eca). Thanks @SammyEnigma.
Version 1.4.1
Fix few issues discovered by users of 1.4.0
Version 1.4.0
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)
Version 1.3.1
Fix few issues found by 1.3.0 users:
Version 1.3.0
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 callingspdlog::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>
.
UseLOG_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 evaluatesome_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());
-
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 (cb71fea). -
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 (1b391cc)
- Fix log_msg constructor doesn't initialize all fields (#888. Thanks @curiouserrandy for reporting).
- Change
log_msg&&
tolog_msg&
params. Thanks @rwen2012 (794a636) - Fix typo in Android example. Thanks @zamazan4ik (f5a2725)
- 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 (c7f42d1).
- Fix and optimize usage of
fmt::internal::count_digits(..)
for better support 32/64 bits. Thanks @DanielChabrowski (c7f42d1, f1ab6fe). - Better handling of rotation errors (b64e446).
- 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 (63a475d).
- Make an implicit cast from int --> uint32_t explicit. Thanks @dpacbach (a6152eb).
- Enable testing in the Travis config file. Thanks @dpacbach (f5dc166).
- Fix the text alignment in the example. Thanks @bzindovic (d6086da4856df510657ffe4ef6b894e902b4b83).
- Fix typos. Thanks @peergynt (ce8cf1e).
- Fix handling of external fmt lib in cmake. Thanks @cneumann (084bc72).
- Fix VC WinRT compilation. Thanks @taniey for reporting (@948).
- Fix typo in file_helper.h. Thanks @brridder (fb702f9).
Version 1.2.1
This fixes a compilation error of dist_sink.h (#864) . Thanks @DimRochette !
Version 1.2.0
Improvements
- Upgraded to latest fmt version 5.2.1.
- Binary data logging using
spdlog::to_hex(binary_data)
. Many types ofstd::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.
Version 1.1.0
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 theoverrun_oldest
mode. Thanks @indiosmo . - Fixed some clang tidy warnings.