v1.3.0
版本发布时间: 2019-01-11 22:23:03
gabime/spdlog最新发布版本:v1.14.1(2024-04-30 20:34:26)
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());
-
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&&
tolog_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).