1
0
mirror of https://github.com/gabime/spdlog.git synced 2025-04-29 20:13:52 +00:00

Compare commits

...

3088 Commits

Author SHA1 Message Date
Hinageshi
548b264254
Fix warning C4530 (#3393)
* Fix warning C4530

* Rename FMT_EXCEPTIONS to FMT_USE_EXCEPTIONS
2025-04-23 19:46:25 +03:00
Tihran Katolikian
847db3375f
dup_filter_sink: remove notification_level argument; use last message log level for notification instead (#3390) 2025-04-18 20:45:56 +03:00
Dmitry Kozlovtsev
bb8694b50f
Fix links for #3380 (#3381) 2025-04-14 19:22:47 +03:00
Christoph Gringmuth
cec28bf839
Fix links to local reference. (#3378)
Enables local navigation in IDE and removes links to branch.
2025-04-10 17:58:19 +03:00
Gabi Melman
bd0609d7a0
Update README.md 2025-04-10 17:06:12 +03:00
Christoph Gringmuth
1f4959c832
Fix link to wiki. (#3377) 2025-04-10 17:04:23 +03:00
gabime
48bcf39a66 Version 1.15.2 2025-03-29 14:01:07 +03:00
Gabi Melman
9c58257480
Fix zformatter on Apple and POSIX.1-2024 conforming platform (#3366)
* Add test case for #3351 (wrong GMT offset in SunOS/Solaris fallback)

* Fix #3352 (Missing test for Apple / POSIX.1-2024 chooses buggy workaround)

Apple platforms have had the tm_gmtoff-field at least since Mac OS X 10.0,
as are POSIX.1-2024 conforming systems, which are also required to support
it.

This has the unfortunate effect to use the SunOS/Solaris fallback, which
doesn't compute the correct value if the passed value of tm isn't the
current system time, i.e. localtime(::time()) (#3351).

* Fixed GMT offset test

---------

Co-authored-by: toh <toh@ableton.com>
2025-03-29 13:44:11 +03:00
gabime
faa0a7a9c5 Bump fmt to version 11.1.4 2025-03-17 16:56:21 +02:00
Gabi Melman
10320184df
Fixed issue #3360 (#3361) 2025-03-17 15:46:31 +02:00
Александр
3335c380a0
Update README.md (#3338)
How to install this package in ALT Linux.
2025-02-11 19:10:50 +02:00
Gabi Melman
f355b3d58f Fix test_daily_logger 2025-02-01 13:08:54 +02:00
Gabi Melman
ac432c3602
Gabime/v1.15.1 (#3332)
* Updated bundled fmt to version 11.1.3

* Bump version to 1.15.1
2025-02-01 12:09:54 +02:00
Janusz Chorko
3c23c27d2d
Revert "fix: Compatibility with external fmtlib 11.1.1 (#3312)" (#3331)
This reverts commit 7f8060d5b280eac9786f92ac74d263cc8359c5ed.
2025-02-01 11:15:04 +02:00
Ken Matsui
ae1de0dc8c
Support custom environment variables for load_env_levels (#3327)
SPDLOG_LEVEL is currently supported to control log levels via
load_env_levels.

This patch adds support for other environment variable names, such as
MYAPP_LEVEL, for load_env_levels.
2025-01-23 23:00:23 +02:00
Gabi Melman
7cbf2a6967
Gabime/ansicolor sink improvements (#3323)
* Added lock to set_color_mode in asnicolor_sink

* Added const qualifiers to some ansicolor_sink functions
2025-01-18 11:58:32 +02:00
Alexander
57505989b7
SPDLOG_LEVEL_NAMES, comment use string_view_literals (#3291)
* SPDLOG_LEVEL_NAMES, comment use string_view_literals

* SPDLOG_LEVEL_NAMES, comment use string_view_literals
2025-01-18 11:57:43 +02:00
gabime
96a7d2a1d4 Format CMakeLists.txt 2025-01-12 08:37:47 +02:00
Gabi Melman
d71555306a
Added SPDLOG_FWRITE_UNLOCKED option to CMakeLists.txt (#3318)
* Added SPDLOG_FWRITE_UNLOCKED option to CMakeLists.txt

* Update CMakeLists.txt
2025-01-12 08:02:39 +02:00
koniarik
ad0f31c009
Enabled bin_to_hex utest for stdformat, fixed std::formatter (#3315)
* Enabled bin_to_hex utest for stdformat, and fixed std::formatter

* fixed usage of \ in macos.yml

* explicitly cast diff variable in test_sink

* moved from ::iterator to decltype

* added fix for custom callbacks

---------

Co-authored-by: Jan Koniarik <veverak@Jans-MacBook-Pro.local>
2025-01-11 17:21:39 +02:00
jdrouhard
96a8f6250c
fix: remove unused to_string_view overload in fmt >= 11.1 (#3314) 2025-01-10 00:58:46 +02:00
Christian Blichmann
7f8060d5b2
fix: Compatibility with external fmtlib 11.1.1 (#3312)
Include fmtlib's `xchar` header to include `fmt::basic_format_string`.
Otherwise, compilation with an external fmtlib 11.1.1 fails with

```
In file included from include/spdlog/spdlog.h:12:
include/spdlog/common.h:369:49: error: no template named 'basic_format_string' in namespace 'fmt'; did you mean 'std::basic_format_string'?
  369 | inline fmt::basic_string_view<T> to_string_view(fmt::basic_format_string<T, Args...> fmt) {
      |                                                 ^~~~~
```

Signed-off-by: Christian Blichmann <cblichmann@google.com>
2025-01-08 00:59:12 +02:00
Rui Chen
276ee5f5c0
fix: update to_string_view function for fmt 11.1 (#3301)
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-12-26 09:13:57 +02:00
Matteo Del Seppia
24dde318fe
Adding lock to rotate_now() (#3281) 2024-12-03 09:53:34 +02:00
Matteo Del Seppia
65e388e82b
Adding on demand truncation for basic file sinks (#3280)
* Adding support to truncate on demand for basic file sink

* Remove unnecessary file close

* Adding lock in basic_file_sink truncate()
2024-12-03 01:38:51 +02:00
Gabi Melman
1e6250e183
Gabime/fwrite unlocked (#3276)
* Use locking fwrite_unlocked if possible

* Added compile definitions to header_only
2024-12-01 14:16:52 +02:00
hjs-ast
951c5b9987
Allow manual rotation of rotating_file_sink (#3269)
* Allow manual rotation of rotating_file_sink

* Rename rotation method

* Attempted fix for tests on Windows

* Apply review mark-ups
2024-11-28 17:37:29 +02:00
Gabi Melman
15f539685b
Update null_sink to be final (#3267) 2024-11-25 00:32:47 +02:00
Gabi Melman
43dcb3982d
Update CMakeLists.txt comment 2024-11-22 12:14:47 +02:00
Gabi Melman
0efef2af24
Update CMakeLists.txt comment 2024-11-22 12:12:32 +02:00
Gabi Melman
018d8aa266
Update CMakeLists.txt 2024-11-22 12:10:53 +02:00
Gabi Melman
35b0417fbe
Update CMakeLists.txt comment 2024-11-22 12:09:48 +02:00
Gabi Melman
94526fa8e8
Update CMakeLists.txt comment 2024-11-22 12:07:39 +02:00
Gabi Melman
633003f40a
Update CMakeLists.txt comment 2024-11-22 11:50:05 +02:00
miyanyan
9edab1b5a1
pass /utf-8 only when compiler is MSVC (#3260) 2024-11-22 11:42:35 +02:00
LiAuTraver
1245bf8e8a
add explicit mt:: and std:: to avoid ambiguous call when both std::format_to and mt::format_to are present (#3259) 2024-11-18 16:41:27 +02:00
F1F88
51a0deca2c
docs: Removed duplicate line in daily_file_sink comment (#3249) 2024-11-09 21:41:00 +02:00
gabime
8e5613379f Version 1.15.0 2024-11-09 17:01:30 +02:00
Gabi Melman
7cee026baa
Added tsan to ci (#3247)
* Added tsan to ci
2024-11-08 17:42:04 +02:00
Gabi Melman
ebfa906952 CMake option to Enable/disable msvc /utf-8 flag (on by default) 2024-11-08 11:16:06 +02:00
Gabi Melman
68f6ec7af1 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2024-11-08 11:09:12 +02:00
Gabi Melman
d343d413c2 CMake option to Enable/disable msvc /utf-8 flag (on by default) 2024-11-08 11:09:05 +02:00
captainurist
fe4f99527d
Fix utf8_to_wstrbuf tests (#3245) 2024-11-06 00:08:36 +02:00
captainurist
5673e9e545
utf8_to_wstrbuf now handles invalid utf8 sequences (#3244) 2024-11-05 22:54:01 +02:00
gabime
63f0875000 Removed if in ci 2024-11-02 15:41:48 +02:00
Gabi Melman
5fd32e1a70
Update README.md 2024-11-02 15:38:52 +02:00
Gabi Melman
35345182f8
Update README.md (#3240) 2024-11-02 15:38:18 +02:00
Gabi Melman
3c2e002b51
ci-win-2019 (#3239)
Update ci
2024-11-02 15:27:34 +02:00
gabime
6192537d08 Fix win ci 2024-11-01 18:48:47 +02:00
gabime
6c7201553d Fix win ci 2024-11-01 18:41:17 +02:00
gabime
d939255f0e Fix win ci 2024-11-01 18:33:57 +02:00
gabime
ecc3881122 Fix win ci 2024-11-01 18:25:35 +02:00
gabime
bff1a6036a Fix win ci 2024-11-01 18:20:39 +02:00
gabime
6f2ead1a0e refactor win ci 2024-11-01 18:09:46 +02:00
gabime
92f9aa32ce refactor win ci 2024-11-01 18:09:01 +02:00
gabime
64d9b4e263 refactor win ci 2024-11-01 18:06:38 +02:00
gabime
3d3f71dbe2 Fix ci 2024-11-01 17:59:26 +02:00
gabime
3fec1a81b7 Fix ci 2024-11-01 17:56:07 +02:00
gabime
984a959883 Fix ci 2024-11-01 17:51:09 +02:00
gabime
7ecfb3bc9c Fix ci 2024-11-01 17:45:19 +02:00
gabime
614c3a6836 Fix ci 2024-11-01 17:33:25 +02:00
gabime
5dc356dcbe windows ci 2024-11-01 17:30:00 +02:00
gabime
a7eb388f84 windows ci wip 2024-11-01 17:21:21 +02:00
Gabi Melman
a5cfbf369d Revert "Better support for FMT_UNICODE in cmake"
This reverts commit d373093734f756da53e0e5e203c305a9614b9741.
2024-11-01 16:49:37 +02:00
Gabi Melman
d373093734 Better support for FMT_UNICODE in cmake 2024-11-01 16:44:15 +02:00
gabime
7a950e028c add /utf-8 flag for msvc 2024-11-01 15:18:44 +02:00
Gabi Melman
9fe79692eb
Gabime/tsan (#3237)
* Fixed race condition in tests

* Support for thread sanitizer
2024-11-01 15:14:27 +02:00
gabime
96c9a62bfd Fixed race condition in tests 2024-11-01 13:26:27 +02:00
Gabi Melman
85bdab0c18
Update bundled fmt to 11.0.2 (#3236) 2024-11-01 12:04:58 +02:00
Gabi Melman
63d1884215
Gabime/async flush (#3235)
* Revert "Ensure flush callback gets called in move-assign operator (#3232)"

This reverts commit b6da59447f165ad70a4e3ca1c575b14ea66d92c9.

* Revert "Exchange promise for condition_variable when flushing (fixes #3221) (#3228)"

This reverts commit 16e0d2e77c9b8c741b0b23d9def2db04de6b1b41.

* Revert PR #3049
2024-11-01 11:26:03 +02:00
Michael de Lang
b6da59447f
Ensure flush callback gets called in move-assign operator (#3232) 2024-10-30 17:55:45 +02:00
Michael de Lang
16e0d2e77c
Exchange promise for condition_variable when flushing (fixes #3221) (#3228)
std::promise and std::future use std::call_once under the hood, which requires
the tls-model to be at least initial_exec, excluding local_exec.

Furthermore, gcc has a bug regarding exceptions in std::call_once that
is best avoided. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66146
for more info.

Signed-off-by: Michael de Lang <kingoipo@gmail.com>
2024-10-28 22:38:01 +02:00
mq白
ee16895787
Improve Cross-Platform Build Instructions in Documentation (#3229)
* Update build

* Simplified build command length for cross-platform compatibility.

* Modified to replace `make -j` only with `cmake --build.`
2024-10-27 22:02:07 +02:00
hydai
e593f6695c
Fix warning - extra ';' for -Wextra-semi (#3198)
Signed-off-by: hydai <z54981220@gmail.com>
2024-09-23 15:39:32 +03:00
Gabi Melman
2c76e6101a
Fix #3194 - Use Sep instead of Sept for abbreviated month 2024-09-20 13:10:23 +03:00
薛定谔的加菲猫
bdd1dff378
Update CMakeLists.txt, Fix spelling errors (#3193) 2024-09-18 20:25:46 +03:00
Uilian Ries
ffd5aa41d6
Update conan install command in README (#3172)
Signed-off-by: Uilian Ries <uilianries@gmail.com>
2024-09-14 09:36:46 +03:00
Gabi Melman
c1fbafdcef
Update mdc.h (#3185)
Update error message
2024-09-12 22:49:58 +03:00
allen_qfl
362214a349
fix/issue-3101: fix the issue where mdc ignores SPDLOG_NO_TLS (#3184)
Co-authored-by: dyf <yufeng.duan@senscape.com.cn>
2024-09-12 22:27:25 +03:00
Leslie
2169a6f6ae
use std::lock_guard instead of std::unique_lock (#3179) 2024-09-11 22:18:51 +03:00
Rasmus
271f0f3b14
Add info about max_files in the docstrings of hourly/daily file sinks (#3170) 2024-09-09 16:54:03 +03:00
Eugene Smirnov
a3a0c9d663
compilation error gcc 8.5 with [-Werror=suggest-override] (#3158) 2024-08-27 04:04:04 +03:00
zjyhjqs
5ebfc92730
fix: set /Zc:__cplusplus and /MP to MSVC only (#3139)
1. macro `__cplusplus` is enabled by clang-cl
2. `/MP` is not supported by clang-cl (warning `-Wunused-command-line-argument` will be generated)
2024-07-22 13:37:28 +03:00
Alex Overchenko
885b5473e2
Fix building with FMT_ENFORCE_COMPILE_STRING (#3137) 2024-07-16 20:41:21 +03:00
Ziyao
d276069a6e
make example compatible with fmt 11 (#3130)
Since fmt 11.0.0, formatter::format() is required to be const. Mark
format() method in example as const to stay compatible with fmt 11.
2024-07-08 23:14:30 +03:00
Philippe Vaucher
eeb22c13bb
Allow customization of syslog_sink (#3124)
Thanks @Silex
2024-07-03 22:51:11 +03:00
Dominik Grabiec
c3aed4b683
Add wide character formatting and output support to wincolor_sink. (#3092)
Fixes printing of unicode characters to the windows console such as microsecond suffix for std::chrono types.
2024-05-22 00:20:17 +03:00
gabime
27cb4c7670 Added mdc example to readme 2024-04-30 13:14:29 +03:00
gabime
2d4acf8cc3 Added mdc example 2024-04-30 13:11:01 +03:00
gabime
3b4fd93bd0 Updated comment about mdc 2024-04-30 12:56:35 +03:00
gabime
2122eb2194 Update spdlog version to 1.14.1 2024-04-30 12:50:45 +03:00
gabime
22b0f4fc06 Clang format 2024-04-30 12:28:13 +03:00
Gabi Melman
37b847692e Revert pr #3023 (std::string_view overloads for logger accessor for c++17) 2024-04-30 12:13:00 +03:00
gabime
fa6605dc99 Fix compile 2024-04-29 19:52:34 +03:00
gabime
94a8e87c71 Fix #3079 2024-04-29 19:46:59 +03:00
gabime
238c9ffa5d Bump spdlog to version 1.14.0 2024-04-26 01:43:02 +03:00
gabime
3b4c775b5b Update comment about set_default_logger 2024-04-26 01:40:26 +03:00
gabime
3403f27898 Don't remove previous defaullt logger from registry in set_default_logger. Fix #3016 2024-04-26 01:32:10 +03:00
gabime
a34e08c7ff Added CMakeSettings.json to gitignore 2024-04-26 01:15:36 +03:00
gabime
71925ca382 Revmoed definition of deprecated fmt macros 2024-04-26 00:59:26 +03:00
gabime
fd61ea9348 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2024-04-26 00:52:48 +03:00
gabime
66ac83e703 Update gitginore to ignore .vs and out/build 2024-04-26 00:52:33 +03:00
gabime
dd6c9c6e43 Update comment 2024-04-26 00:51:28 +03:00
Gabi Melman
b7e0e2c237
Fix #3073 2024-04-26 00:04:00 +03:00
darallium
a0d2187d8f
README.md has include missing (#3066) 2024-04-25 21:26:08 +03:00
gabime
e3f5a4fe66 Update cmake to define FMT_LIB_EXPORT when building shared lib 2024-04-25 18:21:21 +03:00
Gabi Melman
1e7d7e0766 Updated bundled fmt to 10.2.1 2024-04-25 18:17:34 +03:00
Gabi Melman
a2b4262090
Update CMakeLists.txt to fix #3029 2024-04-05 11:13:36 +03:00
Gabi Melman
8fed530bdf
Update mdc.h 2024-03-29 22:11:09 +03:00
gabime
1253a57db6 Add mdc support for default format 2024-03-29 17:04:53 +03:00
gabime
cba66029e2 Update mdc 2024-03-29 16:57:55 +03:00
Gabi Melman
4517ce8b5c
Update mdc.h 2024-03-29 15:28:28 +03:00
Gabi Melman
1f93017403
Update mdc.h 2024-03-29 15:25:46 +03:00
Gabi Melman
f030afe696
Update mdc.h 2024-03-29 15:25:24 +03:00
Gabi Melman
2969dde400 Revert "Updated bundled fmt to 10.2.1"
This reverts commit d8e0ad46bfc2cad56f9a6d50cebc63bddd768633.
2024-03-29 14:46:41 +03:00
Gabi Melman
d8e0ad46bf Updated bundled fmt to 10.2.1 2024-03-28 21:01:15 +02:00
Gabi Melman
62302019ba
Update test_async.cpp 2024-03-24 10:16:22 +02:00
Gabi Melman
a19c76a4e7
Fix flush test in test_async.cpp 2024-03-24 10:15:04 +02:00
Gabi Melman
ec661f98dc
Update test_async.cpp 2024-03-23 21:23:29 +02:00
Kağan Can Şit
c9ce17abca
INSTALL.md has been updated to provide current status information. (#3052) 2024-03-23 17:29:46 +02:00
Yubin
6725584e27
Make async_logger::flush() synchronous and wait for the flush to complete (#3049) 2024-03-23 15:52:32 +02:00
shahar.valiano
6766f873d6
Remove the legacy AnalyzeTemporaryDtors option from .clang-tidy. (#3048)
This option was deprecated in clang-tidy-16, and removed in clang-tidy-18.
2024-03-23 11:28:13 +02:00
Tomas-Zhu
73e2e02b42
Fix #3038 (#3044)
* Fix #3038

* Fix #3038 again

---------

Co-authored-by: Tomas-Zhu <z773922114@gmail.com>
2024-03-21 12:16:11 +02:00
Massimiliano Riva
d03eb40c17
Added Mapped Diagnostic Context (MDC) support (#2907)
* Added Mapped Diagnostic Context (MDC) support

* Update include statement

* Optimize string creation

* Fix includes

* Fix padding rules in mdc empty case

* Add comment to describe the use of mdc formatter
2024-03-18 17:41:46 +02:00
gabime
23587b0d9a Fixed regisry-inl.h 2024-03-17 01:20:26 +02:00
gabime
819eb27c5d Use find if registry is bigger than 10 in registry::get(std::string_view logger_name) 2024-03-17 00:30:05 +02:00
gabime
4052bc0621 Use find if registry is bigger than 20 in registry::get(std::string_view logger_name) 2024-03-17 00:27:43 +02:00
gabime
8cfd4a7e7b Fixed bench dev_null 2024-03-17 00:17:21 +02:00
gabime
e15c505965 fix ci 2024-03-16 16:11:20 +02:00
gabime
42cd77d7e8 fix ci 2024-03-16 16:08:43 +02:00
gabime
c838945eac fix ci 2024-03-16 16:06:43 +02:00
gabime
0621a7ae49 fix ci 2024-03-16 16:02:55 +02:00
Gabi Melman
e0410f430e
Update ci.yml 2024-03-16 15:46:37 +02:00
magnus-nomono
ae525b75c3
Add missing include (#3026) 2024-03-10 02:10:32 +02:00
Alan Candido
a45c939040
Update stopwatch.h (#3034)
Adding elapsed time in milliseconds.
2024-03-09 21:40:05 +02:00
Leadbelly
5532231bbc
feature: adds string view overloads for logger accessor (#3023)
Co-authored-by: Ben Leadbetter <ben.leadbetter@native-instruments.com>
2024-02-29 10:53:56 +02:00
Gabi Melman
60faedb025
Update ci.yml 2024-02-29 09:56:11 +02:00
Gabi Melman
bc4b329585
Update ci.yml 2024-02-29 09:28:18 +02:00
Gabi Melman
75bfbb7c0c
Update ci.yml 2024-02-29 09:21:46 +02:00
Gabi Melman
3f0e400718
Update ci.yml 2024-02-29 09:04:33 +02:00
Gabi Melman
9a445245f1
Update ci.yml 2024-02-29 08:55:37 +02:00
spaceman
d387fdf96c
support MINGW (#3022)
Under Windows 10, compiling with MINGW64 will report an error similar to https://github.com/gabime/spdlog/issues/1581
2024-02-25 02:42:18 +02:00
Gabi Melman
134f9194bb
Update registry.h code formatting 2024-02-14 21:52:21 +02:00
cohdan
fe79bfcc51
Expose the flusher thread object to user in order to allow setting of thread name and thread affinity when needed (#3009)
* Expose the flusher thread object to user in order to allow setting of thread name and thread affinity when needed

* Code review fix - periodic_worker thread getter should return a reference and not a pointer
2024-02-14 21:48:44 +02:00
Dimitri Papadopoulos Orfanos
47b7e7c736
Fix typos found by codespell (#3011) 2024-02-12 23:02:31 +02:00
Enzo Gaban
696db97f67
docs: details about how compile time macros work (#2981) 2024-01-16 06:39:45 +02:00
liubing
8979f7fb2a
Also use _stat() on Windows to be more UTF8 friendly (#2978)
* Also use _stat() on Windows to be more UTF8 friendly

* Cosmetic changes
2024-01-13 23:46:18 +02:00
gabime
7c02e204c9 Bump version to 1.13.0 2024-01-12 12:12:27 +02:00
gabime
2aa8b6c971 Check fd_ is not nullptr in file_helper 2024-01-12 12:10:26 +02:00
Jeff
7cb90d1ab2
Fix MSVC compile flag for no exceptions (#2974) 2024-01-09 22:45:14 +02:00
Gabi Melman
1ef8d3ce34
Fix #2967 2024-01-01 16:50:41 +02:00
gabime
c1569a3d29 Bump to catch2 v3.5.0 2023-12-22 18:15:50 +02:00
Harris
ba508057b1
Update example.cpp to fix the vector issue in bin_example (#2963)
with std::vector<char> buf(80),  80 elements are put in the vector, which is not the expected behavior.
2023-12-22 14:39:06 +02:00
Gabi Melman
ac55e60488
Update README.md 2023-11-04 17:36:11 +02:00
Marcus Müller
ddce42155e
fmt/*.h: include tweakme.h to set SPDLOG_FMT_EXTERNAL according to system (#2923)
Signed-off-by: Marcus Müller <marcus@hostalia.de>
2023-10-25 19:22:39 +03:00
M010
8b331e2cd1
Fix wrong thread_id (TID) in systemd_sink.h (#2919) 2023-10-24 01:43:47 +03:00
shannonbooth
2d5179ba7d
sinks: Make syslog_sink.h's syslog_prio_from_level protected (#2918)
To allow for using this function from a derived sink.
2023-10-23 22:49:01 +03:00
gabime
ff205fd29a Updated logo 2023-10-13 14:05:36 +03:00
gabime
595a524758 Updated spdlog logo 2023-10-13 13:16:45 +03:00
gabime
c5452e0508 Updated spdlog logo 2023-10-13 12:45:29 +03:00
Keith Kraus
0c4fb032e4
Match SPDLOG_CONSTEXPR_FUNC to FMT_CONSTEXPR (#2901)
* Modify the condition of SPDLOG_CONSTEXPR_FUNC to match that of fmt
2023-10-13 10:00:00 +03:00
Peter Nemeth
508d20f0fa
Add .git-blame-ignore-revs to ignore clang-format related commits (#2899) 2023-10-11 18:21:29 +03:00
Peter Nemeth
479a5ac3f1
Fix OS availability check of pthread_threadid_np for iOS (#2897) 2023-10-11 10:34:42 +03:00
Gabi Melman
91807c2e71
Update README.md 2023-09-26 00:33:45 +03:00
Gabi Melman
d4a5fd564c
Update README.md 2023-09-26 00:33:32 +03:00
gabime
e5865186d4 Revert "Added a function to add callbacks that are called when a logger is registered (#2883)"
This reverts commit b6eeb7364cb2f6eeb1ce963d0fa6ddbc929861f4, since it causes deadlocks too easily for the users.
2023-09-25 20:53:45 +03:00
Jonathan Vannier
b6eeb7364c
Added a function to add callbacks that are called when a logger is registered (#2883)
* Added a function to add callbacks that are called when a logger is registered

* Fix non captured registration 2 not being properly tested for

* Replace std::list by std::vector

* Remove const refs to shared pointers

* Fix missing header
2023-09-25 18:49:04 +03:00
gabime
0a53eafe18 update clang format again 2023-09-25 16:40:36 +03:00
gabime
251c856a12 update clang format again 2023-09-25 16:40:26 +03:00
gabime
4b2a8219d5 reformat code 2023-09-25 16:20:42 +03:00
gabime
cafde8ccc1 updated clang format 2023-09-25 16:19:40 +03:00
gabime
9d52261185 clang format 2023-09-25 16:08:29 +03:00
gabime
230e15f499 updated format.sh 2023-09-25 16:07:56 +03:00
gabime
7f535d184e updated .clang-format 2023-09-25 16:06:08 +03:00
gabime
95c226e9c9 format 2023-09-25 05:05:25 +03:00
gabime
5e88d5fe22 Never sort includes in clang format 2023-09-25 05:03:54 +03:00
Gabi Melman
5931a3d6f8 Fixed windows compile 2023-09-25 04:58:45 +03:00
Gabi Melman
f4afd81ce6
Update common.h 2023-09-25 03:07:15 +03:00
gabime
1a0bfc7a89 clang format 2023-09-25 02:44:07 +03:00
gabime
f24f7fa2fa Added missing include mutex 2023-09-25 02:44:00 +03:00
gabime
65701f4d5b Updated format.sh script 2023-09-25 02:39:47 +03:00
gabime
9e36a15875 Updated clang format to google style 2023-09-25 02:37:17 +03:00
Gabi Melman
b9cb721b92
Update async_logger-inl.h 2023-09-22 02:42:37 +03:00
Gabi Melman
1d6dbc2a56
Fix code formatting of async_logger-inl.h 2023-09-22 02:42:00 +03:00
Yubin
b5b5043d42
Support async_overflow_policy::discard_new (#2876)
Reason for the discard_new policy: when there is an overflow, there
is usually some unexpected issue (a bug, or some other unexpected stuff).
And in case of unexpected issue, the first arrived log messages are usually
more important than subsequent ones. For example, some application
keep logging error messages in case of functionality failure, which,
when using async_overflow_policy::overrun_oldest, will overrun the
first arrived messages that may contain real reason for the failure.
2023-09-09 23:05:08 +03:00
gabime
d109e1dcd0 minor cleanup 2023-09-09 13:32:44 +03:00
gabime
a98d3ab0c7 clang format 2023-09-09 12:56:47 +03:00
neothenil
8014d6c31a
Fix encoding issue in qt_sinks (#2862)
Added support for utf8 in qt_color_sink
2023-09-09 12:52:10 +03:00
gabime
3aceda041b Fixed bench 2023-09-01 17:12:16 +03:00
gabime
7d0531b076 Removed policy_max from cmake_minimum_required(..) 2023-09-01 16:40:19 +03:00
Gabi Melman
47e04cf043
Update ci.yml 2023-08-31 00:29:17 +03:00
albert-github
81ce5fcdb7
Remove obsolete part from cmake configuration files (#2871)
Updating minimum CMake version to 3.11
2023-08-30 23:20:37 +03:00
mike
cedfeeb95f
Add SPDLOG_TO_VERSION to compare spdlog version (#2853)
You can use SPDLOG_VERSION to select the latest spdlog features
where available while falling back to older implementations otherwise.
Using SPDLOG_TO_VERSION() for the value to compare with is recommended.
for Example:
```c++
 void sink_it_(const details::log_msg &msg) override
 {
 #if SPDLOG_VERSION < SPDLOG_TO_VERSION(1,4,0)
     fmt::memory_buffer formatted;
 #else
     memory_buf_t formatted;
 #endif
     sinks::base_sink<Mutex>::formatter_->format(msg, formatted);
     // bala bala...
 }
```
2023-08-14 08:19:02 +03:00
Robert Maynard
2312489bdc
Provide spdlog_header_only in build directory export (#2846)
Fixes #2678
2023-08-07 23:25:21 +03:00
gabime
811bc4c7a9 Added another test for circular_q 2023-08-05 17:26:16 +03:00
gabime
1f8d36071e Fixed ci 2023-08-05 17:09:12 +03:00
gabime
bffceb90b0 Fixed circular_q size impl and added tests 2023-08-05 17:03:04 +03:00
moritz-h
371bc8ebe2
Set CMAKE_BUILD_TYPE only for single-config generators (#2839)
Thanks @moritz-h
2023-08-02 17:22:20 +03:00
xvitaly
2ee8bac78e
Added missing square bracket to fix the level_to_string_view test. (#2827) 2023-07-23 11:15:25 +03:00
Gabi Melman
d8d23a6606
Fix #2820 2023-07-21 00:37:03 +03:00
qwark
76dfc7e7c0
Qt Sink : Allow for darker colors (for light background). (#2817)
Default are too bright if background is light(white).
2023-07-14 20:21:25 +03:00
gabime
7e635fca68 Fixed #2724 by excluding bin_to_hex sink if using std::format 2023-07-08 17:12:25 +03:00
gabime
bed324e414 Formatted qt_sinks.h code 2023-07-08 15:27:16 +03:00
gabime
72a7ec3eb9 Bumped spdlog version to 1.12.0 2023-07-08 15:25:17 +03:00
gabime
64ed6b495c Revert "Fixed FMT_EXPORT to FMT_LIB_EXPORT in CMakeLists.txt"
This reverts commit c3fa8f60e2aa6fd6257016436794c024c360cec8.
2023-07-08 13:44:27 +03:00
gabime
4338b9cd23 Revert "Updated bundled fmt to version 10.0.0"
This reverts commit 62e55e7a7fb2fd3fd43fced10cccf166fcd8ff40.
2023-07-08 13:23:40 +03:00
Gabi Melman
b73616ce29
Update README.md 2023-07-08 11:52:49 +03:00
Lucas Rangit MAGASWERAN
01b3724c48
sinks: android: handle when message is not loggable (#2801)
Android logger (since API 30) checks the per-tag property `log.tag.<tag>` to determine if a log message is loggable. See https://developer.android.com/ndk/reference/group/logging#__android_log_is_loggable . For example, `__android_log_buf_write` for a VERBOSE message will call `__android_log_is_loggable` and return `-EPERM` if the log message will not be printed because `log.tag.<tag>` is set to `INFO`.

Instead of erroring with the following error message, the Android sink should handle `-EPERM`. It is not an error to disable a log via the run-time property.

```
[*** LOG ERROR #0001 ***] [2023-06-29 00:50:26] [logcat] logging to Android failed: Unknown error -1 [/path/to/file.cpp(123)]
```
2023-07-07 00:24:06 +03:00
gabime
4b8ff51a29 Added const to put_newline() in bin_to_hex.h 2023-07-04 18:00:20 +03:00
Gabi Melman
8b8bc20f30
Added const qualifier to bin_hex_formatter to support c++20 2023-07-04 17:53:04 +03:00
gabime
3cd06a3d40 Added const qualifier to stopwatch formatter to support c++20 2023-07-04 16:04:49 +03:00
gabime
c3fa8f60e2 Fixed FMT_EXPORT to FMT_LIB_EXPORT in CMakeLists.txt 2023-07-02 21:24:35 +03:00
gabime
169f827957 Added missing include to udp_client.h 2023-07-02 21:19:41 +03:00
gabime
62e55e7a7f Updated bundled fmt to version 10.0.0 2023-07-02 20:47:33 +03:00
gabime
b85c509ec6 Fixed clang warning in qt_sinks.h 2023-07-02 17:52:55 +03:00
gabime
b1eb4953fa Cleaned some warnings in qt_sinks 2023-07-02 17:52:55 +03:00
Simon-Janos
5ece88e5a8
Removing IPv4 limitation from tcp_client (#2790) 2023-06-30 20:08:22 +03:00
CChuancey
826d8ba4b2
ignore vscode and clangd cache files (#2787)
Co-authored-by: chuancey <chuancey@mail.com>
2023-06-29 16:07:22 +03:00
Jiang Y
326f8870c2
Update qt_sinks.h: narrow cast msg.color_range_start, msg.color_range_end (#2781) 2023-06-28 08:32:12 +03:00
Aimin
7990ed8f2b
Update INSTALL (#2775) 2023-06-27 18:19:22 +03:00
gabime
da1e671d42 Clean qt_color_sink 2023-06-17 18:09:08 +03:00
gabime
a29cef5787 Make max_line explicit for qt_color_sink 2023-06-17 17:13:37 +03:00
gabime
9ce7295191 Make max_line explicit for qt_color_sink 2023-06-17 16:58:40 +03:00
gabime
36eb173030 Updated README.md with qt color example 2023-06-17 16:46:50 +03:00
gabime
ca44ce50ab Cleaned qt_color_sink 2023-06-17 16:40:46 +03:00
gabime
91280df07e wip color_qt_sink 2023-06-17 15:07:00 +03:00
Gabi Melman
5a6b6cafa8
Update README.md 2023-06-10 02:52:27 +03:00
Gabi Melman
4f4da7f114
Revert qt_sinks changes and color support, since they are not thread safe 2023-06-10 02:50:19 +03:00
Gabi Melman
199cc0a6d8
Update qt_sinks.h 2023-06-09 12:59:41 +03:00
Gabi Melman
4fb4e2bd86
Update qt_sinks.h 2023-06-09 12:44:54 +03:00
Gabi Melman
c17b5d9cd1
Update qt_sinks.h 2023-06-09 12:41:36 +03:00
Gabi Melman
3a7188505f
Added lock to qt_color_sink 2023-06-08 01:12:25 +03:00
Gabi Melman
32bab0e103
Update README.md 2023-06-07 13:47:50 +03:00
gabime
f0e1f22bbc Updated README.md with qt color example 2023-06-07 13:37:58 +03:00
gabime
1f61f5e019 clang format 2023-06-07 13:23:44 +03:00
gabime
31cefdce79 Use at() in ansicolor_sink 2023-06-07 13:21:40 +03:00
gabime
95b8ee9b32 Remove comment in qt_sinks.h 2023-06-07 13:11:37 +03:00
gabime
d7985e3965 Update comment about qt_color_sink 2023-06-07 13:07:21 +03:00
gabime
dfcb74b129 Added default color handling to qt_color_sink 2023-06-07 12:51:07 +03:00
gabime
6a96c7f902 Added qt_color_sink 2023-06-07 11:45:51 +03:00
gabime
6940f4fd46 Added some comments to qt_sinks.h 2023-06-07 00:29:23 +03:00
gabime
1f1897e3a4 Clean qt_sink code 2023-06-07 00:21:58 +03:00
gabime
0f50ad92d6 Clean qt_sink code 2023-06-07 00:21:44 +03:00
gabime
5384512f25 Store MetaMethod object in qt_sink for better performance 2023-06-07 00:19:40 +03:00
gabime
230cad163d Fixed qt_sink 2023-06-06 20:24:03 +03:00
Gabi Melman
3a6ee663ba
Update qt_sinks.h 2023-06-06 20:06:45 +03:00
Gabi Melman
931cd2fb54
Update qt_sinks.h 2023-06-06 19:58:26 +03:00
Gabi Melman
8fdcf0365b
Update qt_sinks.h 2023-06-06 19:57:09 +03:00
Ulmo-F
32701af60b
qt_sink: add some warning on its usage (#2753)
* qt_sink: add some warning on its usage

* qt_sink: add some warning on its usage - fix

---------

Co-authored-by: Benoit FANCHON <bfanchon@nanoxplore.com>
2023-06-06 19:53:10 +03:00
Gabi Melman
31cf79a70d
Remov foreward to standard vformat_to 2023-05-30 20:38:30 +03:00
gabime
d1eb68154f If exceptions are disabled, disable them in the bundled fmt as well 2023-05-28 12:53:13 +03:00
Gabi Melman
c174c15138
Update test_stopwatch.cpp 2023-05-27 23:05:49 +03:00
Gabi Melman
8222ca4837
Update test_stopwatch.cpp 2023-05-27 22:46:27 +03:00
Eli Boyarski
62a4b8ce4e
Fix fmt build (#2744) 2023-05-27 22:28:22 +03:00
gabime
ea1af20840 Update error message in default error handler 2023-05-27 15:34:33 +03:00
gabime
1fba68bfe2 Catch exceptions from async logger. Fix #2618 2023-05-27 15:33:02 +03:00
gabime
4c5ee9bb10 Added global logger benchmarks 2023-05-21 11:11:29 +03:00
Gabi Melman
dd173bc544
Update daily_file_sink.h 2023-05-19 19:58:45 +03:00
Gabi Melman
fcc8a95a95
Update daily_file_sink.h 2023-05-19 19:56:11 +03:00
Gabi Melman
9fcf609b67
Update daily_file_sink.h 2023-05-19 19:54:47 +03:00
Bernd Ritter
af1785b897
Removes special format handling for fmt. (#2736)
* Removes special format handling for fmt. Regains test compatibility with fmt
1.10.0.

fixes #2735

* reverted std::vector back to filename_t and used pointer to array start likewise as fmt's implementation uses

* calc_filename buffer increase softened, exception is throw if buffer exceeds 4k, filename parameter renamed to match intend.

* calc_filetime based on std::put_time for simpler implementation
2023-05-19 19:51:02 +03:00
Gabi Melman
57a9fd0841
Update README.md 2023-05-08 00:04:27 +03:00
Kasra Hashemi
f9c24d9fa8
Update README.md (#2732)
fixed serious grammar and spelling issues throughout the file without touching the content
2023-05-08 00:02:37 +03:00
James Ruan
e4f92bed48
fix ringbuffer_sink moving warning (#2722) 2023-04-28 18:59:35 +03:00
Sergey Fedorov
c65aa4e488
os-inl.h: fix for missing pthread_threadid_np (#2715) 2023-04-23 11:09:41 +03:00
Gabi Melman
e539d6ae42
Update registry-inl.h fix #2691 2023-04-23 03:21:17 +03:00
H1X4
0ca574ae16
fix build for master fmt (non-bundled) (#2694)
* fix build for master fmt (non-bundled)

* update fmt_runtime_string macro

* fix build of updated macro
2023-03-31 20:39:32 +03:00
Bailey Chittle
069a2e8fc9
fix small issue when compiling with C++20 without std::format (#2688) 2023-03-25 02:47:37 +03:00
SCC/楊志璿
42d1f40a18
Fix stdout_sink_base::log's behavior inconsistency (#2646)
* Fix stdout_sink_base::log's behavior inconsistency

It will flush every time when it if not defined _WIN32, but not in
Windows family.
We viewed the commit #48d4ed9 for fixing issue #1675 .
It seems missing this flushing operation in mistake.

* Use fflush at all operating system

* Remove redundant fflush from stdout_sink_base

---------

Co-authored-by: scc <scc@teamt5.org>
2023-03-23 10:24:48 +02:00
Bailey Chittle
040874224b
setting the cmake standard to 20 when using std format (#2680) 2023-03-21 20:23:14 +02:00
Luis Angerstein
706ad70591
Enable systemd_sink tests in linux pipeline (#2669)
* Install libsystemd-dev in linux pipeline

Without this package the test_systemd_sink.cpp will not be tested.

* Install pkg-config in linux pipeline
2023-03-09 13:00:39 +02:00
Luis Angerstein
1262a249a6
Fix os namespace in systemd_sink.h (#2668)
* Fix os namespace in systemd_sink.h

* Remove spdlog:: prefix from os::thread_id() call
2023-03-09 12:55:34 +02:00
Gabi Melman
2a861d28bd
Update test_errors.cpp 2023-03-05 21:43:07 +02:00
Gabi Melman
febc1e233d
Update test_errors.cpp 2023-03-05 21:34:02 +02:00
Gabi Melman
763ff37348
Update test_errors.cpp 2023-03-05 21:30:29 +02:00
Gabi Melman
2d57e3b57e
Update and rename kafka_skin.h to kafka_sink.h 2023-03-05 00:22:57 +02:00
听风
b25aaecf6a
feat(kafka_skin.h): kafka log support (#2655)
* feat(kafka_skin.h): kafka log support

add kafka log support

* refactor(kafka_skin.h): remove producer_  check

remove producer_  check
2023-03-03 05:04:47 +02:00
Gabi Melman
d07e8cb576
Update appveyor.yml 2023-03-01 17:32:06 +02:00
Vitaly Zaitsev
bcd0a2b820
Copy all compiled DLLs to correct destinations. (#2662) 2023-03-01 15:59:25 +02:00
Vitaly Zaitsev
7f09c88817
Added Catch v3 support (#2661)
* Added Catch v3 support.

* Removed extra square brackets from some tests.
2023-03-01 13:51:04 +02:00
Vitaly Zaitsev
150ba9e6dd
Allow other builders running after build failures. (#2659) 2023-03-01 11:33:58 +02:00
gabime
8be5b41a2f revert pr #2656 2023-03-01 01:12:50 +02:00
Gabi Melman
ceb71825b2
Update ci.yml 2023-03-01 00:43:40 +02:00
Vitaly Zaitsev
2a6d3e9f3b
Added Catch v3 support. (#2656) 2023-03-01 00:16:39 +02:00
Gabi Melman
6b67054071
Update ci.yml 2023-02-28 23:58:39 +02:00
Gabi Melman
13f45c531b
Update ci.yml 2023-02-28 23:54:16 +02:00
Gabi Melman
937ce23537
Update ci.yml 2023-02-28 23:49:36 +02:00
gabime
60f5cb73a8 Revert commit 0e9ccd73ef21015bff50c5044a88f94f33aff01b 2023-02-26 14:00:43 +02:00
Gabi Melman
0e9ccd73ef
Removed use of SPDLOG_FMT_RUNTIME from test_errors.h 2023-02-26 13:48:42 +02:00
Gabi Melman
839ea957ab
Update test_stopwatch.cpp 2023-02-26 02:31:12 +02:00
Gabi Melman
262acfdeb5
Update os-inl.h 2023-02-25 19:52:27 +02:00
Gabi Melman
a4d8817745
move include cassert 2023-02-25 17:30:39 +02:00
Gabi Melman
66407f5b48
Better handling of utf to wchar 2023-02-25 17:02:50 +02:00
璀境石
4641347c3f
msvc_sink: support utf8 (#2651)
* msvc_sink: support utf8
2023-02-25 16:21:24 +02:00
afshinpir
51bcff820e
Added apply_logger_env_levels (#2649)
This method applies levels which is set by environment variable
`SPDLOG_LEVEL` to the a single controller. Usefull for loading
configuration into manually created loggers.
2023-02-25 12:07:33 +02:00
Charles Hardin
7372596126
Add optional TID definition to the systemd sink send (#2619)
From the systemd.journal-fields the TID is a user defined
field passed directly from the clients and stored in the
journal. Adding the arguement in the journal send to support
that storage option in the journal.
2023-02-25 01:33:37 +02:00
Zeus James
da14258533
Fix MinGW build issue on example (#2642)
* Fix MinGW build issue on example #2638

* Move the cmake change to example\CMakeLists.txt

* Update CMakeLists.txt on the example
2023-02-12 10:34:22 +02:00
Li Z
927cc29444
Fix unexpected delimiter at start of line in to_hex formatter (#2627) 2023-02-01 12:04:30 +02:00
Gabi Melman
5a589438d2
Update README.md 2023-01-21 00:36:56 +02:00
Gabi Melman
d8c061aa6e
Update README.md 2023-01-21 00:35:53 +02:00
Mohammad Ali
3cab260814
Add a trivial callback sink (#2610)
Add a trivial callback sink
2023-01-19 19:46:34 +02:00
Gabi Melman
654dbc5c32
Update os.h 2023-01-15 16:00:26 +02:00
Gabi Melman
78e86ba01f
Update os-inl.h 2023-01-15 15:59:41 +02:00
Gabi Melman
435827fe5a
Update os.h 2023-01-15 15:57:08 +02:00
espkk
f29f369a12
Add sync to file_helper (#2343) 2023-01-15 15:33:40 +02:00
albert-github
5a63426d1c
Spelling corrections (#2606)
Spelling corrections v1.x
2023-01-15 13:41:30 +02:00
Gabi Melman
05e3a73b16
Update README.md 2023-01-12 10:15:58 +01:00
Gabi Melman
c92d12bc18
Update README.md 2023-01-12 10:12:30 +01:00
Robin Lindén
6df64c6c34
Fix -Wshadow warnings in spdlog::sinks::dist_sink (#2599)
This is similar to fbba6dff20b0c04a0694515168914a62161999d7 but fixes a
few member functions missed in that commit.
2023-01-10 00:25:26 +01:00
Arnar Bjarni Arnarson
0b9ff5210a
Fix type of event id in win_eventlog_sink (#2598)
Co-authored-by: Arnar Bjarni Arnarson <arnar@menandmice.com>
2023-01-10 00:25:01 +01:00
Ivan Grokhotkov
85a009ad64
Support newlib C library configurations without tm_gmtoff field (#2600)
Newlib C library (https://sourceware.org/newlib/) has a configuration
option to add tm_gmtoff field to the tm structure. Not all the
platforms supported by newlib enable this option, and spdlog doesn't
compile on such platforms due to missing tm_gmtoff field.

Fix this by checking for `__NEWLIB__` and `__TM_GMTOFF` and enabling
calculate_gmt_offset.
2023-01-10 00:12:03 +01:00
Khem Raj
287a00d364
Do not use LFS64 functions on linux/musl (#2589)
On musl, off_t is 64bit always ( even on 32bit platforms ), therefore
using LFS64 funcitons is not needed on such platforms. Moreover, musl
has stopped providing aliases for these functions [1] which means it
wont compile on newer musl systems. Therefore only use it on 32bit
glibc/linux platforms and exclude musl like cygwin or OSX

[1] https://git.musl-libc.org/cgit/musl/commit/?id=246f1c811448f37a44b41cd8df8d0ef9736d95f4
Signed-off-by: Khem Raj <raj.khem@gmail.com>
2023-01-03 19:54:50 +02:00
Vasiliy Kulikov
3c93f7690a
fix build: fix for freebsd (#2590)
The build error was:
  include/spdlog/details/tcp_client.h:106:31: error: use of undeclared identifier 'IPPROTO_TCP'
2022-12-31 23:52:46 +02:00
Alok Priyadarshi
a4e9917575
feat(mpmc_blocking_q): add blocking dequeue without timeout (#2588)
Use the new blocking dequeue to avoid unnecessarily waking up the
thread pool every 10s.

Fixes #2587 by replacing std::condition_variable::wait_for with
std::condition_variable::wait as a workaroung for gcc 11.3 issue 101978.

Co-authored-by: Alok Priyadarshi <alokp@dexterity.ai>
2022-12-30 15:20:10 +02:00
Darby Payne
edc51df1bd
Feature/add system includes option (#2575)
* Adding system includes option

* Adding system includes option
2022-12-11 10:58:02 +02:00
NaDDu
ff88b13c35
Fixed variable name (#2573)
* fixed variable name

* Changed the variable name from check_debbugger_present_ to check_debugger_present_.

Co-authored-by: cpp <c.pp@navercorp.com>
2022-12-10 00:28:28 +02:00
Gabi Melman
dd0d0f68c4
Added compile mscv_sink.h to tests 2022-12-10 00:25:31 +02:00
György Katona
8512000f36
Unnecessary backtrace begin/end logs (#2568)
* add empty getter function to tracer

* add unit test to check empty tracer

Co-authored-by: Gyorgy Katona <gykatona@logmein.com>
2022-12-09 10:25:17 +02:00
zydxhs
f0cd9d1530
dup_filter_sink adds parameters to enable setting the level of skipped logs (#2563)
* dup_filter_sink adds parameters to enable setting the level of skipped logs

* rename the param name 'level' to 'notification_level'

Co-authored-by: zhuyadong <zhuyadong@kedacom.com>
2022-12-02 09:51:34 +02:00
zydxhs
50e8b2d982
fix dup_filter_sink lose source_loc (#2549)
Co-authored-by: zhuyadong <zhuyadong@kedacom.com>
2022-11-22 09:38:01 +02:00
Charles Milette
4f80077339
Support compile-time format string checking with std::format (#2544)
* Support compile-time format string checking with std::format

* Fix pre-VS 17.5 compilation

* Fix compilation without wchar_t support

* What am I doing

* Bring back fmt optimization

* Move to_string_view to common.h

* Fix SPDLOG_CONSTEXPR_FUNC emitting duplicate symbol errors when building in C++11

* Also add inline on VS 2013

* Appender doesn't work on wide strings
2022-11-12 23:07:11 +02:00
Romain Pokrzywka
c5a09ebc49
Update #include to deprecated fmt header (#2545)
The <fmt/locale.h> header has been marked as deprecated for a while
and has finally been removed in fmt v0.9.0:
https://github.com/fmtlib/fmt/commit/5c7d315ded7bdb6cc5bd65daef091eefe

Replace with <fmt/format.h> instead, as recommended.
2022-11-12 02:47:51 +02:00
Sprite
d7de159455
Fix undefined macro FMT_STRING in benchmark when using std::format (#2540) 2022-11-08 11:01:27 +02:00
Eli Boyarski
18495bf25d
Bundle fmt 9.1.0's std.h, and provide a header to include either it or the external fmt's version (#2539) 2022-11-08 01:14:01 +02:00
Gabi Melman
ad0e89cbfb
Version 1.11.0 2022-11-02 23:13:08 +02:00
Gabi Melman
6a9d561671
Update ci.yml 2022-11-01 17:17:29 +02:00
Gabi Melman
545c301877
Update ci.yml 2022-11-01 17:13:35 +02:00
Gabi Melman
7aa00607ea
chrono.h: Remove warning suppression
Not needed since fmt 9.x
2022-11-01 14:46:39 +02:00
gabime
bd5a81df70 Check IsDebuggerPresent in msvc_sink before doing work. Fix #2408 2022-11-01 00:52:39 +02:00
gabime
4accce5d7b Try again fixing fmt::vformat_to when SPDLOG_WCHAR_TO_UTF8_SUPPORT is defined 2022-11-01 00:07:46 +02:00
gabime
4d7308f26d Fixed msvc warning C4800 in win_eventlog_sink 2022-11-01 00:01:19 +02:00
gabime
678a79c0be Fixed syntax error from prev commit 2022-10-31 23:51:48 +02:00
gabime
fbba6dff20 Fix #2431 2022-10-31 23:23:57 +02:00
gabime
fdb1f5926e Fix fmt::vformat_to when SPDLOG_WCHAR_TO_UTF8_SUPPORT is defined 2022-10-31 22:56:29 +02:00
gabime
b59b4a2b45 Rvert suppressing msvc2017 warnings and fix ci instead 2022-10-31 22:52:01 +02:00
gabime
6c975fa13b Replace fmt::detail::vformat_to(buf,..) with fmt::vformat_to(fmt::appender(buf) 2022-10-31 18:43:38 +02:00
gabime
c627c66560 Replace fmt::detail::vformat_to(buf,..) with fmt::vformat_to(fmt::appender(buf) 2022-10-31 18:26:07 +02:00
gabime
130ff0c8db enable the ostream formatting for backward compatibility with fmt 8.x 2022-10-31 18:15:43 +02:00
gabime
31d6935b97 updated readme 2022-10-31 18:12:47 +02:00
gabime
14a29c03eb suppress warning 4307 when including format-inline.h under msvc 2017 2022-10-31 17:47:12 +02:00
gabime
a7e2bf161e Update user defined type example 2022-10-31 17:35:24 +02:00
gabime
070dd181df clang format 2022-10-31 17:09:45 +02:00
gabime
7147da468f Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2022-10-31 17:04:20 +02:00
gabime
9125bda301 suppress "integral constant overflow" warning under msvc 2017 2022-10-31 17:03:53 +02:00
Gabi Melman
a4743370e2
Update appveyor.yml 2022-10-31 15:39:01 +02:00
Gabi Melman
867df8cf87
Update appveyor.yml
Added fatal warnings option to appveyor
2022-10-31 15:10:51 +02:00
gabime
8a0b2231b1 Renamed bench name 2022-10-31 14:01:38 +02:00
gabime
3499dfeeb4 Bump bundled fmtlib to version 1.9.1 2022-10-31 13:47:47 +02:00
刘耘呈
3c0e036cc9
Use 'SPDLOG_FMT_RUNTIME' to fix compilation error throwed MSVC and fmt 9.1.x (#2517)
* Use 'SPDLOG_FMT_RUNTIME' to fix compilation error throwed MSVC and fmt 9.1.x

* Fix #2512
2022-10-20 02:11:16 +03:00
Gabi Melman
bced424855
Merge pull request #2519 from sandorzm/v1.x
Mongo sink improvements
2022-10-19 22:37:29 +03:00
Sandor Magyar
5fba2867f5 Change mongocxx::exception handler to std::exception 2022-10-19 14:02:21 -04:00
Sandor Magyar
b5d361fc21 clang-format mongo_sink.h 2022-10-19 10:08:54 -04:00
Sandor Magyar
0674e79066 Improve arg passing and exceptions in mongo_sink 2022-10-19 09:53:33 -04:00
Sandor Magyar
5f67ef4d6f Remove pointless try block in mongo_sink 2022-10-18 20:25:32 -04:00
Sandor Magyar
1bb1f05d73 Adjust MongoCXX instance handling in mongo_sink
Changes suggested by @gabime on #2519
2022-10-18 20:13:17 -04:00
Gabi Melman
77429b2e2e
Merge pull request #2515 from puneetmatharu/v1.x
Export targets file to build directory at configure time
2022-10-18 13:19:13 +03:00
Sandor Magyar
a3c47cc682 Don't force Mongo sink to own MongoCXX instance
There can only be one instance in the whole program, so programs that use the
Mongo sink and also separately use MongoCXX may have problems if the Mongo sink
owns the instance. MongoCXX recommends that the main application manage its own
instance so configuration parameters can be passed to the constructor:
http://mongocxx.org/api/current/classmongocxx_1_1instance.html

However, this commit is not a breaking change. If no instance has been created
at construction time, the Mongo sink will still create and own the instance.
2022-10-17 17:32:08 -04:00
Sandor Magyar
0145223be1 Add numerical level to Mongo sink for easier queries
Filtering to a certain log level or above, a useful operation, can now be done
with an integer comparison as opposed to comparing to a list of strings in the
database query.
2022-10-17 16:15:23 -04:00
Sandor Magyar
f3b61c70ba Catch exception by reference to fix -Wcatch-value warning 2022-10-17 16:04:49 -04:00
Puneet Matharu
7768c6271c Export targets to build directory so that it can be found at configure time. 2022-10-17 10:02:14 +01:00
Gabi Melman
d011332616
Merge pull request #2509 from kin4stat/v1.x
Replace iterator difference with std::distance(revert #2030)
2022-10-15 00:41:16 +03:00
Daniil
93b9132b0a Replace iterator difference with std::distance 2022-10-13 12:29:48 +03:00
Gabi Melman
936697e5b1
Merge pull request #2500 from offa/ghactions_ci
Migrate to Github Actions CI
2022-10-03 18:52:35 +03:00
offa
cf6cdc5ba6 Replace Travis CI Badge with Github Actions 2022-10-03 16:04:40 +02:00
offa
ec81b321c2 Remove .travis.yml 2022-10-01 18:11:36 +02:00
offa
23fce5ffaa Migrate to Github Actions CI 2022-10-01 18:11:36 +02:00
Gabi Melman
7fa59cf555
Merge pull request #2498 from offa/gcc12_workaround
Workaround GCC 12 warning
2022-09-30 17:12:26 +03:00
offa
29b24f9e72 Use pragams instead of compile options 2022-09-30 13:20:15 +02:00
Gabi Melman
523a075f82
Merge pull request #2499 from offa/clang_cpp20_workaround
Workaround deprecation warning on Clang with C++20
2022-09-30 00:07:28 +03:00
offa
06f9953fa8 Workaround deprecation warning on Clang with C++20 2022-09-29 20:14:53 +02:00
offa
b8fdc9bf5d Workaround GCC 12 warning 2022-09-29 19:28:44 +02:00
Gabi Melman
7130676697
Merge pull request #2495 from panicgh/lowercase-windows-h
Use lower-case "windows.h" for case-sensitive file systems
2022-09-26 14:20:29 +03:00
Nicolas Benes
5ca5fdff9f Use lower-case "windows.h" for case-sensitive file systems
The "windows.h" in MinGW-W64 is lower-case. When cross-compiling for
Windows on Linux with a case-sensitive file system, the upper-case
"Windows.h" file is not found and compilation fails.

Always use lower-case "windows.h" to fix cross-compilation.
2022-09-26 12:42:01 +02:00
Gabi Melman
81de01c02c
Merge pull request #2475 from nigels-com/-fPIC
cmake: set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2022-09-08 01:09:42 +03:00
Gabi Melman
b60512731b
Merge pull request #2476 from nigels-com/SPDLOG_NO_SOURCE_LOC
SPDLOG_NO_SOURCE_LOC support for omitting __FILE__, __LINE__ etc
2022-09-08 01:07:24 +03:00
Nigel Stewart
1eaf98cc10 SPDLOG_NO_SOURCE_LOC implementation refinement 2022-09-03 12:51:31 +10:00
Nigel Stewart
34f88d4382 cmake: SPDLOG_BUILD_PIC opt-in for CMAKE_POSITION_INDEPENDENT_CODE 2022-09-03 12:49:10 +10:00
Nigel Stewart
57e5814364 SPDLOG_NO_SOURCE_LOC support for omitting __FILE__, __LINE__ and SPDLOG_FUNCTION information 2022-09-02 12:18:06 +10:00
Nigel Stewart
de67ebdda1 cmake: set(CMAKE_POSITION_INDEPENDENT_CODE ON) for Linux static library purposes 2022-09-02 12:08:42 +10:00
Gabi Melman
f44fa31f51
Fix #2434 2022-08-17 17:47:22 +03:00
Gabi Melman
64e0724bd6
Merge pull request #2468 from LorenDB/patch-1
Add openSUSE installation
2022-08-12 20:27:02 +03:00
Loren Burkholder
afb1699e0a
Add openSUSE installation 2022-08-12 11:39:47 -04:00
Gabi Melman
b75edfafca
Merge pull request #2449 from Simon-Janos/Re-introduce-redundant-std-move-at-return-for-old-compilers
Re-introduce std::move at return for old GCC (before version 5) inside an ifdef for e.g. CentOS 7
2022-07-27 10:10:54 +03:00
Simon-Janos
26f69ee9d2 Re-introduce redundant std::move at return for old GCC (before version 5) inside an ifdef for e.g. CentOS 7 2022-07-27 07:16:36 +02:00
Gabi Melman
61879237e9
Merge pull request #2445 from Hish15/Hish15/CorrectDoc 2022-07-25 21:42:31 +03:00
Hector PHARAM
fb3ddf749d Removed doc "(shared not supported in windows yet)" 2022-07-25 15:23:07 +02:00
Gabi Melman
7d805c2231
Merge pull request #2443 from ibmibmibm/v1.x
Explicitly casting level_enum to size_t.
2022-07-22 18:52:02 +03:00
Shen-Ta Hsieh
5f8877b665
Explicitly casting level_enum to size_t.
See commit 2a4c34b8785137eba9da7eb4cbb28b4162218272
2022-07-21 20:24:01 +08:00
Gabi Melman
834840636c
Merge pull request #2439 from LucasChollet/duration
Expend support for any std::chrono::duration in spdlog::flush_every
2022-07-17 22:07:06 +03:00
Lucas CHOLLET
dfe1009080 Expend support for any std::chrono::duration in spdlog::flush_every
This allows things like:

spdlog::flush_every(std::chrono::minutes(10));
spdlog::flush_every(std::chrono::milliseconds(100));
2022-07-17 20:28:39 +02:00
Gabi Melman
6c95f4c816
Fix #2419 by documenting the set_pattern behaviour 2022-07-01 10:53:05 +03:00
Gabi Melman
d7690d8e7e
Merge pull request #2415 from neheb/mingw
test_stopwatch: fix on mingw
2022-06-27 01:51:11 +03:00
Rosen Penev
68f42a5b90 test_stopwatch: fix on mingw
There are some timing shenanigans with GCC's chrono that make this
unreliable. Add a start/stop and test for that to work around.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2022-06-25 19:07:36 -07:00
Gabi Melman
ab7b325906
Update README.md 2022-06-24 20:08:47 +03:00
Gabi Melman
a26e174b36
Merge pull request #2402 from cookcocck/fix_cmake_spdlog_use_std_format
Set c++20 when SPDLOG_USE_STD_FORMAT option is turned on
2022-06-19 02:24:01 +03:00
Gabi Melman
866fdaa6db
Merge pull request #2399 from bergen4/v1.x
add overrun_counter reset function
2022-06-19 02:22:56 +03:00
Gabi Melman
03315853df
Merge pull request #2386 from panzhongxian/v1.x
Romove the empty file if no log in first period in hourly logger
2022-06-19 02:22:28 +03:00
cookcocck
ca747c7572 Set c++20 when SPDLOG_USE_STD_FORMAT option is turned on 2022-06-14 11:12:49 +08:00
bergen
1f608a81e8 add overrun reset function 2022-06-09 19:45:40 +08:00
bergen
822f972842 update 2022-06-09 19:39:57 +08:00
Gabi Melman
298a200f69
Merge pull request #2396 from polesapart/v1.x
Remove redundant std::move at return
2022-06-02 22:53:54 +03:00
Alexandre Pereira Nunes
beefee7929
Remove redundant std::move at return (triggers -Wredundant-move in Gcc, at least) 2022-06-02 13:18:00 -03:00
panzhongxian
1eafcfab70 Romove the empty file if no log in first period in hourly logger 2022-05-24 16:19:21 +08:00
Gabi Melman
9e8e52c048
Merge pull request #2385 from panzhongxian/v1.x
Remove `try_lock` from null_mutex.
2022-05-20 12:09:26 +03:00
panzhongxian
1f0c2f9f36 Remove try_lock from null_mutex. 2022-05-20 16:20:19 +08:00
Gabi Melman
fc93ddbefe
Merge pull request #2384 from aengusjiang/v1.x
fix error: cannot bind lvalue to right reference
2022-05-19 23:35:52 +03:00
Gabi Melman
ffd929c590
Merge pull request #2383 from alexshpilkin/fix-pkg-config
Fix pkg-config generation with unconventional `CMAKE_INSTALL_*DIR`
2022-05-19 23:32:00 +03:00
Gabi Melman
d546201f12
Merge pull request #2381 from Esri/john4744/android_fmt_compile_time_check
Add FMT_STRING to allow compilation with FMT_ENFORCE_COMPILE_STRING
2022-05-19 23:29:16 +03:00
John Armstrong
799802f93b Add FMT_STRING to allow compilation with FMT_ENFORCE_COMPILE_STRING 2022-05-19 11:32:54 -07:00
Aengus.Jiang
3d7ee64661 fix error: cannot bind lvale to right reference 2022-05-19 22:50:04 +08:00
Alexander Shpilkin
876880fb3f
Reflect CMAKE_INSTALL_INCLUDEDIR in pkg-config 2022-05-19 17:49:16 +03:00
Alexander Shpilkin
afb69071d5
Allow absolute CMAKE_INSTALL_LIBDIR 2022-05-19 17:48:57 +03:00
Gabi Melman
0d8197cc9d
Update common.h
Init file event handlers to nullptr
2022-05-13 23:06:11 +03:00
Gabi Melman
e36b69a0ec
Merge pull request #2376 from jengelh/master
build: expand SOVERSION to not give false illusion of compatibility
2022-05-13 11:29:10 +03:00
Gabi Melman
0ef5228a77
Merge pull request #2372 from kslattery/v1.x
C++14 build fixes for older gcc #2333
2022-05-13 11:01:19 +03:00
Gabi Melman
e05b8542a0
Merge pull request #2375 from kslattery/bugfix/default_file_event_handlers
Add default file-event_handler callbacks. #2374
2022-05-13 10:58:55 +03:00
Jan Engelhardt
41efc971ad build: expand SOVERSION to not give false illusion of compatibility
Fixes #2369
2022-05-13 09:44:09 +02:00
Kevin Slattery
d89a1e66d8 Add default file-event_handler callbacks. #2374 2022-05-12 19:49:01 -05:00
Kevin Slattery
d3dee23e6c Remove new macro, update example with correct way to specify fmt lib namespace when fmt_lib namespace alias cannot be used. 2022-05-12 18:55:08 -05:00
Kevin Slattery
5f5e70e96e C++14 build fixes for older gcc #2333 2022-05-11 15:14:41 -05:00
gabime
128cbe5a06 clang-format 2022-05-08 13:01:45 +03:00
gabime
6d587f5181 Use fmt::detail::vformat_to(buf, ...) since it is ~20ns faster than fmt::vformat_to(std::back_inserter(buf),..) 2022-05-08 13:01:02 +03:00
Gabi Melman
9b4b373121
Merge pull request #2365 from conr2d/feature/need_localtime
Allow overriding need_localtime for custom formatter
2022-05-07 21:53:32 +03:00
Jeeyong Um
aa7490d187 Set eol to the test for overriding need_localtime 2022-05-08 01:20:27 +08:00
Jeeyong Um
c03c925e29 Copy the value of need_localtime when cloning pattern_formatter 2022-05-08 01:16:31 +08:00
Jeeyong Um
38929f856d Allow overriding need_localtime for custom formatter 2022-05-07 20:44:00 +08:00
Gabi Melman
bd0198de2d
Merge pull request #2364 from stkw0/v1.x
fix clone async test
2022-05-07 14:18:28 +03:00
David Roman
ece96216c4
fix clone async test
Fix #2363
2022-05-07 12:30:41 +02:00
Gabi Melman
a9347017db
Merge pull request #2358 from tiolan/topic/android_buffer_v1_x
V1: Allow modifying the used Android buffer
2022-05-07 00:27:55 +03:00
Timo Lange
2eedf1fa28 remove usage of forward args 2022-05-06 17:06:35 +02:00
Timo Lange
0a875d7b2d use __android_log_write or __android_log_buf_write based on template paramter 2022-05-06 08:55:41 +02:00
Gabi Melman
173d06578f
Fixed move in ringnuffer_sink 2022-04-27 08:35:50 +03:00
Gabi Melman
b299855ef2
Merge pull request #2346 from sylveon/v1.x
Switch to vformat_to
2022-04-27 08:20:48 +03:00
Charles Milette
8338a48c5b
Remove fmt_helper::to_string 2022-04-26 23:27:55 -04:00
Charles Milette
cd4f6c1466
Replace fmt_helper::to_string by a macro 2022-04-26 23:25:35 -04:00
Charles Milette
37dd6bb159
Address PR review comments 2022-04-25 21:59:56 -04:00
Charles Milette
714cf12822
Add fmt_helper.h include to includes.h and os-inl.h 2022-04-22 23:28:28 -04:00
Charles Milette
ee00f2e07d
Remove fmt_helper.h include from logger.h 2022-04-22 22:52:56 -04:00
Charles Milette
c203b4df8e
Fix conversion from fmt::memory_buffer to fmt::string_view 2022-04-21 23:38:12 -04:00
Charles Milette
56adf64ccf
Actually fix bad #ifdef 2022-04-21 22:43:13 -04:00
Charles Milette
91019f4f46
Fix bad #ifdef 2022-04-21 22:36:04 -04:00
Charles Milette
3cf94968e7
Add missing include 2022-04-21 22:11:16 -04:00
Charles Milette
ebeb3707b1
Switch to vformat_to
Drive-by: reduce the amount of occurences of #ifdef SPDLOG_USE_STD_FORMAT
2022-04-21 21:59:02 -04:00
Gabi Melman
b3ce5ed379
Remove comment 2022-04-21 15:24:37 +03:00
Gabi Melman
78fbc69c94
Merge pull request #2336 from aengusjiang/v1.x
[issues/2332]clean code, clean up the warning
2022-04-21 15:17:14 +03:00
Gabi Melman
4ccbb5a71a
Merge pull request #2342 from espkk/v1.x
Make file_event_handlers an aggregate
2022-04-15 12:22:35 +03:00
espkk
e6265c04ae Make file_event_handlers an aggregate 2022-04-15 11:54:11 +03:00
Aengus.Jiang
184fae06d7 clean code, clean up the warning 2022-04-10 13:13:59 +08:00
gabime
76fb40d954 clang format 2022-04-04 16:48:58 +03:00
gabime
757e9f8ec6 Bump version to 1.10.0 2022-04-04 16:48:24 +03:00
Gabi Melman
fc51c095ba
Merge pull request #2328 from Delgan/GH-2323-add-systemd-identifier
Add optional "ident" argument to systemd sink constructor
2022-04-02 11:00:18 +03:00
Delgan
36b4b9dac9 Add optional "ident" argument to systemd sink constructor 2022-04-01 23:20:28 +02:00
Gabi Melman
083ea59fbd
Merge pull request #2324 from Delgan/GH-2320-add-systemd-formatter
Add option to enable formatting of systemd sink
2022-03-30 00:40:36 +03:00
Delgan
c1aeefb0c9 fixup! Add option to enable formatting of systemd sink
Add default value to "systemd_sink" contructor
2022-03-29 22:26:52 +02:00
Delgan
3c1ee54112 Add option to enable formatting of systemd sink 2022-03-27 11:31:49 +02:00
Gabi Melman
a49456f7f2
Merge pull request #2317 from risa2000/patch-1
Fixed compiler error when building on Windows with #define UNICODE
2022-03-24 06:45:08 +02:00
risa2000
52dc210423
Fixed compiler error when building on Windows with #define UNICODE
The original `InetPton` expands to `InetPtonW` when building with UNICODE defined and expects the string parameter to be wchar_t. On the other hand macro `TEXT()` just adds prefix `L` to a string literal (just making it wchar_t literal). The proper way here would be converting `host.c_str()` result from UTF-8(?) into wchar_t (UNICODE) string, but this seems to be an overkill since the host is typically an IP address or a host/domain name. So assuming an ASCII input should be reasonably safe.
2022-03-22 16:20:45 +01:00
Gabi Melman
b1478d98f0
Merge pull request #2305 from nUl1/fix-fopens
Fix fopen_s error reporting with PREVENT_CHILD_FD
2022-03-11 23:10:35 +02:00
Andrey Bugaevskiy
5ee969e4f6 Fix fopen_s error reporting with PREVENT_CHILD_FD 2022-03-11 19:22:45 +00:00
Gabi Melman
7f8a61e79d
Merge pull request #2300 from adamcalhoon/fix-fmt-external-ho-deps
When built with SPDLOG_FMT_EXTERNAL_HO consumers of the spdlog target…
2022-03-06 22:03:47 +02:00
Adam Calhoon
69cac816aa When built with SPDLOG_FMT_EXTERNAL_HO consumers of the spdlog targets depend on fmt
The cmake/spdlogConfig.cmake.in file properly takes into account the fmt
package dependency when building with SPDLOG_FMT_EXTERNAL:BOOL=ON but
not when built with SPDLOG_FMT_EXTERNAL_HO:BOOL=ON.

Prior to these changes SPDLOG_FMT_EXTERNAL_HO:BOOL=ON results in
exported targets with INTERFACE_LINK_LIBRARIES that contain
fmt::fmt-header-only.

As such, the installed spdlogConfig.cmake file should attempt to find
that dependency for the consumer.
2022-03-06 11:04:59 -05:00
Gabi Melman
2f2d04b3e8
Merge pull request #2278 from adriweb/patch-1
pattern_formatter-inl: fix reorder-ctor warning
2022-02-15 18:44:42 +02:00
Adrien Bertrand
9cd9c98f59
pattern_formatter-inl: fix reorder-ctor warning
Fix `Wreorder-ctor` warning

```
spdlog/pattern_formatter-inl.h:1028:7: error: field 'custom_handlers_' will be initialized after field 'need_localtime_' [-Werror,-Wreorder-ctor]
    , custom_handlers_(std::move(custom_user_flags))
      ^
```

Move the initialization of `need_localtime_(true)` right after `pattern_time_type_` as expected.
2022-02-15 11:26:25 -05:00
Gabi Melman
f2461f1430
Merge pull request #2273 from surfycui/v1.x 2022-02-14 09:47:01 +02:00
Surfy Cui
a732a0dc85 Limit max number of rotating files to 200000, not max size 2022-02-14 15:30:06 +08:00
Gabi Melman
4c2ce2c82c
Update rotating_file_sink-inl.h 2022-02-13 09:41:15 +02:00
gabime
4cea9b8729 Limit max number of rotating files to 200000. Fix #1905 2022-02-12 14:10:43 +02:00
gabime
53c9b70ea3 Fix #2211 2022-02-12 14:06:11 +02:00
gabime
71105e0b07 Fixed #2227 2022-02-12 13:59:12 +02:00
gabime
c432fdd987 Bump fmt to version 8.1.1 and run clang-format 2022-02-12 13:20:15 +02:00
gabime
d8199b607d Bump fmt to version 8.1.1 and run clang-format 2022-02-12 13:19:45 +02:00
Gabi Melman
b7836c33ae
Merge pull request #2269 from kyuheon-kr/fix-issue-2201
Fix issue #2201
2022-02-08 14:13:56 +02:00
Kyuheon Kim
d497f494f0 Apply pattern width to one of the source information fields while missing source information 2022-02-08 20:29:58 +09:00
gabime
0b48976be4 flush before rotating 2022-02-05 19:45:19 +02:00
gabime
5b03dc1796 Throw if rotating_file_sink constructor receives max_size==0 as arg 2022-02-05 17:37:55 +02:00
gabime
ec8b0beddd comment 2022-02-05 17:16:36 +02:00
gabime
7536192058 Fix #2261 2022-02-05 17:13:33 +02:00
gabime
5afff7821f throw if flush failed 2022-02-05 14:23:33 +02:00
Gabi Melman
8fb112158a
Merge pull request #2255 from LeonBrands/patch-1
added a few missing files/directories to the gitignore
2022-01-23 20:56:29 +02:00
Leon Brands
792d618c02
added a few missing files/directories to the gitignore 2022-01-23 18:49:50 +01:00
Gabi Melman
93f59d04e9
Merge pull request #2249 from PixelParas/patch-1
removed unneeded spaces
2022-01-17 10:08:11 +02:00
Pixel
666bec5017
removed unneeded spaces
On Line 83 someone probably misclicked tab just removed that tab
2022-01-17 12:13:37 +05:30
Gabi Melman
2382c87aa3
Update pattern_formatter-inl.h 2022-01-16 23:30:57 +02:00
Gabi Melman
caa0e54396
Merge pull request #2246 from doug1234/DontGetTheDate
Now only getting time if pattern_formatter needs it
2022-01-16 21:43:43 +02:00
doug1234
28b9adf794 Added the last few suggested changes. 2022-01-15 16:41:06 -05:00
doug1234
584d77237e Several minor improvements based on code review suggestions. 2022-01-15 13:35:27 -05:00
doug1234
d9ec02d400 Fix mistake in previous checkin. 2022-01-14 20:06:26 -05:00
doug1234
5568b16ed5 Resetting the needs time flag when setting a pattern. 2022-01-13 21:35:02 -05:00
doug1234
eab522e743 Now only getting the date if formater needs to display date related information. 2022-01-13 20:57:14 -05:00
Gabi Melman
4cfdc8c5c8
Merge pull request #2245 from daverigby/level_enum_fwd
Allow forward-declaration of level_enum
2022-01-11 18:59:42 +02:00
Dave Rigby
2a4c34b878 Allow forward-declaration of level_enum
spdlog::level::level_enum cannot be forward-declared at present, as
the definition does not specify an underlying type.

To allow users to make use of <spdlog/fwd.h> to refer to
level::level_enum without pulling in all of <spdlog/common.h> (which
can be quite costly), specify an underlying type (int) for
level::level_enum, then add a forward-declaration for it to
spdlog/fwd.h.

Note this required explicitly casting level_enum to size_t within ansicolor_sink due to sign-conversion errors:

    implicit conversion changes signedness: 'const level::level_enum' to 'std::__1::array::size_type' (aka 'unsigned long') [-Wsign-conversion]

It would appear that an enum with an unspecified underlying type is in
some kind of superposition - it can be treated as both signed _and_
unsigned - using an underlying type of 'unsigned int' triggers even
more warnings of this kind...
2022-01-11 15:12:23 +00:00
Gabi Melman
729d7f6d88
Merge pull request #2234 from SpriteOvO/v1.x
Reset current size if rotated files on open
2022-01-06 01:59:05 +02:00
Sprite
3540ba32e9 Reset current size if rotated files on open 2022-01-04 09:16:20 +08:00
Gabi Melman
32fedcf90c
Merge pull request #2228 from timblechmann/feature/to_hex_span_fix
spdlog: fmt - support `std::span` in `to_hex`
2021-12-31 01:23:55 +02:00
Tim Blechmann
626efad307 spdlog: fmt - support std::span in to_hex
`std::span` does not have `const_iterator`. this prevents `to_hex` from
being used with `std::span<>`. to fix this, we provide an explicit
overload.

compare: https://cplusplus.github.io/LWG/issue3320
2021-12-30 09:46:27 +08:00
Gabi Melman
cc30229abb
Merge pull request #2216 from vnepogodin/patch-1
Reduce warnings with pedantic compiler `-Wuseless-cast`
2021-12-19 21:08:38 +02:00
Vladislav Nepogodin
a087dee98a
🚧 fix building with c++11 2021-12-19 21:48:39 +04:00
Vladislav Nepogodin
f096c615c3
🔥 conditional_cast 2021-12-19 21:37:21 +04:00
Vladislav Nepogodin
f81cb9f365
Revert "Useless cast"
This reverts commit 7e95963940c6dc5e0cfe46bd59bb9119d1fa19a1.
2021-12-19 21:05:21 +04:00
Vladislav Nepogodin
7e95963940
Useless cast 2021-12-19 15:04:47 +04:00
Gabi Melman
3f49f0f247
Update README.md 2021-12-12 10:01:34 +02:00
Gabi Melman
4cb1187871
Update README.md 2021-12-12 09:59:40 +02:00
Gabi Melman
fe782edc53
Update .travis.yml 2021-12-11 18:23:36 +02:00
Gabi Melman
702cf4f54a
Update .travis.yml 2021-12-11 18:11:55 +02:00
Gabi Melman
0c84e21022
Update .travis.yml 2021-12-11 18:08:40 +02:00
Gabi Melman
ee74321ac3
Update .travis.yml 2021-12-11 17:39:43 +02:00
Gabi Melman
e45c11f98a
Update example.cpp 2021-12-11 17:18:40 +02:00
Gabi Melman
c211288576
Update example.cpp 2021-12-11 17:12:15 +02:00
Gabi Melman
4fefd51e08
Fixed custom type example to work in c++11 2021-12-11 17:07:10 +02:00
Gabi Melman
ad08f13aac Update test_file_helper.cpp 2021-12-11 16:42:27 +02:00
Gabi Melman
6638c23cfc Update test_async.cpp 2021-12-11 16:42:17 +02:00
Gabi Melman
378a42c887 Update test_file_helper.cpp 2021-12-11 16:42:00 +02:00
Gabi Melman
9abcf38b90 Update test_file_helper.cpp 2021-12-11 16:41:49 +02:00
gabime
8715f51c61 Fixed file_event_handlers test for windows 2021-12-11 16:41:17 +02:00
gabime
37cbab363e updated file_event_handlers tests 2021-12-11 16:39:57 +02:00
gabime
afdcfc710e Updated file_event_handlers tests 2021-12-11 16:39:31 +02:00
gabime
16bc6d04ad Added file event handlers test 2021-12-11 16:39:13 +02:00
gabime
ac6908a139 Update bench CMakelists.txt 2021-12-11 16:37:06 +02:00
Gabi Melman
28e415fb3e Update to google benchmark to v1.6.0 2021-12-11 16:36:55 +02:00
Gabi Melman
ab2e72340a Update thread_pool.h 2021-12-11 16:36:40 +02:00
Gabi Melman
da9c16278a Update thread_pool.h 2021-12-11 16:36:30 +02:00
Gabi Melman
b5d6c939fd Update thread_pool.h 2021-12-11 16:36:20 +02:00
Philippe Serreault
fda2b361da Added missing global thread-pool initialization helper. 2021-12-11 16:35:58 +02:00
Philippe Serreault
6636ff05e6 Allow custom callback to be executed by thread-pool's threads before joining them.
This is similar to a change that was made a while ago ( https://github.com/gabime/spdlog/pull/208 ).
2021-12-11 16:34:48 +02:00
Acretock
9e17fafe1b c style cast -> static_cast 2021-12-11 16:29:10 +02:00
Gabi Melman
1f58535920 Fixed test_macros tests 2021-12-11 16:27:27 +02:00
Gabi Melman
8dd012096a Update README.md 2021-12-11 16:24:29 +02:00
gabime
f81970191a Fixed example for custom_type 2021-12-11 16:24:07 +02:00
gabime
b8b16e49a5 Fixed example for custom_type 2021-12-11 16:23:46 +02:00
gabime
2c21d9ecf8 Fixed example for custom_type 2021-12-11 16:23:20 +02:00
gabime
2a45eff693 Fixed example for custom_type 2021-12-11 16:22:51 +02:00
gabime
5bf8728cfa Fixed example for std_format 2021-12-11 16:22:33 +02:00
semenov_gv
e3e4c4bc95 minor changes added const ref params 2021-12-11 16:09:19 +02:00
Gabi Melman
0c611af552
Merge pull request #2195 from patrickroocks/v1.x-fix-ranges-and-to-hex
Fix usage of ranges and to_hex in the same compile unit
2021-12-01 14:02:30 -08:00
Roocks Patrick (MTN PTT / External)
f304ca3daf code style fixes 2021-12-01 16:37:29 +01:00
Roocks Patrick (MTN PTT / External)
d93cea97ec Fix usage of ranges and to_hex in the same compile unit
When trying to use spdlog/fmt/bin_to_hex.h in the same compile unit as spdlog/fmt/bundled/ranges.h you got a compile error because there was a multiple definitions for iterable classes. This fix renames the begin() and end() getters in dump_info into getBegin()/getEnd() in order to avoid this collision.

Added an example of ranges in example.cpp to show that it actually works (an to_hex example was already there)
2021-12-01 15:37:48 +01:00
Gabi Melman
cabbe65be4
Update README.md 2021-12-01 03:33:26 +02:00
Gabi Melman
8a6b5b9e62
Update README.md 2021-12-01 03:32:08 +02:00
Gabi Melman
c15262c493
Update README.md 2021-12-01 03:29:46 +02:00
Gabi Melman
9a12e4a885
Merge pull request #2194 from rioki/add-default-docu
Add example how to replace default logger.
2021-11-28 08:06:28 -08:00
Sean Farrell
f52d526e1e Add example to replace default logger.
Close #2193
2021-11-28 13:55:14 +01:00
Gabi Melman
e1a4b28039
Added fmt license file to bundled fmt folder 2021-11-27 19:35:35 +02:00
Gabi Melman
b3560d1567
Merge pull request #2190 from sylveon/sylveon-patch-1
Remove extraneous semicolon
2021-11-25 08:49:33 -08:00
Gabi Melman
c6d144dab9
Merge pull request #1972 from bansan85/v1.x
Fix runtime when build with -fsanitize=cfi
2021-11-24 23:43:56 -08:00
Charles Milette
d5c000394d
Remove extraneous semicolon 2021-11-24 19:25:25 -05:00
LE GARREC Vincent
58e2b455fb
Fix build with "-fvisibility=hidden" 2021-11-25 00:42:27 +01:00
Gabi Melman
2ab86a46d0
Merge pull request #2181 from lisr/os_inl_aix_fix
fix compiling errors on AIX
2021-11-20 08:45:34 -08:00
lisr
569b851b80 aix - reference to 'thread' is ambiguous, sys/thread.h vs std::thread 2021-11-20 22:48:18 +08:00
lisr
232df72b82 use pthread_getthrds_np for AIX 2021-11-20 09:48:14 +08:00
Gabi Melman
e65efdbbe1
Merge pull request #2182 from Light3039/patch-1 2021-11-18 22:32:04 -08:00
Light
29b41741cb
Fix(tweakme): Typo
:(
2021-11-19 09:32:59 +03:30
Light
17f21df441
Fix(tweakme): SPDLOG_FUNCTION
- Uncommenting SPDLOG_FUNCTION will make MSVC fail to compile:
    __PRETTY_FUNCTION__ is shown in intellisense but it's not available at compile time
    https://stackoverflow.com/questions/48857887/pretty-function-in-visual-c
2021-11-19 09:30:22 +03:30
Gabi Melman
94d2a84995
Merge pull request #2179 from ibmibmibm/fix-old-style-cast
Avoid c-style casting
2021-11-18 20:13:03 -08:00
lisr
aac187d3a0 fix aix compile error 2021-11-19 10:55:43 +08:00
Shen-Ta Hsieh
8d46977060
Avoid c-style casting 2021-11-19 09:58:29 +08:00
Gabi Melman
ca1eaedf7b
Update test_daily_logger.cpp 2021-11-17 04:45:49 +02:00
Gabi Melman
8bd5f4f883
Update test_daily_logger.cpp 2021-11-17 01:04:27 +02:00
gabime
dc030ec53c clang-format 2021-11-16 23:44:35 +02:00
gabime
1756c5d37f Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2021-11-16 23:42:20 +02:00
gabime
2b4e07dd91 Fixed wchar support for std::format 2021-11-16 23:42:06 +02:00
Gabi Melman
0df2582674
Update appveyor.yml 2021-11-16 23:21:11 +02:00
Gabi Melman
24e47efae0
fix gcc 4.8 compile warning 2021-11-16 22:48:02 +02:00
Gabi Melman
10b640d773
Update example.cpp 2021-11-16 22:37:43 +02:00
Gabi Melman
ff80d10820
Merge pull request #2170 from sylveon/std-format
Support C++20 std::format as an alternative to fmtlib
2021-11-16 22:11:07 +02:00
Charles Milette
126a9fb261 Merge branch 'v1.x' of https://github.com/gabime/spdlog into std-format 2021-11-16 11:30:23 -05:00
Charles Milette
4001032858 Add attribution, return to previous code for daily_filename_format_calculator with fmtlib 2021-11-16 11:22:30 -05:00
Charles Milette
ad779e4865 Attempt to solve ambiguous symbol on older MSVC 2021-11-16 10:10:02 -05:00
Charles Milette
701ef17227 Move strftime to daily_filename_format_calculator 2021-11-16 10:05:35 -05:00
Charles Milette
5d6af189f1 Use target.capacity() even with std::string 2021-11-16 09:59:48 -05:00
gabime
518bf36aa9 removed redundant intialization 2021-11-16 16:44:47 +02:00
gabime
5b7dfefc7e rename file_event_handlers_t to file_event_handlers 2021-11-16 16:41:04 +02:00
Charles Milette
484bf07379
Fix test_fmt_helper 2021-11-15 18:34:40 -05:00
Charles Milette
0ded003703 Fix wchar_t overloads and dump_info formatter 2021-11-15 16:52:31 -05:00
Charless Milette
95aa159bdd Fix daily_filename_format_calculator (hopefully) 2021-11-15 15:50:16 -05:00
Charless Milette
ba120e524b Add unit test for daily_filename_format_calculator 2021-11-15 15:46:22 -05:00
Charless Milette
a6945d046f Fix use of Char 2021-11-15 15:30:30 -05:00
Charless Milette
108c656e66 Fix copy-paste mistake 2021-11-15 15:29:16 -05:00
Charless Milette
2d77ef92b0 Avoid specializing std::formatter for std::tm (not a great idea after all) 2021-11-15 15:27:34 -05:00
Charless Milette
f6901606f5 Add std::tm formatter, fix spdlog::stopwatch formatter, conditionally use fmt::runtime in test_errors 2021-11-15 14:57:13 -05:00
Charless Milette
849e90bd01 Use /std:c++latest 2021-11-15 13:36:29 -05:00
gabime
e86be93b4a Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2021-11-15 14:55:00 +02:00
gabime
698516f3f5 Updated example 2021-11-15 14:54:51 +02:00
Gabi Melman
da621e4402
Update README.md 2021-11-15 14:48:20 +02:00
Gabi Melman
ea92864a4d
Update README.md 2021-11-15 14:46:23 +02:00
Gabi Melman
a5fa6eb356
Update README.md 2021-11-15 14:45:07 +02:00
Gabi Melman
cbaf4880ad
Update README.md 2021-11-15 14:42:36 +02:00
gabime
b813bb863d Updated file_events example 2021-11-15 14:35:00 +02:00
gabime
30fb78813b Updated file events example 2021-11-15 14:32:34 +02:00
Gabi Melman
a3ad8b5f26
Merge pull request #2169 from seker/v1.x_file_event_handlers
file_event_handlers add before_open function
2021-11-15 13:36:03 +02:00
seker
24a551c14e file_event_handlers add before_open function 2021-11-15 19:14:35 +08:00
Charles Milette
8e359baaec
Merge branch 'v1.x' into std-format 2021-11-14 16:02:38 -05:00
Gabi Melman
85bdfc8695
Merge pull request #2172 from keith-dev/v1.x
example.cpp failes to build on FreeBSD
2021-11-14 09:53:29 +02:00
Gabi Melman
c466e2d8f8
Merge pull request #2171 from rex4539/typos
Fix typos
2021-11-14 09:51:56 +02:00
Charless Milette
d75de3d3b2 Add SPDLOG_USE_STD_FORMAT to target_compile_definitions 2021-11-14 02:33:15 -05:00
Keith Williams
c8ba643f53 example.cpp failes to build on FreeBSD 2021-11-14 06:44:47 +00:00
Dimitris Apostolou
591eedcf36
Fix typos 2021-11-13 21:54:08 +02:00
Charless Milette
48e35f9c3e Make clang happy, fix VS 2022 generator name 2021-11-13 12:08:01 -05:00
Charless Milette
89c4b1aabe Fix build issues under C++11 2021-11-13 12:02:40 -05:00
Charless Milette
6ff1b83038 Fix usage of std::forward 2021-11-13 11:54:06 -05:00
Charless Milette
4008f31add Fix missing spdlog:: 2021-11-13 11:51:22 -05:00
Charless Milette
c475418975 Put formatter specialization in its original namespace 2021-11-13 11:50:26 -05:00
Charless Milette
a31ae23db1 Fix build issue when using built-in fmt 2021-11-13 11:43:19 -05:00
Charless Milette
44a4517e2b Support C++20 std::format as an alternative to fmtlib 2021-11-13 11:29:05 -05:00
Gabi Melman
ff9313e6dd
Merge pull request #2165 from seker/v1.x_file_event_handlers
add file event handlers
2021-11-12 11:15:43 +02:00
seker
c47ae3b15d add file event handlers 2021-11-12 09:49:49 +08:00
Gabi Melman
6aafa89d20
Merge pull request #2140 from sunlong169/v1.x
No need to define the Mutex mutex_ as mutable there is no const method.
2021-10-16 19:41:03 +03:00
sunlong169
acbf18d0dd
No need to define the Mutex mutex_ as mutable there is no const method.
There's no need to define the Mutex mutex_ as mutable since class base_sink has no const method.
2021-10-16 23:52:01 +08:00
Gabi Melman
8826011c81
Merge pull request #2102 from yzz-ihep/v1.x
fix mongo_sink<std::mutex>::instance_ template
2021-09-12 15:51:56 +03:00
yunzhong
d6a78cb85b
fix mongo_sink<std::mutex>::instance_ template 2021-09-12 15:25:55 +08:00
Gabi Melman
7812a4c89f
Merge pull request #2098 from RedDwarf69/v1.x
CMake: Support <PackageName>_ROOT
2021-09-09 13:30:33 +03:00
Cristian Morales Vega
ef540c1243 CMake: Stop explicitly setting CMP0077
The policy_max in cmake_minimum_required() already does that.
2021-09-08 16:45:04 +01:00
Cristian Morales Vega
8ffbc0f114 CMake: Specify "policy_max" 2021-09-08 16:44:13 +01:00
Gabi Melman
21ba38972b
Merge pull request #2096 from mmarkeloff/v1.x
Unhandled errors
2021-09-08 17:31:31 +03:00
Your Full Name
d54b8e89c0 fixed #2058 by updating catch2 to v2.13.7 2021-09-08 13:23:36 +03:00
Маркелов Максим
14eecc6e2a Unhandled errors
inet_aton(), InetPton() return codes
2021-09-07 09:10:25 +03:00
Gabi Melman
99fda0ed22
Merge pull request #2094 from jspraul/patch-1
Update to latest Travis CI Build Status
2021-09-07 00:03:41 +03:00
jspraul
8e055a4086
Use generated Status Image
Found out the ~/github vdir portion of the URL is not needed.
2021-09-06 16:16:46 -04:00
jspraul
d4967358a5
Update to latest Travis CI Build Status
https://travis-ci.com/gabime/spdlog (404's) → https://app.travis-ci.com/github/gabime/spdlog
https://travis-ci.com/gabime/spdlog.svg?branch=v1.xhttps://app.travis-ci.com/gabime/spdlog.svg?branch=v1.x (Result from clicking Status Image url builder)
2021-09-06 15:36:29 -04:00
gabime
bae78f7b6c Fixed comments 2021-09-05 17:29:47 +03:00
gabime
f97dcc72dc cleanup tcp client WSA Startup/Shutdown 2021-09-05 17:28:46 +03:00
Gabi Melman
dd10e41b27
Remove empty code line 2021-09-05 16:59:12 +03:00
gabime
c0d10efabf Cleanup unix udp client 2021-09-05 16:35:11 +03:00
gabime
fecb3f4307 update comment 2021-09-05 16:34:53 +03:00
gabime
9bb66c00e9 Cleanup windows udp client 2021-09-05 16:18:14 +03:00
gabime
1ec50cdcfc update udp example 2021-09-05 11:35:00 +03:00
Gabi Melman
5906ce844a
Merge pull request #2090 from CJLove/v1.x
Add udp_sink
2021-09-05 10:25:09 +03:00
Chris Love
2e66a27081 Remove is_init() check on each log call 2021-09-04 19:29:56 -07:00
Chris Love
497fa60f57 Explicitly set SO_SNDBUF size to fix drops on Windows and address other PR feedback 2021-09-04 13:18:06 -07:00
Chris Love
2d1217006b Fix #ifdef WINDOWS_LEAN_AND_MEAN 2021-09-03 16:44:16 -07:00
Chris Love
444df2b287 Address PR comments 2021-09-03 16:36:49 -07:00
Chris Love
8ee1c167b9 Don't use std::chrono_literals 2021-09-03 11:02:12 -07:00
Chris Love
486dc5102e Winsock support 2021-09-03 10:53:29 -07:00
Gabi Melman
a1d9f501e3
Fix #2075 2021-08-28 04:38:08 +03:00
Chris Love
4501f21ae7 Fix example 2021-08-26 18:50:55 -07:00
Chris Love
649424b8ea Fix IP address of udp sink example 2021-08-26 06:36:31 -07:00
Chris Love
a15f5137ef Fix udp sink on Windows 2021-08-26 06:35:28 -07:00
Chris Love
410e641dff Fix windows include 2021-08-26 06:01:22 -07:00
Chris Love
c5fd8a0b97 Port code from prior PR (#1746), code cleanups 2021-08-25 20:32:35 -07:00
Gabi Melman
5df9b11141
Update README.md 2021-08-19 23:43:40 +03:00
Gabi Melman
e159052e6d
Merge pull request #2057 from mr-c/patch-1
List Debian instructions in the README
2021-08-19 00:54:00 +03:00
Michael R. Crusoe
23f47ebc47
List Debian instructions in the README 2021-08-18 20:10:26 +02:00
Gabi Melman
58e7f68004
Merge pull request #2056 from mguludag/patch-1
Fixed qt_sinks ctor
2021-08-17 19:24:58 +03:00
Gabi Melman
29e5930090
Update logger.h 2021-08-17 19:21:39 +03:00
Gabi Melman
deb178a0b1
Merge pull request #2048 from D-r-P-3-p-p-3-r/feature/2046_improved_error_handler_message
Added additional information for error handler
2021-08-17 19:20:52 +03:00
Muhammed Galib Uludag
e185926beb
Fixed qt_sinks ctor
Removed default args #2055
2021-08-17 18:58:34 +03:00
Wolfgang Petroschka
0d10e21c2f Remove inner try catch in SPDLOG_LOGGER_CATCH
The fmt::format call should not throw formatting the exception message and the source code location.
2021-08-17 17:50:35 +02:00
Wolfgang Petroschka
ed27592537 Switch additional information to source location of bad log message 2021-08-17 15:26:59 +02:00
Wolfgang Petroschka
df45d78d14 Windows/wchar problems
Mixing char types in libfmt is a problem and WIP.
2021-08-13 13:53:35 +02:00
Wolfgang Petroschka
c98b29aa67 Fix empty additional info, 2nd try
There's actually a diffent string view type for wide string...
2021-08-13 12:49:02 +02:00
Wolfgang Petroschka
388679b00e Fix empty additional info
does not work with wchar_t based string.
2021-08-13 12:30:49 +02:00
Wolfgang Petroschka
119467c580 Added additional information for error handler
Useful when formatting log messages fails. Now you can tell which log message caused the problem.
2021-08-13 12:11:59 +02:00
Gabi Melman
c2550ac24a
Merge pull request #2047 from seker/v1.x
better file name for hourly file sink
2021-08-13 10:27:53 +03:00
辛文
12ee35a3d1 better file name for hourly file sink 2021-08-13 13:55:12 +08:00
Gabi Melman
eb3220622e
Bump version to 1.9.2 2021-08-12 14:10:50 +03:00
Gabi Melman
8f26e819ad
Merge pull request #2036 from madeso/v1.x
The install instructions for "header only" refers to the wrong folder
2021-08-12 13:02:44 +03:00
Gabi Melman
b6b1c2f95d
Update .travis.yml 2021-08-10 22:09:30 +03:00
Gabi Melman
9ce9804a88
Update .travis.yml 2021-08-10 22:05:54 +03:00
Gabi Melman
ddaa61ca9a
Revert changes 2021-08-10 16:53:22 +03:00
Gabi Melman
4646bd082a
Update rotating_file_sink-inl.h 2021-08-10 15:41:03 +03:00
Gabi Melman
53aca9c3d0
C++20 support 2021-08-10 14:17:20 +03:00
Gabi Melman
aa1e794213
Update .travis.yml 2021-08-10 12:37:13 +03:00
Gabi Melman
45e3b678b0
Merge pull request #2037 from dkavolis/v1.x
Fix #2034
2021-08-09 20:07:45 +03:00
Gabi Melman
bd99496423
Merge pull request #2035 from dmerkushov/v1.x
bin_to_hex.h: include spdlog.h
2021-08-09 20:04:18 +03:00
dkavolis
e471ec884e remove conditional is_convertible_* structs for wide chars 2021-08-09 17:33:00 +01:00
Dmitriy Merkushov
b400705a1c bin_to_hex.h: include common.h instead of spdlog.h 2021-08-09 19:27:24 +03:00
dkavolis
cb35191fc1 clang is acting weird with disabled constructors 2021-08-09 09:59:57 +01:00
Gustav
1945a93b33
chore: the link points to the include, make sure the text reflect this 2021-08-09 09:36:11 +02:00
Dmitriy Merkushov
dfd12e6dac bin_to_hex.h: include spdlog.h to support inclusion of bin_to_hex.h in any order with spdlog.h 2021-08-07 01:50:09 +03:00
Gabi Melman
ba29e1d75d
Merge pull request #2030 from neheb/v1.x
remove std::distance usage
2021-08-05 09:37:32 +03:00
Rosen Penev
8f6d123586 remove std::distance usage
std::distance internally runs a loop, which may or may not be optimized
away. Just use simple arithmetic.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-04 17:07:18 -07:00
Gabi Melman
d368ed586c
Merge pull request #2029 from daverigby/relocatable_export
Ensure exported package is relocatable
2021-08-04 20:02:52 +03:00
Dave Rigby
87095a9f1f Ensure exported package is relocatable
As per CMake's Importing and Exporting Guide[1],
configure_package_config_file() should be used for configuring the
package configuration file, not the regular configure_file() function.

This ensures that a spdlog package built on one system (with a given
directory tree) can be imported from a different system -
e.g. creating a pre-compiled spdlog package for use on different
systems.

[1]: https://cmake.org/cmake/help/git-stage/guide/importing-exporting/index.html#id8
2021-08-04 15:34:27 +01:00
Gabi Melman
dd6d203488
Merge pull request #2026 from hbwang15/feature/include_twice_fix
fix include file twice in the same file
2021-08-03 11:35:51 +03:00
wanghengbing
f463ebf54a fix include file twice in the same file 2021-08-03 11:36:12 +08:00
Gabi Melman
3547d7e24f
Merge pull request #2025 from jabartek/mongo_make_unique
Removal of C++14-specific std::make_unique from mongo_sink.h
2021-08-02 15:24:02 +03:00
Bartlomiej Janowski
a9c01aba78 Changed mongo_sink.h so that it does not use C++14-specific std::make_unique 2021-08-02 13:38:59 +02:00
Gabi Melman
f237947bdc
Merge pull request #2024 from p-ranav/patch-1
Fixed typo in README
2021-07-30 17:33:10 +03:00
Pranav
890df3d90b
Fixed typo 2021-07-29 21:26:53 -05:00
Gabi Melman
14783585b6
Fix #2022 2021-07-29 10:09:52 +03:00
Gabi Melman
243c4beac7
Merge pull request #2018 from mguludag/v1.x
Added common class for all qt objects
2021-07-28 22:51:15 +03:00
Muhammed Galib Uludag
fe9cb54e0d
Added factory function overloads for QTextEdit, QPlainTextEdit and QObject
Added factory funtion overloads for QTextEdit, QPlainTextEdit and QObject objects
cleaned qt_sink ctor
2021-07-28 22:35:09 +03:00
Muhammed Galib Uludag
dabec32748
Added common class for all qt objects
Removed separate class for qt_sinks and also send logs to any custom qt (QObject) classes (QML, QFile, custom Widget etc.)
2021-07-28 16:23:43 +03:00
Gabi Melman
6faa5fc95b
Update to version 1.9.1 2021-07-28 15:30:08 +03:00
Gabi Melman
dbbec6cdb4
Merge pull request #2016 from mguludag/v1.x
Simplified Qt sinks
2021-07-28 02:08:10 +03:00
Muhammed Galib Uludag
43923cf038
Merge branch 'v1.x' into v1.x 2021-07-28 00:48:48 +03:00
Muhammed Galib Uludag
2ccba49b01
removed nullptr checks and renamed member vars 2021-07-28 00:06:12 +03:00
Muhammed Galib Uludag
362fdc6ceb
trim newline chars instead of remove 2 chars 2021-07-27 23:42:00 +03:00
Gabi Melman
7bb53541e4
Merge pull request #2015 from MadMax411/change-qt-sink-delete-newline-chars
Trim the newline-chars instead of removing of 2 chars
2021-07-27 23:15:59 +03:00
Muhammed Galib Uludag
c07b3aeef9
Simplified Qt sinks
Removed private class that derived from QObject
2021-07-27 23:05:24 +03:00
Muhammed Galib Uludag
fb47935a7b
Delete qt_sinks .h 2021-07-27 23:04:26 +03:00
Muhammed Galib Uludag
ec3538c2ee
Simplified Qt sinks
Removed private class that derived from QObject
2021-07-27 22:55:43 +03:00
Markus Neugebauer
84e15d1ee2 Trim the newline-chars instead of removing of 2 chars 2021-07-27 21:45:34 +02:00
Gabi Melman
5b4c4f3f77
Merge pull request #2011 from sjanel/bugfix/fixclangcompilation
Fix compilation error in clang 13 in C++20 mode - ambiguous call to log function
2021-07-27 12:26:34 +03:00
Stephane Janel
aecdfc60a0 Fix comment and clang-format 2021-07-27 09:19:02 +02:00
Gabi Melman
816ede3a17
Revert e93115f436dcbeaf5dd664053b4dc53af60766f4 because won't compile under mscv 2017 2021-07-27 02:43:54 +03:00
Gabi Melman
353c79ca71
Update .travis.yml 2021-07-27 01:49:36 +03:00
Gabi Melman
e93115f436
Fixed compile under c++20 and clang 12 2021-07-27 01:44:52 +03:00
Gabi Melman
197c9639bb
Fixed compile under c++20 and clang 12 2021-07-27 01:37:15 +03:00
Gabi Melman
a358a38b84
Update .travis.yml 2021-07-27 01:31:34 +03:00
Gabi Melman
16d76e2293
Update .travis.yml 2021-07-27 01:29:36 +03:00
Gabi Melman
536e583cbe
Merge pull request #2013 from gabime/pr-2011
Fix ambiguous error in clang13 and c++20
2021-07-27 01:12:48 +03:00
gabime
9049f9aeb9 Fix ambiguous error in clang13 and c++20 2021-07-27 00:26:32 +03:00
Gabi Melman
bee3e63e1b
Merge pull request #2008 from dkavolis/v1.x
Enable format string compile time validation
2021-07-22 19:54:14 +03:00
dkavolis
d8f13cbd5b replace FormatString template argument with fmt::basic_format_string 2021-07-22 16:23:56 +01:00
gabime
0f39da5490 Updated example 2021-07-22 12:44:41 +03:00
Gabi Melman
28fef35a12
Merge pull request #2010 from dkavolis/fmt_string
Check args on formatting
2021-07-22 02:32:28 +03:00
dkavolis
1344d44a5a check args on formatting 2021-07-21 23:54:11 +01:00
gabime
61ed2a670e bump version number to 1.9.0 2021-07-20 23:01:34 +03:00
gabime
db1bc035f7 clang-format 2021-07-20 22:55:47 +03:00
gabime
8de6cdaa82 bump version number to 1.8.6 2021-07-20 22:52:37 +03:00
gabime
fe1a4f5fb6 Added SPDLOG_FMT_RUNTIME macro for compatibilty with fmt prior 8 2021-07-20 17:18:40 +03:00
gabime
d38f89cae8 Fixed daily_file_sink compilation under c++20 2021-07-20 15:02:39 +03:00
gabime
9c90fe8264 Fixed wchar support 2021-07-20 12:53:50 +03:00
gabime
b85a666f72 Enabled parallel build under msvc 2021-07-19 16:33:31 +03:00
Gabi Melman
5ba95f6816
Update logger.h 2021-07-19 03:46:01 +03:00
Gabi Melman
dc38b7c3c4
Update logger.h 2021-07-19 03:20:34 +03:00
Gabi Melman
6484b03dd9
Update logger.h 2021-07-19 03:09:37 +03:00
gabime
29235d9b4b minor string_view change and comment 2021-07-19 01:15:53 +03:00
gabime
4b3687f1a6 Removed unneeded macro definition 2021-07-19 01:11:45 +03:00
gabime
e7e8b75a4c clang-format 2021-07-19 00:50:51 +03:00
gabime
e98265a49b cosmetic reorder of logger funcs definitions 2021-07-19 00:48:01 +03:00
gabime
e87f69bdb6 Removed check if format string can be converted to fmt::is_compile_string 2021-07-19 00:12:17 +03:00
Gabi Melman
70d2832c0d
Update README.md 2021-07-14 16:30:54 +03:00
gabime
7636f1f659 revert some changes made by mistake 2021-07-14 14:33:45 +03:00
gabime
1523c83650 Added fmt/compile.h bundled file 2021-07-14 14:28:34 +03:00
Gabi Melman
a6987efaec
Update README.md 2021-07-14 13:51:23 +03:00
Gabi Melman
6491abb519
Update .travis.yml 2021-07-10 19:14:47 +03:00
gabime
8faabb4e3a Fix msvc compile 2021-07-10 17:33:08 +03:00
gabime
2838c2c8a5 use vformat_to instead for format_to for better performance 2021-07-10 17:00:13 +03:00
gabime
3315bad009 Treat wall warnings as errors if SPDLOG_BUILD_WARNINGS is ON 2021-07-10 15:22:44 +03:00
gabime
3eeced78b5 Removed some cmake wdev warnings 2021-07-10 15:15:39 +03:00
gabime
c23430b438 Fixed cast warning 2021-07-10 14:31:56 +03:00
Gabi Melman
0e49bfff51
Update .travis.yml 2021-07-10 14:20:06 +03:00
Gabi Melman
3ed40d04a9
Update .travis.yml 2021-07-10 14:14:09 +03:00
gabime
70b36aa55d Remove fmt::runtime() wrapper in logger.h 2021-07-10 14:07:32 +03:00
gabime
0f83b33d4f backward compatibility with fmt version < 8 2021-07-10 13:48:06 +03:00
gabime
b83106bed4 Update bundled fmt to v8.0.1 2021-07-03 23:10:57 +03:00
Gabi Melman
21413e599a
Update qt_sinks.h 2021-06-29 02:20:48 +03:00
Gabi Melman
5f4cc7b036
Merge pull request #1986 from mguludag/v1.x
Added QTextEdit and QPlainTextEdit sink
2021-06-29 02:18:00 +03:00
Muhammed Galib Uludag
9aa26fb969
Added Qt sinks 2021-06-29 01:04:25 +03:00
Muhammed Galib Uludag
7f74012a0d
Delete qtextedit_sink.h 2021-06-29 01:02:16 +03:00
Muhammed Galib Uludag
96ebef093f
Delete qtextedit_sink_p.h 2021-06-29 01:01:48 +03:00
Muhammed Galib Uludag
a19f4bba0c
Delete qplaintextedit_sink_p.h 2021-06-29 01:01:40 +03:00
Muhammed Galib Uludag
c24b957e17
Delete qplaintextedit_sink.h 2021-06-29 01:01:18 +03:00
Muhammed Galib Uludag
5ba2f77230
Added QPlainTextEdit sink
QPlainTextEdit performs better than QTextEdit and its derivatives and also it has rich features
2021-06-28 23:16:23 +03:00
Muhammed Galib Uludag
a09f490804
Implemented QTextEdit and, QTextBrowser sink 2021-06-28 23:13:37 +03:00
Gabi Melman
082d6fbea9
Merge pull request #1984 from hctym1995/v1.x
Add a color-terminal type
2021-06-28 15:10:01 +03:00
zyw1995ted@163.com
37372960a8 add a color-terminal type 2021-06-28 18:12:12 +08:00
gabime
0035a0c98d Fixed dup sink compile warnings in older compilers with back_inserter 2021-06-28 12:09:39 +03:00
Gabi Melman
036cc5d575
Merge pull request #1982 from mguludag/v1.x
ignore pattern formatting
2021-06-27 23:11:39 +03:00
Muhammed Galib Uludag
14950926ed
ignore pattern formatting for message section in mongodb 2021-06-27 22:50:31 +03:00
Muhammed Galib Uludag
baa3b1a07e
Merge branch 'gabime:v1.x' into v1.x 2021-06-27 20:32:52 +03:00
Gabi Melman
2a09f66a44
Remove un needed functions and added override keyword 2021-06-27 20:32:01 +03:00
Muhammed Galib Uludag
e50b62c770
suppressed unused var 2021-06-27 20:30:41 +03:00
Gabi Melman
13d8b0f17f
Merge pull request #1981 from mguludag/v1.x
added mongodb sink
2021-06-27 20:30:08 +03:00
Muhammed Galib Uludag
9e0c658b29
factory functions namespace fix 2021-06-27 20:17:19 +03:00
Muhammed Galib Uludag
74fec56927
Changed base class to base_sink and added factory functions 2021-06-27 19:59:07 +03:00
Muhammed Galib Uludag
514f304a47
changed license template for compability to other spdlog headers 2021-06-27 18:06:44 +03:00
Muhammed Galib Uludag
7f85a5c988
change license to mit 2021-06-27 17:53:19 +03:00
Muhammed Galib Uludag
14d626d961
added mongodb sink 2021-06-27 16:16:39 +03:00
Gabi Melman
7560cacb3f
Update .travis.yml 2021-06-27 00:31:34 +03:00
Gabi Melman
3cd9bcdab9
Update dup_filter_sink.h 2021-06-27 00:21:03 +03:00
Gabi Melman
32f1efdc99
Update dup_filter_sink.h 2021-06-27 00:11:31 +03:00
Gabi Melman
bcc9f03457
Update .travis.yml 2021-06-27 00:01:44 +03:00
Gabi Melman
4c845bf02b
Update dup_filter_sink.h 2021-06-26 23:40:11 +03:00
Gabi Melman
c727864393
Update .travis.yml 2021-06-26 23:25:27 +03:00
Gabi Melman
4548573a75
Update .travis.yml 2021-06-26 23:18:22 +03:00
Gabi Melman
385246730d
Update .travis.yml 2021-06-26 23:14:26 +03:00
Gabi Melman
e06d21a4c0
Update .travis.yml 2021-06-26 22:53:48 +03:00
Gabi Melman
c132d2ae8c
Update .travis.yml 2021-06-26 22:51:28 +03:00
Gabi Melman
ece31100e0
Update appveyor.yml 2021-06-26 22:47:32 +03:00
Gabi Melman
ce4e1ac54b
Update appveyor.yml 2021-06-26 22:44:02 +03:00
Gabi Melman
ef61fb11f0
Update README.md 2021-06-26 22:21:55 +03:00
Gabi Melman
42f2b11ec8
Update .travis.yml 2021-06-26 21:46:49 +03:00
Gabi Melman
ac87cbb0d1
Update appveyor.yml 2021-06-26 21:44:03 +03:00
Gabi Melman
c65de3d689
Update appveyor.yml 2021-06-26 21:41:15 +03:00
Gabi Melman
1433fa4209
Update appveyor.yml 2021-06-26 21:40:42 +03:00
Gabi Melman
d51149e5ac
Update appveyor.yml 2021-06-26 20:45:29 +03:00
Gabi Melman
ffd813435a
fix compile error again with wchar formatting 2021-06-26 20:10:21 +03:00
gabime
d75fd2c7f9 Fixed wchar support under msvc 2021-06-26 19:43:37 +03:00
gabime
cdad84aa46 merge 2021-06-26 18:02:09 +03:00
gabime
0fdb545d8c Fixed clang c++20 compile 2021-06-26 17:59:08 +03:00
gabime
a5f5ff70e0 Fixed clang c++20 compile 2021-06-26 17:58:45 +03:00
gabime
4f0e320236 Fixed format string in bench 2021-06-26 17:52:55 +03:00
gabime
68aed6a5eb Fixed building under c++17 2021-06-26 17:36:57 +03:00
Gabi Melman
6811112208
Update logger.h 2021-06-24 19:42:12 +03:00
gabime
9ebc4b24d9 Added missing args.h file 2021-06-24 17:26:02 +03:00
gabime
b990080a52 Fixed fmt locale.h deprecation warning 2021-06-24 17:22:06 +03:00
gabime
efbe3e4d57 Added missing fmt 8 headers 2021-06-24 17:17:27 +03:00
gabime
7b14a65b2b Fixed format_to deprecated warning by wrapping the buffer with std::back_inserter 2021-06-24 17:07:14 +03:00
gabime
5887744d8b Fixed bin2hex to work with fmt v8 2021-06-24 15:58:25 +03:00
gabime
8bf718671a Update fmt version 8.0 2021-06-24 13:22:02 +03:00
Gabi Melman
c858b14c03
Update clang format to format cpp macros 2021-06-20 23:20:36 +03:00
Gabi Melman
12df172575
Merge pull request #1971 from SpriteOvO/v1.x
Use std::function for the global error handler
2021-06-16 01:25:09 +03:00
Sprite
7fa751d36e Use std::function for the global error handler 2021-06-16 05:04:17 +08:00
Gabi Melman
7a7611e977
Merge pull request #1970 from bansan85/v1.x
Fix signed/unsigned mismatch in VS
2021-06-13 21:49:08 +03:00
LE GARREC Vincent
ec8763adf2
Fix signed/unsigned mismatch in VS 2021-06-13 19:35:02 +02:00
Gabi Melman
f2d1d573f5
Fix #1967 2021-06-07 22:39:42 +03:00
Gabi Melman
a530b87fd0
Merge pull request #1961 from jafj/FixCxx20Wdeprecated-copy
Fix C++20 build resulting in deprecated implicit copy assignment operator warning
2021-06-02 12:15:38 +03:00
JB_12
6c21789aed Fix C++20 build resulting in deprecated implicit copy assignment operator warning 2021-06-02 08:20:29 +01:00
Gabi Melman
616866fcf4
Merge pull request #1958 from mlund/v1.x
Allow compilation with nvc++ (and possibly PGI)
2021-05-30 22:14:02 +03:00
Mikael Lund
faf06bcfe5 Add newlin to color_sinks.cpp 2021-05-30 13:07:16 +01:00
Mikael Lund
cd376a5c43 Allow compilation with nvc++ 2021-05-30 13:02:56 +01:00
Gabi Melman
6ba5ab6d67
Merge pull request #1948 from stevenlunt/v1.x
add macros for overriding the individual level names
2021-05-20 01:09:09 +03:00
steven lunt
1bee3218b4 cleanup thanks to gabime 2021-05-19 17:51:03 -04:00
steven lunt
802eaadd2d add macros for overriding the individual level names 2021-05-19 10:45:33 -04:00
steven lunt
ee22eed23d add macros for overriding the individual level names 2021-05-18 19:36:45 -04:00
steven lunt
ab72de5f7a Revert "added spdlog::level::set_string_view to enable alternate log level names without changing the build via SPDLOG_LEVEL_NAMES"
This reverts commit 2a16d1d2303164618694361513f2ec1391d8f3e4.
2021-05-18 19:25:07 -04:00
steven lunt
a32cea24fd Revert "remove constexpr on level_string_views to fix compilation on C++17 from addition of set_string_view"
This reverts commit ac3e26b0ffeffe1f9b030fabdfcb124dc878480e.
2021-05-18 19:24:44 -04:00
Gabi Melman
af0d805be4
Merge pull request #1946 from jafj/EnableCMakePolicyCMP0077
Add support for CMake policy CMP0077
2021-05-17 01:54:23 +03:00
JB_12
181c22f798 Add support for CMake policy CMP0077 2021-05-16 22:49:02 +01:00
Gabi Melman
87133ef6b7
Merge pull request #1933 from neheb/s
small std::find conversion
2021-05-11 02:12:46 +03:00
Rosen Penev
1ef2f014ee small std::find conversion
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-05-10 14:42:28 -07:00
Gabi Melman
0a92d1d684
Merge pull request #1931 from vadz/msvc-undef-warning-fix
Fix warning about testing _WIN64 which might be undefined
2021-05-07 01:05:41 +03:00
Vadim Zeitlin
ff5221b693 Fix warning about testing _WIN64 which might be undefined
This warning is disabled by default, but is pretty useful and worth
enabling for MSVC, just as -Wundef for gcc, so fix it in Win32 build.
2021-05-06 22:33:41 +01:00
Gabi Melman
db484cc4b8
Merge pull request #1930 from vadz/msvc-unreachable-warning-fix-alt
Avoid harmless warning about unreachable statement in MSVS build
2021-05-07 00:27:45 +03:00
Vadim Zeitlin
6442963f49 Avoid harmless warning about unreachable statement in MSVS build
All MSVS versions >= 2015 warn about "return 0" after throw_spdlog_ex()
being unreachable in filesize(), so disable this warning in this
function (note that it can't be disabled inside it).
2021-05-06 22:02:25 +01:00
Gabi Melman
0f7b95ce47
Merge pull request #1924 from lnovey/remove-c-style-casts
Change c-style casts to reinterpret casts in tcp_client
2021-05-03 20:12:03 +03:00
Luke Novey
632a2e0894 Change c-style casts to reinterpret casts 2021-05-03 12:33:58 -04:00
gabime
e9635c7b2d rethrnow non std exceptions to fix #533 2021-05-01 00:29:36 +03:00
Gabi Melman
8e3b1338a5
Merge pull request #1918 from matt77hias/v1.x
Made mutex member variable mutable
2021-04-22 22:48:29 +03:00
Matthias Moulin
9d3dde0900
Made mutex member variable mutable
Classes inheriting from `base_sink` can now lock the base mutex inside their `const` member methods (e.g., basic accessors).
2021-04-22 21:19:54 +02:00
Gabi Melman
c5abaeddca
Merge pull request #1916 from haifengkao/FixNoNewLineAtEndOfFile
fix Xcode compiler warning "no new line at the end of file"
2021-04-20 22:31:56 +03:00
Hai Feng Kao
ca2cd6f3e7 fix Xcode compiler warning "no new line at the end of file" 2021-04-20 12:43:56 +08:00
Gabi Melman
7d07e0312a
Update README.md 2021-04-10 13:07:36 +03:00
Gabi Melman
e1c73fd8f4
Update README.md 2021-04-10 13:05:39 +03:00
Gabi Melman
b83ab21283
Update README.md 2021-04-10 13:02:16 +03:00
Gabi Melman
8001156ca8
Update stdout_sinks-inl.h 2021-04-08 23:20:36 +03:00
Gabi Melman
57e31f0a58
Merge pull request #1906 from LonghronShen/v1.x
fix bug #1790
2021-04-08 23:18:20 +03:00
Gabi Melman
51fadf6b7e
Merge pull request #1912 from SUPERustam/v1.x
Minor update, PEP8 format and f-string instead of format method
2021-04-08 23:13:33 +03:00
Gabi Melman
2a6a8aa0a0
Merge pull request #1913 from bsergean/patch-1
Update pattern_formatter-inl.h full_formatter comment to describe the default logging pattern expression accurately
2021-04-08 21:11:53 +03:00
Benjamin Sergeant
aa264a7fb2
Update pattern_formatter-inl.h
Comment describing the default logging pattern is missing [%s:%#], which is the abbreviated source file + the line number.

I tried to customize our own logger by copy pasting this info, and then I noticed we had lost that information.
2021-04-08 09:05:55 -07:00
SUPERustam
5e35c2b6ab
Update extract_version.py 2021-04-08 09:56:01 +03:00
Steven Hangger
0385372314
fix bug #1790 2021-04-05 20:00:22 +08:00
Gabi Melman
efbff95ec7
Merge pull request #1900 from nandanvasudevan/patch-1
Minor typo
2021-04-03 16:16:04 +03:00
Nandan V
2a9edb2153
Minor typo 2021-04-03 11:42:35 +00:00
Gabi Melman
be14e60d9e
Merge pull request #1891 from Hugoto69/patch-1
Update .clang-tidy
2021-03-25 22:15:12 +02:00
Hugo Bonnet
ef4641cad7
Update .clang-tidy 2021-03-25 20:43:51 +01:00
Gabi Melman
100f30043f
Update version.h 2021-03-25 21:00:48 +02:00
Gabi Melman
1574b5b0a2
Merge pull request #1889 from stevenlunt/set_string_view
remove constexpr on level_string_views to fix compilation on C++17 fr…
2021-03-25 20:59:37 +02:00
Gabi Melman
012fe99ab1
Update version.h 2021-03-25 20:34:53 +02:00
Gabi Melman
8ff5a3e096
Merge pull request #1890 from prince-chrismc/patch-4
Remove version requirement from fmt find_package
2021-03-25 19:22:51 +02:00
Chris Mc
65317eb019
Remove version requirement from fmt find_package
By introducing 'no module' support this inadvertently triggered the find_package to use the "full version" version selection.

From https://cmake.org/cmake/help/latest/command/find_package.html#version-selection:

> When the [version] argument is given, Config mode will only find a version of the package that claims compatibility with the requested version (see format specification).

FMT does not set this configuration https://github.com/fmtlib/fmt/blob/7.1.3/support/cmake/fmt-config.cmake.in... but regardless it would not be "any compatibility" based on version semantics.

Which causes this error. v1.8.2 builds perfectly fine.

```
CMake Error at CMakeLists.txt:181 (find_package):
  Could not find a configuration file for package "fmt" that is compatible
  with requested version "5.3.0".

  The following configuration files were considered but not accepted:

    /home/proj/build/e98598522b7c484d9220bffc7ec84474515facbc/fmt-config.cmake, version: 7.1.3
```
2021-03-24 21:54:36 -04:00
steven lunt
ac3e26b0ff remove constexpr on level_string_views to fix compilation on C++17 from addition of set_string_view 2021-03-24 18:20:08 -04:00
Gabi Melman
e86f450428
Merge pull request #1885 from ahmedyarub/fix_android_build
Add required libraries for Android CMake build
2021-03-25 00:14:41 +02:00
Gabi Melman
7b2776fdc7
Merge pull request #1888 from stevenlunt/set_string_view
added spdlog::level::set_string_view to enable alternate log level na…
2021-03-24 23:10:11 +02:00
steven lunt
2a16d1d230 added spdlog::level::set_string_view to enable alternate log level names without changing the build via SPDLOG_LEVEL_NAMES 2021-03-24 16:22:54 -04:00
Gabi Melman
53e1c9ab11
Update version number to 1.8.3 2021-03-24 21:49:10 +02:00
Gabi Melman
410abc4626
Added the Windows Event logger to readme features 2021-03-24 01:45:26 +02:00
Ahmed Yarub Hani Al Nuaimi
a2e28443f0
Add required libraries for Android CMake build 2021-03-22 00:08:17 -03:00
Gabi Melman
c1af0a3f21
Merge pull request #1882 from imsherlock/v1.x
add default cases
2021-03-20 21:02:57 +02:00
Ryan Sherlock
bb5e1ee2f9 Removing changes to bundled fmt
Removing changes to the bundled fmt library. The default case
statements will be changed in the upstream library.

Signed-off-by: Ryan Sherlock <sherlock@loftorbital.com>
2021-03-20 09:22:40 -07:00
Ryan Sherlock
3aee89c8fd add default cases
Adding default case for cases where the compilation flag
-Wswitch-default is present on the command line when spdlog is
included in external projects.

Signed-off-by: Ryan Sherlock <ryan.m.sherlock@gmail.com>
2021-03-19 10:06:09 -07:00
gabime
44e1f9f682 Added nonreturn sepcifier to fix #1748 2021-03-17 00:25:26 +02:00
gabime
37d76b961c Fix #1876 2021-03-16 23:39:55 +02:00
gabime
1305663d99 make sure __cplusplus is defined under msvc 2021-03-12 15:10:15 +02:00
gabime
8f4efe57a2 make sure __cplusplus is defined under msvc 2021-03-12 15:09:35 +02:00
gabime
0613dbc4a2 Revert pr #1860 2021-03-04 23:52:50 +02:00
Gabi Melman
0ed0d69368
Update CMakeLists.txt 2021-03-04 23:24:02 +02:00
Gabi Melman
2ffbbee1f6
Merge pull request #1860 from rofferom/msvc-allow-static-runtime
CMake: Add SPDLOG_STATIC_VCRT to choose static MSVC runtime
2021-03-04 23:17:32 +02:00
Romain Roffé
b9d2f2537b CMake: Add SPDLOG_STATIC_VCRT to choose static MSVC runtime 2021-03-04 20:14:18 +01:00
Gabi Melman
69dc173979
Update README.md 2021-03-03 00:17:33 +02:00
Gabi Melman
ded8b5ebd4
Added build2 to package managers section in readme 2021-03-03 00:16:59 +02:00
Gabi Melman
ed58ae9f98
Revert PR #1851 2021-03-02 22:49:11 +02:00
Gabi Melman
f7f790b4b3
Merge pull request #1851 from Klaim/patch-1
Add build2 package support
2021-03-02 22:37:43 +02:00
Klaim (Joël Lamotte)
fe74c80992
Add build2 package support
WARNING: Please do not merge yet! See below.

We are currently in the process of packaging `spdlog` for `build2`, we have it working (even on unsupported Windows, see for example: https://ci.stage.build2.org/@a993b64e-8ba2-422e-97d7-250cdb5828e0?builds=&pv=&tc=*&cf=&mn=&tg=&rs=*)

This change simply adds the necessary information to use this package when using `build2`. Some notes:
 - not sure how to give the info succintly because `build2` allows packages to come from different sources, including the git repository of the package - in doubt I just linked to the future community repository address providing all the info, but the other package manager didn't do it like that so not sure if it's ok for you?; 
 - `build2` distinguish the package (`depends: spdlog <some-version-scheme>`, added in the `manifest` file of a `build2` project) and the target (`spdlog%lib{spdlog}` imported in a `buildfile`) because packages can contain several targets. I was not sure how to formulate that here, so feel free to tell me if I should just provide the name of the package and not more info?

The package isn't available yet so this have to be merged only once it is made available (probably in a few days).
2021-02-27 14:45:55 +01:00
Gabi Melman
fa659bf7ad
Update daily_file_sink.h 2021-02-27 11:18:12 +02:00
Gabi Melman
9b41649601
Merge pull request #1849 from concatime/cmake-library-type-option-flag
CMake: Replace custom SPDLOG_BUILD_SHARED by standard BUILD_SHARED_LIBS
2021-02-26 23:35:23 +02:00
Issam E. Maghni
1b3438f5a5 AppVeyor: Use standard BUILD_SHARED_LIBS 2021-02-26 16:26:53 -05:00
Issam E. Maghni
3eed64e5c4 CMake: Replace custom SPDLOG_BUILD_SHARED by standard BUILD_SHARED_LIBS 2021-02-26 16:26:50 -05:00
Gabi Melman
0fac33781d
Update daily_file_sink.h 2021-02-26 12:38:49 +02:00
Gabi Melman
3135b6a33d
Update comment 2021-02-26 12:33:43 +02:00
Gabi Melman
2686ae2322
Merge pull request #1847 from fawdlstty/v1.x
add daily sink filename format
2021-02-26 12:17:29 +02:00
fawdlstty
a709e29586 fix unique mode compile 2021-02-26 10:18:33 +08:00
fawdlstty
dd46579cb4 fix name 2021-02-26 10:17:43 +08:00
fawdlstty
f4b7210e7b remove externs 2021-02-26 09:28:12 +08:00
fawdlstty
05a0b0d7b0 use fmt::chrono and remove is_fmt flags 2021-02-26 09:21:13 +08:00
fawdlstty
c1f4d7506a replace tab 2021-02-25 23:57:37 +08:00
fawdlstty
b6ba0be550 add daily_logger_format_mt and daily_logger_format_st sink 2021-02-25 23:55:19 +08:00
Gabi Melman
23dfb4e2f9
Merge pull request #1846 from MathiasMagnus/fix-bench
Avoid relying on function name decay mechanics
2021-02-24 11:26:25 +02:00
Máté Ferenc Nagy-Egri
7a10e31982
Avoid relying on function name decay mechanics 2021-02-24 09:45:35 +01:00
Gabi Melman
de89c4fd01
Merge pull request #1835 from jneruda/v1.x
Set default value to registry::err_handler_
2021-02-18 19:49:39 +02:00
Jakub Neruda
5d4956d34b
Set default value to registry::err_handler_ 2021-02-17 14:02:20 +01:00
Gabi Melman
42c5eb59c9
Update wincolor_sink-inl.h 2021-02-14 01:49:29 +02:00
Gabi Melman
09cc6e7754 Simplify wincolor_sink::set_foreground_color_ 2021-02-14 01:03:02 +02:00
Gabi Melman
4a5bc41e89 Validate range in wincolor_sink::print_range_ 2021-02-14 00:20:44 +02:00
Gabi Melman
0ade18828d Remove switch statement from wincolor_sink::set_color_mode_impl 2021-02-13 23:53:36 +02:00
Gabi Melman
91046e6ca4 Simplify wincolor sink color mode management 2021-02-13 20:59:10 +02:00
Gabi Melman
17e1ba8ae2 simplifiy and mutex protect set_color_mode in wincolor sink 2021-02-13 20:16:15 +02:00
Gabi Melman
c47c854f15 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2021-02-13 20:06:51 +02:00
Gabi Melman
e931866b35 Removed public color constants from wincolor sink and intensify red and yellow 2021-02-13 20:06:40 +02:00
Gabi Melman
7828a065bf
Update stdout_sinks-inl.h 2021-02-13 17:45:00 +02:00
Gabi Melman
3e689e700e Handle return values of win32 color functions in wincolor sink 2021-02-13 17:26:55 +02:00
Gabi Melman
a9964afcf7 Don't throw wincolor redirection failed, to be consistent with the non-redirect behaviour 2021-02-13 16:58:04 +02:00
Gabi Melman
95c19876c6 Skip log in wincolor sink if out_handle_ is null 2021-02-13 16:55:40 +02:00
Gabi Melman
5efccfa5e2 Fix #1828 2021-02-13 16:11:07 +02:00
Gabi Melman
89e737a258 Handle invalid handle in wincolor sink 2021-02-13 15:00:35 +02:00
Gabi Melman
8fbc853b0d
Merge pull request #1829 from prateek9623/fix-prevent-msvc-warning-in-cuda
Fix: prevents MSVC warning flags to propagate in CUDA
2021-02-12 10:57:33 +02:00
Prateek Chokse
2e008b319c Fix: prevents MSVC warning flags to propagate in CUDA 2021-02-12 14:13:51 +05:30
Gabi Melman
ff6e3c95f2
Merge pull request #1819 from NukeULater/v1.x
better numeric_limits<>::max/min fix when using SPDLOG_WCHAR_TO_UTF8_SUPPORT
2021-02-06 11:32:14 +02:00
Unknown
7e9385405f better numeric_limits<>::max/min fix when using SPDLOG_WCHAR_TO_UTF8_SUPPORT
NOMINMAX macro doesn't work everytime for some reason
2021-02-06 10:50:29 +02:00
Gabi Melman
592ea36a86
Fix #1811 2021-01-21 21:12:42 +02:00
Gabi Melman
e059ebf99d
Merge pull request #1807 from ChristianPanov/patch-1
Initializer list style consistency
2021-01-21 03:02:26 +02:00
Gabi Melman
609480ed78
Merge pull request #1798 from gv-me/constexpr-log-levels
add constexpr to SPDLOG_LEVEL_NAMES declaration
2021-01-21 03:00:49 +02:00
Gabi Melman
4271185936
Merge pull request #1805 from sillykelvin/patch-1
fix compiling error and typo
2021-01-21 02:56:53 +02:00
Christian Panov
aacae62591
Initializer list style consistency 2021-01-20 20:11:34 +02:00
Kelvin Hu
47cbf3828d
fix compiling error and typo 2021-01-19 22:03:47 +08:00
Gabi Melman
46d418164d
Merge pull request #1787 from sylveon/windows-separator-filenames
Better support for / separators on Windows, improve wchar filename coverage
2021-01-12 00:29:08 +02:00
Gaurav Vaidya
ede8d84884 fix constexpr declaration for c++11 2021-01-11 11:25:27 +01:00
Gaurav Vaidya
53d223b45f add constexpr to SPDLOG_LEVEL_NAMES declaration
for #1791
2021-01-11 11:16:06 +01:00
Charles Milette
ac35dd5a6f
Prevent integer overflows in wstr_to_utf8buf and utf8_to_wstrbuf 2021-01-10 18:26:24 -05:00
Charles Milette
9e19012cb0
Remove filename_memory_buf_t from headers 2021-01-10 18:19:28 -05:00
Charles Milette
1234cda3b3
Don't build the example with wide filenames 2021-01-10 18:19:00 -05:00
Gabi Melman
710a0e3a45
Merge pull request #1795 from graydon/truncate-but-still-append
Open files with "ab" mode even if truncating.
2021-01-09 12:20:26 +02:00
Graydon Hoare
b7f24b2456
Open files with "ab" mode even if truncating. 2021-01-09 00:35:32 -08:00
Charles Milette
fc594b551a
Prevent win_eventlog_sink from silently discarding errors when wide support is enabled 2021-01-06 22:17:09 -05:00
Charles Milette
f39ccccc0c
Fix linker error 2021-01-06 21:52:59 -05:00
Charles Milette
f0a4ddd78b
Fix character issues in test_errors.cpp 2021-01-06 20:00:59 -05:00
Charles Milette
c691769e46
Fix other build errors and unit tests 2021-01-06 19:39:47 -05:00
Charles Milette
19dc30567e
Fix build errors 2021-01-06 18:55:57 -05:00
Charles Milette
a453bccff0
Better support for / separators on Windows, improve wchar filename coverage 2021-01-06 04:15:14 -05:00
Gabi Melman
aa2053a575
Merge pull request #1774 from Ryan-rsm-McKenzie/v1.x
skip module mode when finding fmt
2020-12-27 14:19:08 +02:00
ryan-rsm-mckenzie
3d8f71c4d2 skip module mode when finding fmt 2020-12-27 01:37:12 -08:00
Gabi Melman
6aaaabbc4d
Merge pull request #1773 from Ryan-rsm-McKenzie/v1.x
ensure SPDLOG_FMT_EXTERNAL is honored throughout whole codebase
2020-12-27 11:17:30 +02:00
ryan-rsm-mckenzie
42c36f48ed ensure SPDLOG_FMT_EXTERNAL is honored throughout whole codebase 2020-12-27 00:47:57 -08:00
Gabi Melman
a5f4139102
Merge pull request #1771 from Ryan-rsm-McKenzie/v1.x
ensure stdout color sinks do not leak windows headers with SPDLOG_COMPILED_LIB
2020-12-26 15:23:37 +02:00
ryan-rsm-mckenzie
030d85a9b3 ensure stdout color sinks do not leak windows headers with SPDLOG_COMPILED_LIB 2020-12-26 03:45:12 -08:00
Gabi Melman
adcfb7fb55
Merge pull request #1768 from dominicpoeschko/colorterminal_detection
Changed is_color_terminal to be more generic.
2020-12-20 03:01:42 +02:00
dominic
cec365888a Added check for COLORTERM environment variable to detect if terminal
supports color.
Added alacritty to supported color terminals.
2020-12-19 23:22:31 +01:00
Gabi Melman
55bfa8dd11
Merge pull request #1766 from shimaowo/v1.x
Fix #1765 - Add SPDLOG_DISABLE_DEFAULT_LOGGER as a cmake option
2020-12-19 07:40:39 +02:00
shimaowo
e99759fe45 Fix #1765 - Add SPDLOG_DISABLE_DEFAULT_LOGGER as a cmake option 2020-12-18 14:31:34 -08:00
Gabi Melman
17c6e6ee3f
Merge pull request #1760 from iko1/v1.x
fix windows event sink log compilation error with UNICODE preprocessor
2020-12-16 11:41:44 +02:00
Amir Alperin
7fff900a1a Fix error message in exception 2020-12-16 06:57:24 +02:00
Amir Alperin
c67974e4c8 replace deprected wchar string conversion 2020-12-16 01:14:55 +02:00
Gabi Melman
a36696e02e
Merge pull request #1763 from BVonk/v1.x
Add Hourly file sink
2020-12-16 01:11:51 +02:00
BVonk
9b80ca6c41
Add files via upload 2020-12-15 17:21:09 +01:00
Amir Alperin
22f514aabf restore ident format 2020-12-13 23:11:25 +02:00
Amir Alperin
211478e13e convert message back to wchar 2020-12-13 10:45:55 +02:00
Amir Alperin
5e33a7e58b fix compilation errors 2020-12-13 10:11:00 +02:00
gabime
b2e31721e8 Update example 2020-12-11 16:58:49 +02:00
gabime
de0dbfa359 version 1.8.2 2020-12-11 16:40:52 +02:00
gabime
f93459579f version 1.9.0 2020-12-11 16:37:37 +02:00
gabime
2b81c40b90 Bump fmt to version 7.1.3 2020-12-11 16:32:39 +02:00
Gabi Melman
233e97c5e4
Merge pull request #1749 from bluescarni/pr/async_test_fix
Increase sleep time on a test case to avoid spurious failures
2020-11-26 11:03:46 +02:00
Francesco Biscani
fc1ce48dc7 Increase sleep time on a test case to avoid spurious failures. 2020-11-26 09:45:39 +01:00
Gabi Melman
fd5562eebe
Merge pull request #1744 from ArnaudBienner/ArnaudBienner-readme-patch
📝 README example: Add {:a} format flag to bin_to_hex example
2020-11-23 02:01:34 +02:00
ArnaudBienner
0695d9cb5f
📝 README example: Add {:a} format flag to bin_to_hex example
Add {:a} format flag to bin_to_hex example
2020-11-22 20:54:28 +01:00
Gabi Melman
456b24134d
Merge pull request #1742 from jwittbrodt/v1.x
Add missing include
2020-11-20 18:13:49 +02:00
Jonas Wittbrodt
f8ba24afee add missing <algorithm> include 2020-11-19 14:09:33 +01:00
Gabi Melman
eebb921c9f
Merge pull request #1735 from o2gy84/v1.x
Ability to get size of messages queue of async thread pool
2020-11-13 12:59:52 +02:00
Могилин Виктор
e17ee87f38 Ability to get size of messages queue of async thread pool 2020-11-13 13:12:32 +03:00
Gabi Melman
18e3f07f7d
Fix #1710 2020-11-05 18:27:31 +02:00
Gabi Melman
9ce39a470f
Merge pull request #1726 from dkavolis/v1.x
Perfect forwarding for arguments
2020-11-02 04:02:38 +02:00
dkavolis
23572369fc Perfect forwarding for arguments 2020-11-02 00:37:03 +00:00
Gabi Melman
01b350de96
Merge pull request #1712 from ChristofKaufmann/deb-package
Add CPack debian package settings
2020-10-20 22:23:45 +03:00
Christof Kaufmann
365e470a32 Add CPack debian package settings 2020-10-20 19:57:56 +02:00
Gabi Melman
a42b40656c
Merge pull request #1711 from ChristofKaufmann/fix-typo
Fix typo in comment
2020-10-20 10:00:43 +03:00
Christof Kaufmann
40160f2a57 Fix typo in comment 2020-10-20 02:49:09 +02:00
Gabi Melman
90b33b1552
Merge pull request #1709 from kitattyor/v1.x
Download googlebenchmark if not found
2020-10-17 17:56:59 +03:00
kitattyor
5567ed01e5 Download googlebenchmark if not found; requires cmake 3.11 2020-10-17 21:08:36 +08:00
gabime
cbe9448650 version 1.8.1 2020-09-30 17:30:06 +03:00
gabime
5b345534dc Minor change in ifdef for clarity 2020-09-30 17:29:44 +03:00
Gabi Melman
c8dc318fb3
Update logger-inl.h 2020-09-29 02:23:03 +03:00
Gabi Melman
23cb1a1080
Update logger-inl.h 2020-09-29 02:20:43 +03:00
Gabi Melman
21cf8d7d3c
Merge pull request #1685 from eddelbuettel/feature/r_use_of_reprintf
let R header defines switch to REprintf over fprintf(stdderr)
2020-09-29 02:18:35 +03:00
Dirk Eddelbuettel
3cf4d34094 let R header defines switch to REprintf over fprintf(stdderr) 2020-09-28 17:13:09 -05:00
Gabi Melman
16d78ae5db
Update stdout_sinks-inl.h 2020-09-28 17:08:13 +03:00
gabime
62b4b7af83 Fix #1667 2020-09-28 13:39:31 +03:00
Gabi Melman
9799ecac6a
Remove redundant size check before calling WriteFile 2020-09-27 21:27:58 +03:00
Gabi Melman
dccb766095 Fix warning about enum usage 2020-09-27 19:08:24 +03:00
gabime
c97983a91c Fix linux build 2020-09-27 18:42:27 +03:00
gabime
680fb07fd5 Updatd WriteFile usage 2020-09-27 18:34:01 +03:00
gabime
cfd0ea197c Simplify WriteFile() usage under windows 2020-09-27 18:32:08 +03:00
gabime
48d4ed9bc0 Fix #1675 2020-09-27 18:27:41 +03:00
gabime
3bed78356e Added cfg tests 2020-09-27 02:10:52 +03:00
gabime
8923922f30 Cleaned level loading from env var 2020-09-27 02:08:24 +03:00
gabime
7542e42e4f removed extra parentheses 2020-09-27 01:05:55 +03:00
Gabi Melman
7a9b23e4f4
Update registry-inl.h 2020-09-26 16:09:43 +03:00
gabime
47253ba2a1 Updated comment 2020-09-26 15:56:57 +03:00
gabime
69b54dd9e4 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2020-09-26 15:49:21 +03:00
gabime
36138617fc small readablilty update in registry 2020-09-26 15:36:57 +03:00
gabime
231ca50700 clang-format 2020-09-26 15:34:05 +03:00
gabime
c7613f3e91 Fixed #1680 2020-09-26 15:32:44 +03:00
gabime
05d5546eb1 Restore example 2020-09-26 15:30:45 +03:00
gabime
cefe67726e wip fix #1680 again 2020-09-26 15:06:53 +03:00
gabime
1ac2dcc537 wip fix #1680 again 2020-09-26 14:41:33 +03:00
gabime
3a68eecb28 Fix issue #1680 2020-09-25 18:19:50 +03:00
gabime
54a8259b42 Fix #1680 2020-09-25 15:03:13 +03:00
gabime
32b6f1619f Added tests for issue #1680 2020-09-25 14:44:01 +03:00
Gabi Melman
99b8c5d379
Update bin_to_hex.h 2020-09-24 10:04:07 +03:00
Gabi Melman
5deb7c55e1
Fix #1676 2020-09-21 03:31:19 +03:00
gabime
9cd25dd216 Remove un needed hasher declaration 2020-09-01 23:49:54 +03:00
gabime
4a9ccf7e38 Fixed chrono wrapper 2020-09-01 12:34:59 +03:00
gabime
2963b9f07f Updated comment 2020-09-01 12:24:11 +03:00
gabime
a4a9bc4d8e version 1.8.0 2020-09-01 12:05:23 +03:00
gabime
a16a029790 Added bundled fmt os.h file 2020-09-01 12:04:36 +03:00
Gabi Melman
97fea81599
Update README.md 2020-08-31 03:51:17 +03:00
gabime
ccffb6ecd6 Fix #1581 2020-08-30 20:44:42 +03:00
gabime
63b5a1a4d8 Fix #1581 2020-08-30 20:44:04 +03:00
gabime
dfc777803a enable the 'n' flag in for backward compatibility with fmt 6.x 2020-08-30 15:58:22 +03:00
gabime
934a9bb23e Fix issue #1617 2020-08-30 15:18:33 +03:00
gabime
7097f7a894 Updated stopwatch example to README.md 2020-08-29 03:50:48 +03:00
gabime
537fd7c4ba Added stopwatch example to README.md 2020-08-29 03:49:18 +03:00
gabime
d5048b8b0c Added stopwatch example to README.md 2020-08-29 03:48:24 +03:00
gabime
0348556aac Added stopwatch example to README.md 2020-08-29 03:46:29 +03:00
gabime
d6329b9dce Added some stopwatch tests 2020-08-29 03:25:16 +03:00
gabime
34f3d29d93 Added stopwatch support 2020-08-29 02:48:43 +03:00
gabime
cd701761f9 clang-format 2020-08-26 00:10:05 +03:00
gabime
23c2c00d69 Bumb fmt version to 7.0.3 2020-08-26 00:02:09 +03:00
Gabi Melman
fa501b46cf
Merge pull request #1653 from gk6k6k/patch-1
Update README.md
2020-08-20 12:26:03 +03:00
gk6k6k
38dc0a5c5d
Update README.md
Hi,
fedora yum is obsolite log time ago...
https://www.2daygeek.com/comparison-difference-between-dnf-vs-yum/

Works for fedora 31:

[root@Galleon ~]# uname -a
Linux Galleon 5.6.13-200.fc31.x86_64 #1 SMP Thu May 14 23:26:14 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@Galleon ~]#
2020-08-20 11:01:49 +02:00
Gabi Melman
685cc4edbc
Revert last commit 2020-08-20 00:00:54 +03:00
Gabi Melman
78369375e3
Update helpers-inl.h 2020-08-19 23:57:47 +03:00
Gabi Melman
6587058f74
Update argv.h 2020-08-19 23:56:56 +03:00
Gabi Melman
30f738e49a
Merge pull request #1651 from bareya/make_load_env_levels_inline
Make load_env_levels inline function
2020-08-19 23:55:40 +03:00
Piotr Barejko
726ca01e5c Make load_env_levels inline function 2020-08-19 12:43:41 -07:00
Gabi Melman
83b40b8cda
Merge pull request #1640 from dkruempe/v1.x
tcp_client.h bugfix for macOS and add tcp example
2020-08-06 13:06:08 +03:00
Dominik Krümpelmann
db0d0438ff tcp_client.h bugfix for macOS and add tcp example
-> fix the issue that the head is not compilable bc. of missing declaration
-> optimize if/else block in connection function. Else not needed bc. of break in if
2020-08-06 11:40:17 +02:00
Gabi Melman
3c527488e7
Update spdlog-inl.h 2020-07-24 13:06:29 +03:00
Gabi Melman
99abcf6ded
Merge pull request #1628 from eyalroz/issue-1627
Fix for issue #1627: Global get_level() and should_log()
2020-07-24 00:31:51 +03:00
Eyal Rozenberg
7009727559 Fix for issue #1627:
* Added: `spdlog::get_level()` API function - like `logger::level()`, except for the name change
* Added: `spdlog::should_log()` API function - like `logger: should_log()`
2020-07-23 23:05:12 +03:00
Gabi Melman
ae02fba141
Merge pull request #1624 from tambry/cmake_range
Bump CMake requirement to 3.10, don't enable C language
2020-07-21 14:28:42 +03:00
Raul Tambre
76cdeb62e3 Don't enable C language in CMake
spdlog doesn't seem to actually require the C language.
Not enabling it results in a significant initial configure time speedup.
2020-07-21 11:39:40 +03:00
Raul Tambre
ae9627c64c Raise CMake requirement to 3.13
* Reduces the range of possible version we'd need to test with.
* Enables newer policies reducing possible deprecation warnings from new policies.
* Allows removing some code for compatibility with older versions.
* Coincides with LLVM's bump to requiring CMake 3.13.
2020-07-20 22:03:50 +03:00
Gabi Melman
58875bdcd7
Update tcp_client-windows.h 2020-07-14 23:15:49 +03:00
Gabi Melman
616caa5d30
Version 1.7.0 2020-07-09 20:24:20 +03:00
Gabi Melman
8236ee3ff6
Update version.h 2020-07-08 19:46:57 +03:00
Gabi Melman
19f2804661
Fix #1611 2020-07-08 18:50:51 +03:00
Gabi Melman
c62ba5f48d
Merge pull request #1606 from candrews/fmt-7
fmt 7.0.0 renamed the internal namespace to detail.
2020-07-06 20:41:13 +03:00
Craig Andrews
22bee8128a fmt 7.0.0 renamed the internal namespace to detail.
See: https://github.com/fmtlib/fmt/issues/1538
2020-07-06 13:01:52 -04:00
Gabi Melman
39150eb8c7
Update README.md 2020-06-18 18:43:12 +03:00
Gabi Melman
1b14fa53ef
Merge pull request #1591 from Pospelove/cmake-cleanup
Cleanup options-related lines in CMakeLists.txt
2020-06-12 15:29:57 +03:00
Leonid Pospelov
cf55e5d4f8 Cleanup options-related lines in CMakeLists.txt 2020-06-12 14:30:49 +03:00
Gabi Melman
1a1ea028f6
Merge pull request #1587 from podsvirov/increased-tolerance-waiting-time-for-mingw
Twice tolerance waiting time with MinGW
2020-06-10 23:47:19 +03:00
Gabi Melman
814c3445a3
Merge pull request #1586 from podsvirov/fix-shared-non-msvc
Fix shared library building failure on Windows with non MSVC
2020-06-10 23:46:46 +03:00
Konstantin Podsvirov
075dcee042 Twice tolerance waiting time with MinGW
Increased tolerance waiting time for MinGW in dequeue-empty-nowait test
case, because this test case not passed on slow and powerful computers.
2020-06-10 23:44:30 +03:00
Konstantin Podsvirov
fe97a03033 Fix shared library building failure on Windows with non MSVC
For example, now we can built shared library on Window with MinGW.

This changes improve features added in #1467.
2020-06-10 22:56:53 +03:00
Gabi Melman
f593aad786
Update .travis.yml 2020-06-08 18:03:55 +03:00
Gabi Melman
4a8c602a59
Update .travis.yml 2020-06-08 18:03:43 +03:00
Gabi Melman
7143dbc46a
Update appveyor.yml 2020-06-08 03:29:58 +03:00
gabime
e69699e12c enable_if 2020-06-08 00:38:30 +03:00
gabime
d6dbdbf27a Revert 7f15fb2a21cfc7895846a22e5b0f5e4e88040e88 since it breaks the ABI 2020-06-07 14:50:57 +03:00
gabime
a0dae55a69 Revert 7f15fb2a21cfc7895846a22e5b0f5e4e88040e88 since it breaks the ABI 2020-06-07 14:38:16 +03:00
Gabi Melman
7f15fb2a21
Merge pull request #1580 from TamasFlorin/custom_rotating_filename
Add support for custom filename calculator in rotating_file_sink.
2020-06-06 22:25:52 +03:00
Tamas Florin
d5aa8db36f Add missing os include for rotating_file_sink. 2020-06-06 21:08:03 +03:00
gabime
357b6c9d8c Added FMT_STRING bench 2020-06-06 14:26:50 +03:00
gabime
b0c4794305 Use default pointer type in enable_if 2020-06-06 14:25:36 +03:00
Tamas Florin
071206ef59 Add support for custom filename calculator in rotating_file_sink. 2020-06-04 13:38:21 +03:00
Gabi Melman
63ab8e6341
Merge pull request #1574 from Tridacnid/tridacnid/FMT_STRING
Add support for FMT_STRING compile time checking.
2020-06-04 11:42:01 +03:00
Joe Burzinski
741b0d6e82 Address code review comments: remove perfect forwarding on FormatString template parameters. 2020-06-03 21:47:48 -05:00
Joe Burzinski
3041faffab Address code review comments: revert perfect forwarding on places that didn't need it, remove negative compilation unit test. 2020-06-02 20:30:25 -05:00
Joe Burzinski
30ee690401 Add support for FMT_STRING compile time checking. Add negative compilation unit test for compilers and c++ standard that support relaxed constexpr. 2020-05-31 13:15:40 -05:00
gabime
22a169bc31 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2020-05-27 00:02:51 +03:00
Gabi Melman
ac19803d03
Merge pull request #1571 from IIFE/filename-deadlock
fix deadlock on filename() call. Thanks @IIFE
2020-05-27 00:01:58 +03:00
IIFEgit
95485ee89b keep filename as it's public 2020-05-26 21:59:57 +01:00
gabime
bc61f69058 Bump fmt version to 6.2.1 2020-05-26 23:47:57 +03:00
IIFEgit
0b86d6a451 fix deadlock on filename() call 2020-05-26 21:35:04 +01:00
gabime
0317731dc9 Fix #1569 2020-05-26 23:34:17 +03:00
Gabi Melman
3dedb52163
Merged again pr #1563 2020-05-20 22:50:35 +03:00
Gabi Melman
ad393b83a2
Revert 01dac453db3343cdf537d5c7db28ecc61a067061 2020-05-20 22:39:25 +03:00
Gabi Melman
01dac453db
Merge pull request #1563 from vekkuli/fix_ringbuffer_sink_last
Fixed ringbuffer_sink last_raw and last_formatted
2020-05-20 22:30:46 +03:00
Jaakko Rantala
03abdf49a0 Fixed ringbuffer_sink last_raw and last_formatted giving the first lim number of elements instead of last. 2020-05-20 19:05:24 +03:00
Gabi Melman
83b9149930
Update README.md 2020-05-14 00:13:56 +03:00
gabime
5ca5cbd447 Added missing SPDLOG_API to color_sinks.cpp 2020-05-05 02:12:39 +03:00
gabime
597e89efe3 clang-format 2020-05-05 01:42:39 +03:00
gabime
683e44f5f8 Use static fun instead of member 2020-05-05 01:33:01 +03:00
gabime
0b36d4e360 Fix #1540 2020-05-05 01:03:33 +03:00
Gabi Melman
67606e2460
Delete meson.build 2020-05-02 18:54:59 +03:00
Gabi Melman
b6c6b30c0d
Delete meson.build 2020-05-02 18:53:40 +03:00
Gabi Melman
e5935f0ced
Delete meson.build 2020-05-02 17:39:15 +03:00
gabime
75c15e8028 Formatted cmake 2020-05-02 11:42:08 +03:00
gabime
4831ae17d9 Set tabsize to 4 in when formatting cmake 2020-05-02 11:41:32 +03:00
gabime
22655d7554 Formatted cmake using cmake-format 2020-05-02 11:39:59 +03:00
gabime
ff0e430e46 Formatted cmake using cmake-format 2020-05-02 11:38:14 +03:00
gabime
e86dc8c338 Added call to cmake-format 2020-05-02 11:35:13 +03:00
gabime
0814de6371 Added call to cmake-format 2020-05-02 11:34:04 +03:00
Gabi Melman
34bc6907d0
Update .travis.yml 2020-05-02 09:16:54 +03:00
Gabi Melman
a6dd1a2b4b
Update README.md 2020-05-02 09:15:08 +03:00
Gabi Melman
4fe5d3d5e3
Merge pull request #1537 from waywardmonkeys/cmake-whitespace
cmake: Fix tabs, whitespace at EOL.
2020-05-02 08:47:19 +03:00
Bruce Mitchener
937fe7e909 cmake: Fix tabs, whitespace at EOL. 2020-05-02 07:17:15 +07:00
Gabi Melman
89ab1e679d
Merge pull request #1536 from waywardmonkeys/fix-typos
Fix typos.
2020-05-01 12:12:48 +03:00
Bruce Mitchener
559984b2fe Fix typos. 2020-05-01 08:54:16 +07:00
Gabi Melman
3ac9540351
Update test_file_helper.cpp 2020-04-29 14:50:25 +03:00
Gabi Melman
d5709c9d70
temp test appveoyr 2020-04-29 14:15:52 +03:00
Gabi Melman
891cc95add
Update appveyor.yml 2020-04-29 04:18:57 +03:00
Gabi Melman
0246b5657a
Update appveyor.yml 2020-04-29 03:54:59 +03:00
Gabi Melman
26ca1fb9f3
Update appveyor.yml 2020-04-29 03:32:52 +03:00
Gabi Melman
6b4355b76f
Delete meson_options.txt 2020-04-29 01:57:00 +03:00
Gabi Melman
90bd9692f5
Delete meson.build 2020-04-29 01:56:45 +03:00
gabime
8878185628 Add dll configuration to appveyor 2020-04-29 01:32:10 +03:00
gabime
15066d1d37 clang-format 2020-04-29 01:19:23 +03:00
gabime
abaae6e28b Add dll configuration to appveyor 2020-04-29 01:06:17 +03:00
Gabi Melman
2170de8819
Update common.h 2020-04-28 18:42:59 +03:00
Gabi Melman
300ec667f6
Update common.h 2020-04-28 18:37:57 +03:00
Gabi Melman
348c4380d6
Fix #1535 2020-04-28 18:01:48 +03:00
Gabi Melman
98388d18de
Update README.md 2020-04-26 19:55:58 +03:00
Gabi Melman
bbc5753b96
Update README.md 2020-04-26 19:53:58 +03:00
Gabi Melman
564eecaa3b
Update README.md 2020-04-26 19:50:33 +03:00
Gabi Melman
0480920058
Update README.md 2020-04-26 19:49:12 +03:00
Gabi Melman
d977dd4395
Update README.md 2020-04-26 09:40:56 +03:00
Gabi Melman
ca402379a9
Update README.md 2020-04-26 09:35:52 +03:00
Gabi Melman
903bf2135d
Update README.md 2020-04-26 09:34:03 +03:00
Gabi Melman
1f732585b2
Update README.md 2020-04-26 09:26:52 +03:00
Gabi Melman
224de0601e
Update README.md 2020-04-26 09:24:33 +03:00
Gabi Melman
9b84337830
Update README.md 2020-04-26 09:23:31 +03:00
Gabi Melman
a4665c27df
Update README.md 2020-04-26 09:20:14 +03:00
Gabi Melman
3337015346
Update README.md 2020-04-26 09:19:05 +03:00
gabime
42c466296a Fix #1527 again 2020-04-26 01:58:55 +03:00
Gabi Melman
a9fcf9db47
Revert last commit 2020-04-26 00:47:32 +03:00
Gabi Melman
f3b55fcab0
Fix #1527 2020-04-26 00:43:36 +03:00
Gabi Melman
b56b6509b1
Update README.md 2020-04-23 02:49:37 +03:00
Gabi Melman
ac85e383a9
Update README.md 2020-04-23 02:48:50 +03:00
Gabi Melman
2b326e90b8
Merge pull request #1525 from Montellese/improvement/fmt_min_version
Set minimum version of fmt to 5.0.0
2020-04-20 21:10:05 +03:00
Montellese
3e8be645d2 Set minimum version of fmt to 5.3.0
The used fmt::fmt target has been introduced with fmt 5.0.0.
2020-04-20 19:59:50 +02:00
gabime
81444265f4 clang-format 2020-04-19 11:33:36 +03:00
Gabi Melman
5716ab70ec
Merge pull request #1521 from ron003/single_log_method_with_time_point
add single logger method and log_msg constructor and tests/test_time_…
2020-04-19 09:55:07 +03:00
Ron Rechenmacher
faaef7686d pass log_time param by value 2020-04-18 22:44:13 -05:00
Ron Rechenmacher
9e6f5b6b2d add single logger method and log_msg constructor and tests/test_time_point.cpp 2020-04-18 08:58:11 -05:00
Gabi Melman
d28465bf60
Update .travis.yml 2020-04-18 14:04:46 +03:00
gabime
867fec260b Another shot at travis clang-10 2020-04-18 13:22:07 +03:00
Gabi Melman
f5309d902a
Update .travis.yml 2020-04-18 04:48:26 +03:00
gabime
82823e50dd Another shot at travis clang-10 2020-04-17 17:23:39 +03:00
gabime
394f79e9d3 small refactoring 2020-04-15 19:44:54 +03:00
gabime
595bbbd3e4 travis fix 2020-04-15 02:29:38 +03:00
gabime
2127572c33 travis fix? 2020-04-15 02:25:30 +03:00
gabime
7d6c927684 Updated travis to clang-9 2020-04-15 01:13:33 +03:00
gabime
9d2d4c82df Updated travis to clang-9 2020-04-15 01:06:28 +03:00
gabime
515ce9bebb Updated travis to clang-9 2020-04-15 01:05:09 +03:00
gabime
7698bb0ae1 Bump fmt version to 6.2.0 2020-04-15 00:51:03 +03:00
Gabi Melman
c89a5148b2
Update README.md 2020-04-14 12:48:11 +03:00
Gabi Melman
c37adba77b
Update README.md 2020-04-14 12:47:18 +03:00
Gabi Melman
95cc3dec3f
Update README.md 2020-04-14 00:42:01 +03:00
Gabi Melman
42c4a91041
Update README.md 2020-04-13 22:07:51 +03:00
Gabi Melman
d253dad2ee
Update README.md 2020-04-13 21:46:29 +03:00
Gabi Melman
7f0265e674
Update README.md 2020-04-13 21:35:39 +03:00
Gabi Melman
b9726ba66d
Update syslog_sink.h 2020-04-13 21:12:42 +03:00
Gabi Melman
b20ffa7369
Fix #1523 2020-04-13 21:09:27 +03:00
gabime
854abdf5e6 Added cmake option SPDLOG_BUILD_ALL 2020-04-12 02:43:42 +03:00
gabime
d0fc8a572c Fixed clang-tidy warnings 2020-04-12 02:30:47 +03:00
gabime
8bc1ca0e44 clang-format 2020-04-12 02:21:48 +03:00
gabime
d38bd138cd Micro optimze pattern-formatter when padding not needed 2020-04-12 02:21:14 +03:00
gabime
7766bc25d1 Updated fmt_helper::pad2() 2020-04-12 01:40:22 +03:00
Gabi Melman
34244656a6
Update test_fmt_helper.cpp 2020-04-11 21:09:48 +03:00
gabime
619849c793 fixed comment 2020-04-11 20:15:04 +03:00
gabime
927b2b3942 Fixed conversion warnings 2020-04-11 20:07:40 +03:00
gabime
76389e057f Optimize fmt_helper::pad3() 2020-04-11 19:50:19 +03:00
Gabi Melman
0a14e491ab
Update README.md 2020-04-11 11:19:17 +03:00
Gabi Melman
1f7f1c1ffb
Update CMakeLists.txt 2020-04-10 16:39:59 +03:00
gabime
6440733002 Fixed cmake 2020-04-10 15:51:34 +03:00
gabime
02802af97f Renamed SPDLOG_ENABLE_WARNINGS to SPDLOG_BUILD_WARNINGS 2020-04-10 15:38:33 +03:00
gabime
a8169a3d6b clang-format 2020-04-10 15:35:58 +03:00
gabime
9ba7fc94a5 Disable building tests by default in cmake 2020-04-10 15:35:41 +03:00
gabime
48b71a02d7 Updated latency test to run null logging be default 2020-04-10 15:29:43 +03:00
gabime
18ed04b990 Fixed clang-tidy warnings in bench.cpp 2020-04-09 16:12:52 +03:00
gabime
d09e03606c Fixed multiple clang-tidy warnings 2020-04-08 18:18:27 +03:00
gabime
b2017f5653 Fixed multiple clang-tidy warnings 2020-04-08 18:17:21 +03:00
gabime
c16eb80d7f Fixed multiple clang-tidy warnings 2020-04-08 17:04:10 +03:00
gabime
0c56f98a92 Fix .clang-tidy 2020-04-08 16:27:12 +03:00
gabime
490940cd53 Minor update to fmt_helper 2020-04-04 20:11:59 +03:00
gabime
92d27b0aa3 Minor update to fmt_helper 2020-04-04 20:11:17 +03:00
gabime
ca9c83f824 Minor improvment to number padding 2020-04-04 20:06:04 +03:00
gabime
fc900e2432 Enabled warnings in ci 2020-04-04 17:20:48 +03:00
gabime
e3257e56ab Fix #1480 2020-04-04 17:13:03 +03:00
Gabi Melman
7d2337c6eb
Fix #1504 - Extra warnings OFF by default 2020-04-03 20:37:05 +03:00
Gabi Melman
58629f1fea
Merge pull request #1503 from Glamhoth/warnings_as_option
Added an option to disable compiler warnings
2020-04-03 20:32:38 +03:00
FIlip Demski
132ec0a5fc Added an option to disable compiler warnings 2020-04-03 10:09:29 +02:00
gabime
c2b47430fb Enabled warning on examples only if built as part of spdlog 2020-04-01 00:23:04 +03:00
Gabi Melman
7906592230
Fix #1499 2020-04-01 00:10:57 +03:00
Gabi Melman
f57378d8ba
Update test_eventlog.cpp 2020-03-28 13:59:59 +03:00
Gabi Melman
1ccdc225af
Merge pull request #1495 from trondhe/v1.x
add /WX mscv compiler option for only mscv compiler
2020-03-28 13:30:43 +03:00
Trond H Emaus
3e4df86ac0 create MSVC_OPTIONS list only if compiler is msvc 2020-03-28 10:26:32 +01:00
Trond H Emaus
7054cf7a35 replace MSVC_OPTIONS variable as list 2020-03-28 00:03:59 +01:00
Trond H Emaus
2a7fc9e30e add /WX mscv compiler option for only mscv compiler
clang on windows support both gcc and mscv style options. Clang.exe on windows
defaults to gcc style, which will result in /WX unknown compiler command.
This will set /WX if and only if the compiler is MSVC and greater than version 1900
2020-03-27 19:59:22 +01:00
Gabi Melman
f1b4f15dbb
Merge pull request #1494 from zyansheep/zyansheep-patch-1
yaourt is outdated and insecure, use yay in README.md
2020-03-26 22:50:08 +02:00
Zyansheep
c98152e9d0
Use community database instead of AUR 2020-03-26 16:25:38 -04:00
Zyansheep
7c34859e0c
yaourt is outdated and insecure, use yay
Not maintained anymore: https://archlinux.fr/yaourt-en
Alternatively: spdlog is now apart of the community repo (https://www.archlinux.org/packages/community/x86_64/spdlog/)
2020-03-26 11:45:22 -04:00
Gabi Melman
dd38e096b2
Fix issue #1486 2020-03-24 02:15:14 +02:00
Gabi Melman
ea89efbed7
Merge pull request #1487 from Naios/v1.x
Fix a build issue when SPDLOG_PREVENT_CHILD_FD is defined
2020-03-23 23:18:37 +02:00
Denis Blank
61408a0f29 Fix a build issue when SPDLOG_PREVENT_CHILD_FD is defined
* Ref 033fe9f133092dd8d
2020-03-23 22:16:25 +01:00
Gabi Melman
cca004efe4
Update README.md 2020-03-22 17:19:11 +02:00
Gabi Melman
da3f3da92c
Update win_eventlog_sink.h 2020-03-22 02:30:15 +02:00
gabime
f0c35819bd Removed unneeded nullptr check 2020-03-22 02:17:48 +02:00
gabime
ff616002cf Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2020-03-22 01:09:16 +02:00
gabime
e1c79869b6 Replaced more SPDLOG_THROW with throw_spdlog_ex 2020-03-22 01:09:08 +02:00
Gabi Melman
bd43403f5a
Update fwd.h 2020-03-22 00:54:23 +02:00
gabime
d3997cc4d1 Fix #1481 2020-03-22 00:50:22 +02:00
gabime
5b0b8579b2 Fix #1485 by removing SPDLOG_NO_NAME option 2020-03-22 00:30:01 +02:00
gabime
c927de137c clang-format 2020-03-22 00:16:27 +02:00
gabime
eb23d505f8 resolve issue #1483 2020-03-22 00:09:56 +02:00
gabime
2400cf16a4 Merge branch 'issue-#1483' into v1.x 2020-03-22 00:05:02 +02:00
gabime
bbe3ace533 Fixed bench 2020-03-21 23:42:22 +02:00
Gabi Melman
3b87eb3d08 Moved throw to dedicated function throw_spdlog_ex 2020-03-21 23:25:12 +02:00
Gabi Melman
d43a17304e
Merge pull request #1484 from OlivierLDff/pch-support
Support for precompiled headers with SPDLOG_ENABLE_PCH
2020-03-21 17:51:50 +02:00
Olivier LDff
21d41b8e81 Support for precompiled header for static & dynamic spdlog compilation.
Compilation is shorten by 2 on windows with msvc. Some improvement for gcc and appleclang. Add SPDLOG_ENABLE_PCH option to CMake that is defaulted to ON. This will enable precompiled header by default if supported. It can be disable if user have a conflict of any kind. Or to check that project is still compiling with CMake version that do not support precompiled header.
2020-03-21 15:36:14 +01:00
gabime
332eaaf916 Update readme with custom flags example 2020-03-21 15:54:01 +02:00
gabime
0a5ada6411 clang-format 2020-03-21 15:25:26 +02:00
gabime
963f8d3485 Fixed tests 2020-03-21 15:25:05 +02:00
Gabi Melman
60a8c5f1c9 Added padding support and set_pattern to custom_flags 2020-03-21 15:03:41 +02:00
Gabi Melman
d1a1024465 Moved pattern formatter from spdlog/details to spdlog/ 2020-03-21 13:35:16 +02:00
Gabi Melman
0d7ff9ac47 Moved pattern formatter from spdlog/details to spdlog/ 2020-03-21 13:35:04 +02:00
Gabi Melman
752d5685dc Moved pattern formatter from spdlog/details to spdlog/ 2020-03-21 13:33:04 +02:00
Gabi Melman
c6c517431f wip custom formatter flags 2020-03-20 16:09:30 +02:00
Gabi Melman
ee54f54ced Use /W3 for mvsc 2020-03-20 13:56:54 +02:00
Gabi Melman
2c5c96e159
Merge pull request #1475 from Crunkle/v1.x
Fix Windows setenv check
2020-03-18 16:17:04 +02:00
Crunkle
a10763138e Fix Windows setenv check 2020-03-18 09:46:32 +00:00
Gabi Melman
208eb0ca07
Merge pull request #1473 from avrahamshukron/patch-1
README: add conda as a supported package manager
2020-03-15 22:07:39 +02:00
Avraham Shukron
f0403fa9e4
README: add conda as a supported package manager
spdlog is available on conda-forge for a long time.
https://anaconda.org/conda-forge/spdlog
2020-03-15 21:59:34 +02:00
gabime
3f86b250e6 Updated comment 2020-03-15 18:56:38 +02:00
gabime
d1819f5f76 clang-format 2020-03-15 18:51:52 +02:00
gabime
19c7e63858 Added final keywords to pattern_formatter classes 2020-03-15 18:46:10 +02:00
gabime
7efdcc26fe CMakeLists.txt: use same policy as fmt 2020-03-15 18:41:34 +02:00
gabime
3ab3970dd2 CMakeLists.txt: use same policy as fmt 2020-03-15 18:40:42 +02:00
gabime
5ab487dbae Updated example 2020-03-15 17:38:15 +02:00
gabime
55fbc2c78e Merge branch 'ngugcx-hexdump' into v1.x 2020-03-15 17:32:11 +02:00
gabime
643426e2b2 Small refactor 2020-03-15 17:20:02 +02:00
gabime
f31a834613 clang-format 2020-03-15 17:16:28 +02:00
gabime
683080be53 Fix clang-tidy warning 2020-03-15 17:14:52 +02:00
gabime
d14b8a9ad6 Merge branch 'hexdump' of https://github.com/ngugcx/spdlog into ngugcx-hexdump 2020-03-15 16:27:58 +02:00
ngugcx
0f87ba6c93 fix a test case error. 2020-03-15 20:21:58 +08:00
ngugcx
02bfa0898c Do not fill blanks to align if there is only one line. 2020-03-15 20:09:28 +08:00
ngugcx
f5313f92f1 Enhance to_hex like the unix command hexdump. 2020-03-15 12:01:31 +08:00
Gabi Melman
e41a258b93
Update tcp_sink.h 2020-03-13 01:38:10 +02:00
Gabi Melman
ffa85cda1a
Update tcp_sink.h 2020-03-13 01:36:33 +02:00
Gabi Melman
0123d41647
Update tcp_sink.h 2020-03-13 01:36:03 +02:00
Gabi Melman
2b0481deed
Always use SOCK_CLOEXEC in tcp client 2020-03-13 01:18:27 +02:00
Gabi Melman
1389f86675
Update tcp_client.h 2020-03-13 01:17:12 +02:00
Gabi Melman
cf6bb88af2
Update tcp_client-windows.h 2020-03-13 01:12:05 +02:00
Gabi Melman
8e19a267bd Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2020-03-13 01:01:28 +02:00
Gabi Melman
3b55709e7f tcp_sink windows impl 2020-03-13 01:01:19 +02:00
gabime
f78bca4ad8 Removed junk files 2020-03-12 16:09:34 +02:00
Gabi Melman
713feca582
Update CMakeLists.txt 2020-03-12 14:46:49 +02:00
Gabi Melman
26c20ed91d
Update CMakeLists.txt 2020-03-12 14:46:01 +02:00
Gabi Melman
e399249f31
Update CMakeLists.txt 2020-03-12 14:45:01 +02:00
Gabi Melman
b4a1b4b59a Updated verion.rc and CMakeLists.txt for dll build 2020-03-12 14:35:30 +02:00
Gabi Melman
b309a88bea Update utils.cmake 2020-03-12 14:29:39 +02:00
Gabi Melman
e88bee49a6 Added version info to dll build 2020-03-12 14:29:23 +02:00
Gabi Melman
ec12770693
Merge pull request #1467 from vejmartin/v1.x
Add shared library support for Windows
2020-03-11 13:31:39 +02:00
Martin Vejdarski
5b3a18319e fix SPDLOG_BUILD_SHARED cmake option 2020-03-11 03:05:44 +07:00
Martin Vejdarski
3b73278348 fix shared lib issues with bundled fmt 2020-03-11 00:39:42 +07:00
Martin Vejdarski
0ca2cb625e Add shared library support for Windows 2020-03-10 03:14:36 +07:00
Gabi Melman
67561f97ec
Update argv.h 2020-03-06 16:27:08 +02:00
Gabi Melman
b667bae65d
Update argv.h 2020-03-06 16:26:11 +02:00
gabime
54be9bd8b9 Use brackets to include spdlog in srcs 2020-03-06 15:51:07 +02:00
Gabi Melman
06d0299639
version 1.6.0 rc 2020-03-06 15:37:50 +02:00
Gabi Melman
84851e230f
Update README.md 2020-03-06 15:33:24 +02:00
Gabi Melman
52aed9e0de
Update README.md 2020-03-06 15:32:51 +02:00
Gabi Melman
ead9a550fd
Update README.md 2020-03-06 15:32:23 +02:00
Gabi Melman
cf80b492a3
Update README.md 2020-03-06 15:31:38 +02:00
gabime
69f3d2678e Updated readme. 2020-03-06 15:30:14 +02:00
gabime
8038bc2fc8 Update example 2020-03-06 15:21:21 +02:00
gabime
f20b12cf3f Update example 2020-03-06 15:16:48 +02:00
gabime
c8bd53509c Update example 2020-03-06 15:15:59 +02:00
gabime
006124d816 Update example 2020-03-06 15:15:10 +02:00
gabime
efd73ac956 Merge remote-tracking branch 'origin/v1.x' into conf-env3 2020-03-06 15:10:24 +02:00
gabime
b7d7334451 Renamed level loaders 2020-03-06 15:09:46 +02:00
gabime
8284865f9a Fix tidy warning 2020-03-04 16:21:07 +02:00
gabime
1f8b04cbd1 Fix tidy warning 2020-03-04 16:09:04 +02:00
gabime
b3402a0b9f Fix tidy warning 2020-03-04 16:08:35 +02:00
gabime
4037959945 Fix tidy warning 2020-03-04 15:59:45 +02:00
gabime
d7313a3274 Fix tidy warning 2020-03-04 15:52:42 +02:00
gabime
8302086942 Fixed tcp_client 2020-03-04 15:40:04 +02:00
Gabi Melman
6095db951b
Update README.md 2020-03-04 14:12:56 +02:00
gabime
817d2764b6 Fix bench tidy warning 2020-03-03 23:53:28 +02:00
Gabi Melman
62189602cb
Update README.md 2020-03-03 09:51:56 +02:00
Gabi Melman
0120dcc787
Update logger-inl.h 2020-02-29 13:20:26 +02:00
Gabi Melman
6bfc0ec3a7
Merge pull request #1457 from Ruffel/fix-clang-tidy-warning
Resolve erroneous clang-tidy warning about using a moved from pointer
2020-02-29 13:16:49 +02:00
Steven Cartmell
f999d879d5
fix: Break from loop on last iteration to resolve clang-tidy warning
The clang-tidy warning `clang-analyzer-cplusplus.Move` warns when a
moved from object is deferenced. This is triggered in spdlog because
clang-tidy fails to detect that the `logger:set_formatter` will only
move the unique_ptr on the last iteration of the loop, assuming that
`f->clone` may be called on it afterwards.

To fix, add a break statement after moving the pointer (on the last
iteration) to let clang-tidy know the logger pointer is not used after
this point.
2020-02-28 21:09:31 +00:00
gabime
c861e2d9cf Updated example 2020-02-26 19:21:36 +02:00
gabime
e696978d11 Renamed function name 2020-02-26 18:47:51 +02:00
gabime
fbf2e942a9 Allow "err" when converting string to level 2020-02-26 18:33:49 +02:00
gabime
d18f282938 Fixed missing cfg.cpp 2020-02-26 18:21:24 +02:00
gabime
c10be7eaec merge with v1.x 2020-02-26 18:13:13 +02:00
gabime
05ecad4263 Use windows_include in os-inl.h 2020-02-26 18:10:47 +02:00
Gabi Melman
4cdb159ccb
Update spdlog.h 2020-02-26 12:54:31 +02:00
Gabi Melman
fccb25586f
Update spdlog.h 2020-02-26 12:52:46 +02:00
Gabi Melman
ab2f3307eb
Update spdlog.h 2020-02-26 12:51:16 +02:00
Gabi Melman
db26a103d6
Update spdlog.h 2020-02-26 12:50:51 +02:00
Gabi Melman
32902f79ad
Merge pull request #1453 from david-bodor-at-craftunique/v1.x
only include windows.h when it's unavoidable
2020-02-26 12:41:51 +02:00
Dávid Bodor
fab33dd230 refactor: extract windows.h include to details/windows_include.h 2020-02-26 08:54:56 +01:00
gabime
daaa025356 moved .clang-format to top level 2020-02-25 18:52:35 +02:00
gabime
ffe272c165 Added SDPLOG_TIDY option to CMakeLists.txt instead of clang_tidy.sh 2020-02-25 18:49:28 +02:00
Dávid Bodor
6e763d2776 only include windows.h when it's unavoidable 2020-02-25 15:36:39 +01:00
gabime
c71b433a35 clang-format 2020-02-25 15:10:44 +02:00
gabime
0b91d55269 Refactored tcp_client_sink 2020-02-25 15:09:03 +02:00
gabime
9f41903067 Refactored tcp_client_sink 2020-02-25 15:00:42 +02:00
gabime
64de8807e2 Fix #1452 2020-02-24 17:01:09 +02:00
gabime
3848cbe24a Fix #1452 2020-02-24 17:00:35 +02:00
Gabi Melman
15ac7b08f7
Merge pull request #1451 from tcraigtyler/more-rpm-cpack
Updates supporting CPack RPM generation
2020-02-21 02:53:07 +02:00
Craig Tyler
e47ecc1828 Updates supporting CPack RPM generation
Enable command line overrides of default settings
* CPACK_GENERATOR
* CPACK_PACKAGE_RELOCATABLE

Enables command line setting of generated RPM version attributes
* CPACK_RPM_PACKAGE_RELEASE
* CPACK_RPM_PACKAGE_ARCHITECTURE

Adds dependency on pkgconfig RPM when not generating relocatable RPM
2020-02-20 14:52:56 -08:00
Gabi Melman
c09641cf47
Merge pull request #1450 from rabbull/fmt_string
Add example to FMT_STRING in README
2020-02-20 20:27:03 +02:00
Karl Liu
92467db591 add example to FMT_STRING 2020-02-21 02:06:06 +08:00
Gabi Melman
ea5e7182ab
Merge pull request #1444 from Crunkle/v1.x
Fix Windows event log sink
2020-02-17 21:37:27 +02:00
Crunkle
d38d53d9dd Fix Win32 event log sink 2020-02-17 17:15:43 +00:00
Gabi Melman
c9e094d9fc
Merge pull request #1442 from niamster/v1.x
workaround for `Unknown extension ".c" for file` issue
2020-02-16 22:41:52 +02:00
Dmytro Milinevskyi
af75985ec6 workaround for Unknown extension ".c" for file issue
http://www.grokit.ca/cnt/CMakeProblemsSolutions/
2020-02-16 19:57:49 +01:00
gabime
4b7c05903b optimize wincolor_sink to use array instead of map to find color codes 2020-02-15 12:11:01 +02:00
gabime
695912c7cf Optimize ansicolor_sink to use array instead of map to find color codes 2020-02-15 12:06:01 +02:00
gabime
5c06306ccc Updated clang-tidy 2020-02-15 12:05:07 +02:00
gabime
d4fd17f64f Fixed #1439 2020-02-15 11:29:04 +02:00
Gabi Melman
76d94e69ae
Fix #1439 2020-02-15 10:57:12 +02:00
Gabi Melman
0f42744f5c
Update rotating_file_sink-inl.h 2020-02-12 12:11:03 +02:00
Gabi Melman
e8daf7c73b
Merge pull request #1431 from tt4g/avoid-references-to-race-data-filename
Avoid references to race data filename
2020-02-12 12:09:25 +02:00
tt4g
0cf1af5bbf Avoid references to race data filename 2020-02-12 16:30:44 +09:00
Gabi Melman
a343328a21
Update rotating_file_sink-inl.h 2020-02-12 08:56:24 +02:00
Gabi Melman
53a56b82af
Update rotating_file_sink-inl.h 2020-02-12 07:51:42 +02:00
Gabi Melman
64dd4dc219
Update rotating_file_sink-inl.h 2020-02-12 07:49:29 +02:00
Gabi Melman
9e9da42c64
Update rotating_file_sink.h 2020-02-12 07:48:41 +02:00
Gabi Melman
5c410f4ca2
Merge pull request #1430 from tt4g/add-critical-section-to-filename-api
Add critical section to filename function of  each file sink
2020-02-12 07:35:52 +02:00
tt4g
0778211116 Add critical section to filename function of each file sink 2020-02-12 11:01:35 +09:00
Gabi Melman
574563d711
Update tcp_sink.h 2020-02-10 23:00:08 +02:00
Gabi Melman
e9d0b424d5
Merge pull request #1427 from dominicpoeschko/patch-1
Handling SPDLOG_PREVENT_CHILD_FD in tcp_sink
2020-02-10 19:04:32 +02:00
dominicpoeschko
eef981e05f
Handling SPDLOG_PREVENT_CHILD_FD in tcp_sink
Adding SOCK_CLOEXEC to socket

Fixing bug in sink_it_ (bytes_sent not added to buffer)
2020-02-10 17:52:54 +01:00
gabime
9f24f4bc69 revert last commit 2020-02-10 17:38:31 +02:00
gabime
5da9818676 updated member name in win eventlog sink 2020-02-10 17:25:39 +02:00
gabime
ff59b07986 Update tcp_sink.h 2020-02-10 17:21:32 +02:00
gabime
1b6d4fd277 Update tcp_sink.h 2020-02-10 17:19:22 +02:00
gabime
7b19890deb Update tcp_sink.h 2020-02-10 17:18:18 +02:00
gabime
5370443ece clang-format 2020-02-10 17:13:41 +02:00
gabime
ad4fb1cf84 Fixed tcp sink 2020-02-10 17:13:04 +02:00
gabime
7f8169f0da Fixed tcp_sink to accept hostnames 2020-02-10 15:02:48 +02:00
gabime
66e8652862 Fix tcp_sink 2020-02-10 14:34:00 +02:00
gabime
05cbdbc1ef moved tcp sink to sinks 2020-02-10 14:21:26 +02:00
Gabi Melman
38584a1fca
Merge pull request #1426 from Proheeler/v1.x
tcp_sink implementation for fluentbit
2020-02-10 14:19:21 +02:00
Vyacheslav
d96d8c49ac
Code Style naming 2020-02-10 15:13:39 +03:00
Vyacheslav
4bb623a0a3
removed unneccessary namespace std 2020-02-10 15:08:51 +03:00
Vyacheslav
3aa94a0997
Added send function verification + licence 2020-02-10 14:58:54 +03:00
Vyacheslav
ccad4ae04f
Resolve modification requests 2020-02-10 14:46:39 +03:00
v.reshetnikov
346b9ae5a1 tcp_sink implementation for fluentbit 2020-02-10 14:24:17 +03:00
Gabi Melman
12f36debae Merge pull request #1414 from BioDataAnalysis/bda_tests_support_empty_eol
Make tests support empty SPDLOG_EOL
2020-02-10 13:12:07 +02:00
Mario Emmenlauer
87acec6a91 Make tests support empty SPDLOG_EOL with new helper method require_message_count() 2020-02-10 11:26:48 +01:00
Mario Emmenlauer
58a5e654f9 tests/utils.cpp: Use binary mode for reading test results, to preserve EOL 2020-02-10 11:26:48 +01:00
Gabi Melman
e278953191 Update win_eventlog_sink.h 2020-02-10 02:23:25 +02:00
Gabi Melman
573ddf8aec
Merge pull request #1424 from dominicpoeschko/patch-2
adding additional log overload to prevent unnecessary fmt::format
2020-02-10 01:31:08 +02:00
gabime
4f32243214 Update comment 2020-02-10 00:54:43 +02:00
gabime
601bdfb1b4 Minor cleanup 2020-02-10 00:53:01 +02:00
gabime
90454a93b2 Update test_eventlog.cpp 2020-02-10 00:37:48 +02:00
gabime
640921cd3f Optimize win_eventlog to avoid string allocation 2020-02-10 00:37:45 +02:00
Gabi Melman
fccee959b1
Merge pull request #1418 from ban-dana/v1.x
Add eventlog_sink for logging to Windows Event Log (local only)
2020-02-09 23:27:00 +02:00
bandana2004
67a8ecf2bf Remove registration and stderr reporting from win_eventlog_sink 2020-02-09 22:59:02 +02:00
bandana2004
d8701890b2 cleanup win_eventlog_sink 2020-02-09 18:12:54 +02:00
bandana2004
2435f46d06 fix registry key handle leak in win_eventlog_sink::add_registry_info 2020-02-09 18:04:38 +02:00
bandana2004
4bece787c8 Refactor Event Log sink 2020-02-09 15:12:30 +02:00
Gabi Melman
d4ce938679
Merge pull request #1423 from dominicpoeschko/patch-1
Properly handling SPDLOG_PREVENT_CHILD_FD
2020-02-08 14:05:38 +02:00
dominic
033fe9f133 Properly handling SPDLOG_PREVENT_CHILD_FD
Removed check for posix version so that missing O_CLOEXEC leads to
compiler error.

Removed extra function since it hat no real purpose anymore.

Error behavior between Windows and Unix now equivalent.
2020-02-08 12:15:05 +01:00
dominicpoeschko
25b10dc264 additional log overload
calling log with a string_view as msg called
```
 template<typename... Args>
    void log(source_loc loc, level::level_enum lvl, string_view_t fmt, const Args &... args)
```

instead of
```
template<class T, typename std::enable_if<std::is_convertible<const T &, spdlog::string_view_t>::value, T>::type * = nullptr>
    void log(source_loc loc, level::level_enum lvl, const T &msg)
```

which lead to an unnecessary call to fmt::format
2020-02-08 11:11:04 +01:00
dominicpoeschko
a9c3630d1b
Properly handling SPDLOG_PREVENT_CHILD_FD
Using the SPDLOG_PREVENT_CHILD_FD option there where still a race when
a other thread was using fork and exec in between the call to fopen and fcntl.

Using open and O_CLOEXEC when possible prevents this race.

I have no idea if this problem  exists on Windows.
2020-02-07 17:59:11 +01:00
Gabi Melman
f3d99f41d4
Merge pull request #1422 from mr-c/post_installation_testing
Enable running the tests against an installed copy of spdlog
2020-02-07 18:23:50 +02:00
Gabi Melman
fdb46b857f
Merge pull request #1407 from vitlav/fix-GNUInstallDirs-using
CMakeLists.txt: put GNUInstallDirs after set project language
2020-02-07 18:22:03 +02:00
Michael R. Crusoe
8d06df9775
Enable building & running the example against an installed copy of spdlog 2020-02-07 16:09:20 +01:00
Michael R. Crusoe
a8d6e60ec6
Enable running the tests against an installed copy of spdlog 2020-02-07 15:39:26 +01:00
Gabi Melman
4e643fa42c
Merge pull request #1421 from tt4g/ctest-run-serial
Don't run spdlog-utests and spdlog-utests-ho in parallel
2020-02-07 15:49:25 +02:00
tt4g
eb234bbf91 Don't run spdlog-utests and spdlog-utests-ho in parallel
spdlog-utests and spdlog-utests-ho use the same log output directory, so some tests will randomly fail when run in parallel.
2020-02-07 22:20:54 +09:00
bandana2004
db1a221427 Add eventlog_sink for logging to Windows Event Log (local only). 2020-02-07 15:04:47 +02:00
Gabi Melman
5378f35239
Merge pull request #1417 from BioDataAnalysis/bda_fix_trivial_issue_in_test_utils
tests/utils.h: removed duplicate entry for count_lines()
2020-02-07 12:49:13 +02:00
Mario Emmenlauer
622f5eb967 tests/utils.h: removed duplicate entry for count_lines() 2020-02-07 10:22:58 +01:00
Gabi Melman
966d827d35
Update LICENSE 2020-02-03 22:32:17 +02:00
Gabi Melman
bed56d3e52
Update LICENSE 2020-02-03 21:12:12 +02:00
Gabi Melman
24173d5ebc
Update LICENSE 2020-02-03 21:11:45 +02:00
Gabi Melman
60853b5e54
Update LICENSE 2020-02-02 14:20:44 +02:00
Gabi Melman
da2ff552c5
Update LICENSE 2020-02-02 14:20:24 +02:00
Gabi Melman
742df52236
Update license to add note about fmt lib dependecy 2020-02-02 14:16:57 +02:00
Vitaly Lipatov
1b4621962f CMakeLists.txt: put GNUInstallDirs after set project language 2020-01-30 14:51:42 +03:00
Gabi Melman
0a36828ff3
Merge pull request #1394 from ruoshui1314/v1.x
add max files for rotating days
2020-01-19 12:34:57 +02:00
weiy
85ea4297b9 update method name 2020-01-19 17:29:17 +08:00
weiy
34cc3419fa add max files for rotating days 2020-01-19 13:52:01 +08:00
weiy
46fcd2e844 add max files for rotating days 2020-01-19 13:46:43 +08:00
Gabi Melman
23f0cdf901
Merge pull request #1389 from XNephila/support-on-MacPorts
latest spdlog now available on MacPorts
2020-01-14 01:06:42 +02:00
X Nephila
26bdf66659
latest spdlog now available on MacPorts
I am the maintainer of spdlog on MacPorts, now the latest version(1.4.2) of spdlog is available on MacPorts.
2020-01-14 07:04:27 +08:00
Gabi Melman
cf6f1dd01e
Merge pull request #1387 from gocarlos/patch-1
docs: spdlog now available in conan center, bincrafters repo is deprecated
2020-01-13 10:06:56 +02:00
Carlos Gomes Martinho
286eb59081
docs: spdlog now available in conan center 2020-01-13 08:40:01 +01:00
Gabi Melman
40bb28e9b6
Merge pull request #1378 from ldanko/v1.x
meson: add fallback to fmt dependency
2020-01-02 04:10:50 +02:00
Łukasz Dańko
aac085a9be meson: add fallback to fmt dependency
Now `fmt` library can be used as subproject which helps with cross
compilation.
2020-01-01 23:59:32 +01:00
Gabi Melman
58e68901c7
Merge pull request #1370 from segfault-magnet/bugfix/invalid_meson_option
Fix invalid meson option
2019-12-23 17:44:31 +02:00
Ahmed Sagdati
8e69c6e492 Fix invalid meson option 2019-12-23 15:57:16 +01:00
gabime
4d98a14cb1 Updated fmt.cpp to 6.1.2 2019-12-22 22:54:31 +02:00
gabime
5bf99dfd61 Renamed loaders.cpp to cfg.cpp 2019-12-22 22:51:52 +02:00
gabime
bc42415ceb Updated fmt.cpp to 6.1.2 2019-12-22 22:51:12 +02:00
gabime
284e6a80ac Fixed cfg tests 2019-12-22 22:33:19 +02:00
gabime
0243882238 Updated example 2019-12-22 20:58:16 +02:00
gabime
877eee408e renamed loaders with cfg 2019-12-22 20:40:19 +02:00
gabime
8dd54de326 Merge remote-tracking branch 'origin/v1.x' into conf-env3 2019-12-22 20:29:31 +02:00
Gabi Melman
09d729bfba
Update README.md 2019-12-22 19:46:56 +02:00
Gabi Melman
9caaca742e
Update README.md 2019-12-22 19:42:08 +02:00
Gabi Melman
ac95c3ffbf
Update README.md 2019-12-22 19:40:50 +02:00
Gabi Melman
9715d80030
Update README.md 2019-12-22 19:39:52 +02:00
Gabi Melman
a0a1e5c078
Update README.md 2019-12-22 19:37:42 +02:00
Gabi Melman
d7ba1fdd3d
Update README.md 2019-12-22 19:36:58 +02:00
Gabi Melman
2544fca519
Update test_loaders.cpp 2019-12-22 08:58:36 +02:00
Gabi Melman
0b55e2c332
Update test_loaders.cpp 2019-12-22 00:17:32 +02:00
gabime
b105046202 Fixed loaders tests 2019-12-21 20:15:18 +02:00
gabime
de20255c71 wip 2019-12-21 20:01:25 +02:00
gabime
1a1c37db7c wip 2019-12-21 19:59:23 +02:00
gabime
a87700a28c wip 2019-12-21 19:52:37 +02:00
gabime
1f8e9ad0fc renamed cfg namespace to loaders 2019-12-21 19:45:14 +02:00
gabime
e13e978af4 added loaders tests 2019-12-21 19:25:54 +02:00
gabime
28e334c728 Fixed tests 2019-12-21 18:52:35 +02:00
gabime
15a9427112 wip 2019-12-21 18:08:42 +02:00
gabime
010b0e1d75 wip 2019-12-21 17:58:31 +02:00
gabime
cd5ddca00d wip 2019-12-21 17:55:30 +02:00
gabime
f18e1fccfd cfg.cpp 2019-12-21 17:49:34 +02:00
gabime
773b8c5a54 refectored file names 2019-12-21 17:47:02 +02:00
gabime
fc3d18ed64 format 2019-12-21 15:54:42 +02:00
gabime
68ed281461 Refactored to cfg::log_levels class 2019-12-21 15:54:09 +02:00
gabime
65ada37399 refactor and and support for init from argv 2019-12-21 13:29:03 +02:00
gabime
9f539d7028 Merge branch 'v1.x' into conf-env2 2019-12-21 11:58:13 +02:00
Gabi Melman
c73a5ff918
Merge pull request #1367 from mike239x/v1.x
Fix a small problem in the basic example
2019-12-20 12:42:57 +02:00
Mike Lezhnin
9858d4e918 Fix a small problem in the basic example
The line
```
SPDLOG_TRACE("Some trace message with param {}", {});
```
which normally is discarded at the compile time since by deafult
`SPDLOG_ACTIVE_LEVEL` is at `SPDLOG_LEVEL_INFO`. If however, one goes
to `tweak.me` and sets
```
 #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE
```
suddenly the basic example does not compile any more.
This commit fixes the potential problem.
2019-12-20 11:05:38 +01:00
gabime
0dfb1d264e removed include 2019-12-13 18:32:37 +02:00
gabime
a056b9115b clang-format 2019-12-13 18:26:36 +02:00
gabime
62ecc04212 Merge branch 'v1.x' into conf-env2 2019-12-13 18:25:24 +02:00
gabime
4a0f4fc186 keep clang-tidy happy 2019-12-13 17:55:39 +02:00
gabime
3a61dcd360 Aceept also 'warn' string in level::from_str() 2019-12-13 16:22:20 +02:00
gabime
04d0240f8d updated example 2019-12-13 16:17:09 +02:00
gabime
13ebfc0779 rename function 2019-12-13 16:00:55 +02:00
gabime
d70d5aa9d8 Merge branch 'conf-env2' of https://github.com/gabime/spdlog into conf-env2 2019-12-13 15:54:46 +02:00
gabime
70d3c2cd3e so::getenv - Always empty string under windows uwp since it's not supported 2019-12-13 15:50:27 +02:00
gabime
6fbe0dec2c Throw if trying to getenv under windows uwp 2019-12-13 15:35:37 +02:00
gabime
9d3591dcd5 refactor 2019-12-13 15:22:21 +02:00
gabime
8992f36fbf refactor env-inl 2019-12-13 15:14:42 +02:00
gabime
3d203aa7c4 Simplify and removed SPDLOG_PATTERN support 2019-12-13 14:49:41 +02:00
gabime
cd8d7e6de9 wip 2019-12-13 12:44:11 +02:00
gabime
5d4e6f17ee wip 2019-12-13 01:35:50 +02:00
gabime
49f707ec93 wip 2019-12-13 01:24:34 +02:00
gabime
6a305df46d wip 2019-12-13 01:17:29 +02:00
gabime
35e9482574 wip 2019-12-13 01:14:38 +02:00
gabime
dac61d4e9c merge 2019-12-13 00:14:33 +02:00
gabime
d52e825bbc clang-format 2019-12-13 00:12:05 +02:00
gabime
4fa463dff6 Merge branch 'v1.x' into conf-env2 2019-12-13 00:09:36 +02:00
gabime
ebaa16f403 CMakeLists.txt allow overriding the cpp standard to higher than 11 2019-12-12 23:52:22 +02:00
gabime
175741ed1d Bump fmt to 6.1.2 2019-12-12 23:50:30 +02:00
gabime
8d9d9899b7 wip 2019-12-12 20:00:18 +02:00
gabime
cff7448fb2 Merge branch 'v1.x' into conf-env2 2019-12-11 01:28:24 +02:00
gabime
0f8f510ebb removed junk file 2019-12-11 01:27:27 +02:00
gabime
3812c22f86 Merge remote-tracking branch 'origin/v1.x' into conf-env2 2019-12-11 01:25:19 +02:00
gabime
2b3000dddc wip 2019-12-11 01:24:51 +02:00
gabime
b278baf94e wip 2019-12-11 00:42:00 +02:00
gabime
4119b72d50 clang-format 2019-12-11 00:13:53 +02:00
gabime
da2c15ecb4 wip config from env 2019-12-11 00:13:27 +02:00
gabime
25a702fc22 Update fmt.h 2019-12-10 03:03:08 +02:00
gabime
ab178057db Fixed (maybe) #1348 2019-12-10 03:00:06 +02:00
gabime
c44cf5a720 Removed extra space 2019-12-10 02:42:28 +02:00
gabime
98ca01bf2d Fix issue #1347 2019-12-10 02:40:06 +02:00
gabime
d0ed873ab6 wip 2019-12-08 17:09:17 +02:00
gabime
0f24399887 wip 2019-12-08 17:08:20 +02:00
gabime
abbbda6f74 wip 2019-12-08 17:07:52 +02:00
gabime
1a5ee7ab83 Merge remote-tracking branch 'origin/v1.x' into conf-env2 2019-12-08 14:17:59 +02:00
gabime
3a258ee5c9 Fix CMakeList for older versions of CMake 2019-12-08 14:14:57 +02:00
gabime
4d41fdf0fc Wip 2019-12-08 13:35:15 +02:00
Gabi Melman
1586c4b0c7
Update appveyor.yml 2019-12-05 23:19:31 +02:00
Gabi Melman
9198e97401
Update appveyor.yml 2019-12-05 23:03:01 +02:00
Gabi Melman
346267c82f
Update appveyor.yml 2019-12-05 22:53:06 +02:00
Gabi Melman
529f72325f
Update appveyor.yml 2019-12-05 22:34:36 +02:00
Gabi Melman
1cf1209586
Update appveyor.yml 2019-12-05 21:24:31 +02:00
Gabi Melman
36774529a4
Update appveyor.yml 2019-12-05 20:52:57 +02:00
Gabi Melman
27dcb1008c
Update appveyor.yml 2019-12-05 20:21:04 +02:00
Gabi Melman
e8a9c7b13e
Update appveyor.yml 2019-12-05 20:20:10 +02:00
Gabi Melman
7be59851d5
Update appveyor.yml 2019-12-05 20:13:02 +02:00
Gabi Melman
15cf9ec365
Update appveyor.yml 2019-12-05 18:59:43 +02:00
Gabi Melman
c44c904161
Update appveyor.yml 2019-12-05 18:51:26 +02:00
Gabi Melman
9e3d8d1650
Update appveyor.yml 2019-12-05 18:37:19 +02:00
Gabi Melman
7b9668fe01
Update appveyor.yml 2019-12-05 18:07:43 +02:00
gabime
2334c48e02 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-12-05 17:44:48 +02:00
gabime
afb949a417 CMake: - Allow non fatal security wanrnings for msvc 2015 and below 2019-12-05 17:44:38 +02:00
gabime
c9bb85c91d Revert supress of warning 4996 under msvc 2015 2019-12-05 17:25:12 +02:00
Gabi Melman
13e1667d61
Update appveyor.yml 2019-12-05 16:24:13 +02:00
Gabi Melman
3c106c9cec
Update appveyor.yml 2019-12-05 16:23:11 +02:00
Gabi Melman
1988668d10
Update appveyor.yml 2019-12-05 14:17:10 +02:00
Gabi Melman
484d7f91e5
Added vs2017 to appveyor.yml 2019-12-05 13:42:28 +02:00
gabime
53d58f222f fix warning C4996 under vs2015 about std::copy in fmt 2019-12-05 13:37:31 +02:00
gabime
d5a72b1eaf Fixed msvc compilation 2019-12-05 02:02:16 +02:00
gabime
6b5ebab6ae Fixed msvc compilation 2019-12-05 02:01:02 +02:00
gabime
8107df08a8 Bump bundled fmt to 6.1.1-rc 2019-12-05 01:29:32 +02:00
gabime
dc29500931 version 1.5.0-rc 2019-12-05 01:21:58 +02:00
gabime
31fc1aca53 Supress -Wimplicit-fallthrough and -Wsign-conversion when including fmt headers 2019-12-05 01:12:55 +02:00
gabime
0db4b04ad3 Bump bundled fmt to version 6.1.0 2019-12-04 23:39:17 +02:00
gabime
1aa9ea92e2 Fix #1340 2019-12-03 00:35:28 +02:00
gabime
2698f54a9c Fix #1325. Added SPDLOG_FMT_EXTERNAL_HO option 2019-12-01 02:19:34 +02:00
gabime
6f977248bf Impl #1298 2019-12-01 01:28:28 +02:00
Gabi Melman
046fd62dc4
Merge pull request #1337 from luigino/meson
Set version for shared library
2019-11-29 14:41:21 +02:00
Luigi Baldoni
da60dda2dd Set version for shared library 2019-11-29 13:32:41 +01:00
gabime
d25fb08a75 clang-format 2019-11-29 12:50:54 +02:00
gabime
79e105243c Fix #1335 2019-11-29 12:48:21 +02:00
gabime
2d4e531ac9 Fix #1327 2019-11-29 12:36:06 +02:00
gabime
52403ad9ed Fix #1332 2019-11-29 11:32:46 +02:00
Gabi Melman
2d264855cc
Merge pull request #1331 from 0x8000-0000/fix-warnings
Fix compiler warnings
2019-11-28 02:34:17 +02:00
Florin Iucha
c172c72be9 Fix compiler warnings 2019-11-27 19:17:27 -05:00
Gabi Melman
79259fdb3f
Update os-inl.h 2019-11-16 13:23:00 +02:00
gabime
cee35f7d24 Added truncate flag (issue #1297) 2019-11-14 12:28:23 +02:00
Gabi Melman
1f5f17622e
Merge pull request #1311 from inhzus/v1.x
Remove redundant semicolon
2019-11-11 13:13:50 +02:00
Zhi Sun
e8f7f80f2b Remove redundant semicolon 2019-11-11 18:41:58 +08:00
gabime
6db8beeade Removed un needed file 2019-11-10 00:55:50 +02:00
gabime
4f66313440 Fix #1308 2019-11-10 00:35:34 +02:00
gabime
89b5bcfdc7 Updated ringbuffer sink 2019-11-10 00:18:24 +02:00
gabime
26f706ebe3 Fixed #1302 2019-11-10 00:11:39 +02:00
gabime
0cb38085a1 Updated ringbuffer sink 2019-11-10 00:08:50 +02:00
Gabi Melman
cff6644b28
Merge pull request #1307 from eudoxos/ringbuffer-sink
Add ringbuffer sink
2019-11-09 21:38:57 +02:00
Václav Šmilauer
63837530ed Fix circular_q::size() empty case 2019-11-09 19:26:49 +01:00
Václav Šmilauer
62e09e73f7 defer formatting, use log_msg_buffer for intermediate storage 2019-11-09 13:48:04 +01:00
Václav Šmilauer
daef0a2374 Fix circular_q::size() 2019-11-09 13:15:57 +01:00
Václav Šmilauer
042045b998 typo fix 2019-11-09 09:35:05 +01:00
Václav Šmilauer
bad7284465 Fix cicular_q::size() 2019-11-09 09:30:27 +01:00
Václav Šmilauer
6f0cb6365e Move ringbuffer_sink to spdlog::details::circular_q, enhance its API: size(), at(i) 2019-11-08 19:25:31 +01:00
gabime
653ec05c0e Updated .clang-tidy with more checks 2019-11-08 16:42:16 +02:00
gabime
be2a751513 Fixed clang-tidy warning in example 2019-11-08 16:35:18 +02:00
gabime
840adfbbcf Added performance chacks tp .clang-tidy 2019-11-08 16:32:57 +02:00
Václav Šmilauer
acf32be842 Add ringbuffer sink (requires boost::circular_buffer)
Ringbuffer sink keeps user-given number of most recent log messages in
memory and returns them upon request (using the ringbuffer_sink::last
method). This can be useful for e.g. remote debugging of a running app.
2019-11-08 15:29:20 +01:00
gabime
3999613eca Added performance chacks tp .clang-tidy 2019-11-08 16:27:08 +02:00
gabime
bff85725d2 Fixed some more clang-tidy warnings 2019-11-08 16:20:41 +02:00
gabime
93008b2369 Fix clang-tidy warning about non existing move 2019-11-08 15:31:33 +02:00
gabime
be336e7514 Added noexcept to log_msg move constructor 2019-11-08 15:21:18 +02:00
gabime
255f7f2dee Optimze backtracer operator= 2019-11-08 15:09:57 +02:00
gabime
de2c07ac62 always cache gmt offset 2019-11-08 14:37:52 +02:00
gabime
844d54d7e6 Fix #1302 2019-11-08 14:27:05 +02:00
gabime
ff3e6c7248 Fix issue #1306 2019-11-08 14:08:31 +02:00
Gabi Melman
408a2229d6
Merge pull request #1304 from RedDwarf69/include_path
"#include" <spdlog/.*> instead of "spdlog/.*"
2019-11-06 22:27:56 +02:00
Cristian Morales Vega
7cdd65075c "#include" <spdlog/.*> instead of "spdlog/.*"
The meaning of using quotes to #include is implementation defined, so it
may or not may be what we want. At least POSIX
(https://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html)
says: "headers whose names are enclosed in double-quotes ( "" ) shall be
searched for first in the directory of the file with the #include line",
so not what we want since "spdlog" ends up twice in the path.
2019-11-06 19:15:29 +00:00
gabime
436ce16e79 Updated meson tests build 2019-11-05 00:31:36 +02:00
gabime
58320e2678 Updated meson build options 2019-11-05 00:22:30 +02:00
gabime
a6f7edf94b Updated meson build options 2019-11-05 00:16:45 +02:00
gabime
4a4f13be46 Updated meson build 2019-11-04 23:38:31 +02:00
gabime
a13b0abb7d Simplify meson for tests 2019-11-04 23:29:05 +02:00
gabime
c081919320 Enabled tests under meson by default 2019-11-04 23:19:02 +02:00
gabime
21f7f78130 Update tests CMakeLists.txt 2019-11-04 23:16:44 +02:00
gabime
bb1b24c178 Fixed #1295 2019-11-04 23:16:21 +02:00
gabime
3f30000088 comment 2019-11-04 17:51:57 +02:00
gabime
e6ce39f76e comment 2019-11-04 17:46:59 +02:00
gabime
10116b7717 Removed SPDLOG_NO_DATETIME option 2019-11-04 17:43:30 +02:00
gabime
18edb8bd63 Added tweakme options to CMakeLists.txt 2019-11-04 17:19:18 +02:00
gabime
dae1aeb1f7 clang-format 2019-11-04 16:48:54 +02:00
gabime
57085c892f exclude from compilation prevent_child_fd() if SPDLOG_PREVENT_CHILD_FD not defined 2019-11-04 16:42:58 +02:00
Gabi Melman
d67efb2cab
Merge pull request #1296 from sylveon/patch-1
Correctly guard SetHandleInformation API call
2019-11-04 10:58:14 +02:00
Charles Milette
0e09ecbaa5
Correctly guard SetHandleInformation API call
`__cplusplus_winrt` only detected C++/CX (which can be used without compiling for UWP, SetHandleInformation would be available in those cases), and did not detect native UWP C++. This patch fixes that by using the WINAPI_FAMILY_PARTITION macro in the Windows SDK headers in the same way those headers remove SetHandleInformation in UWP builds.
2019-11-03 22:41:55 -05:00
gabime
e3699070a4 clang-format 2019-11-03 17:07:37 +02:00
gabime
bf40855825 Micro-optimize level checking by inlining 2019-11-03 17:04:34 +02:00
gabime
3ee4f2810d Micro-optimze log_it_ 2019-11-03 17:01:58 +02:00
gabime
79468cf676 Micro-optimze log_it_ 2019-11-03 17:00:12 +02:00
gabime
4037942a26 suppress modernize-use-trailing-return-type fron clang-tidy 2019-11-03 15:22:54 +02:00
gabime
cae6c9ab36 Removed lazy argument evaluation from macros 2019-11-03 15:19:59 +02:00
gabime
15b393193a Replaced a forgotten try with SPDLOG_TRY 2019-11-03 15:16:03 +02:00
Gabi Melman
53ab34928c
Merge pull request #1294 from pck/refmacro
Improve log macros
2019-11-03 12:17:00 +02:00
Paul Kunysch
eb4a169cfb Improve log macros 2019-11-02 09:40:37 +01:00
Gabi Melman
6f6cadf31d
Merge pull request #1292 from jktjkt/journald
improve systemd journald support
2019-10-30 21:33:31 +02:00
Jan Kundrát
17513a6dce journald: structured output for logger's name
Previously, the logger name was effectively lost. There were two choices
on how to add it:

- Via a formatter, which would mean that `journalctl` would not be able
to filter against that. That would be suboptimal.

- As a "syslog identifier". This means that `journalctl` will, by
default, stop showing the daemon's executable name and replace that via
the logger name. The PID is still shown, and if one would like to go
back to the previous behavior, it is still possible via `journalctl -o
with-unit`.

I think that the second option is strictly better than the first one.

fixes #1289
2019-10-30 20:08:30 +01:00
Jan Kundrát
a44560ddb6 journald: fix source file location
This is what my manpage says, and what the original blog post [1] says
as well.

Also, `sd_journal_send` can add the location of its own invocation to
the log. That's typically not what we want, so we have to suppress that
feature and instead put whatever is inside the spdlog message into the
journal.

[1] http://0pointer.de/blog/projects/journal-submit.html
2019-10-30 20:08:29 +01:00
gabime
2b8afb38b7 Revert pull #1288 2019-10-28 23:41:40 +02:00
Gabi Melman
685ad74d53
Merge pull request #1288 from yipdw/bugfix/use-64-bit-file-access
Use _FILE_OFFSET_BITS=64 when building on Linux 32-bit systems
2019-10-28 20:48:56 +02:00
David Yip
288ea11534 Use _FILE_OFFSET_BITS=64 when building tests on Linux 32-bit systems
When cross-compiling spdlog from x86-64 to armhf, I ran spdlog-utests
via qemu-arm and noticed that the "daily_logger rotate" test was failing
because count_files always returned zero.

Investigation of count_files revealed that readdir was returning nullptr
immediately and setting errno to 75, i.e. "value too large for defined
data type".  I suspected this had something to do with some 64 vs.
32-bit thing, so I added _FILE_OFFSET_BITS=64 to the build and that
seems to have made readdir happy.

It might be safe to add _FILE_OFFSET_BITS=64 for all Linux builds, but
it only seems to be necessary for the 32-bit case (which is a pretty
small audience these days -- I'm only building for armhf to target a
Raspberry Pi 3 running Raspbian, which runs in 32-bit mode).
2019-10-28 13:23:01 -05:00
Gabi Melman
b848ff8db9
Merge pull request #1285 from masmullin2000/v1.x
Remove unused variable
2019-10-25 22:22:59 +03:00
Michael Mullin
5881fcb0d6 Remove unused variable 2019-10-25 14:47:38 -04:00
Gabi Melman
491a2e8732
Update os-inl.h 2019-10-25 18:59:02 +03:00
gabime
4a620a2c5e Merge branch 'Issue-1248' into v1.x 2019-10-25 16:56:26 +03:00
gabime
05105155f8 refactoed file_helper 2019-10-25 16:55:24 +03:00
gabime
9f96545fa7 refactoed file_helper 2019-10-25 16:52:12 +03:00
gabime
0c60107e62 refactoed file_helper 2019-10-25 16:50:06 +03:00
gabime
49eb9cbdd8 Removed junk folder 2019-10-25 16:26:21 +03:00
gabime
594d226056 update tests 2019-10-25 16:20:24 +03:00
gabime
aac7dccf45 comment 2019-10-25 16:17:55 +03:00
gabime
c19e325b83 Added some tests for create_dir 2019-10-25 16:17:02 +03:00
gabime
bd92c23add comment 2019-10-25 16:07:10 +03:00
gabime
88335bd92e clang-format 2019-10-25 16:05:12 +03:00
gabime
a4602021d8 Renamed private members of file_helper 2019-10-25 16:04:07 +03:00
gabime
dbe5c17a96 Renamed file_exists()->path_exists() 2019-10-25 15:56:23 +03:00
gabime
c40555c0ac clang-format 2019-10-25 15:44:53 +03:00
gabime
bfc76278a9 update tests 2019-10-25 15:24:54 +03:00
gabime
a1f283946e updated os::dir_name and tests 2019-10-25 14:29:57 +03:00
gabime
066087b383 Update create_dir 2019-10-25 14:14:50 +03:00
gabime
e9d42e059f // support forward slash in windows 2019-10-25 12:52:39 +03:00
Gabi Melman
d1dadc9814
Merge pull request #1283 from bencsikandrei/refactor/cmake-minor-duplication-removal
Minor cmake code duplication improvement
2019-10-25 12:28:10 +03:00
Andrei-Florin BENCSIK
2cc620ef33 Function instead of macro
Be more consistent with the existing code and with the naming
_function -> function
2019-10-25 11:15:07 +03:00
Andrei-Florin BENCSIK
cee705ccd3 Minor cmake code duplication improvement
Create a macro to add tests for both static/header only.

The only differneces between these two are the libraries they link
with and the target names. Created the simple macro:

_spdlog_prepare_test(<target> <spdlog_lib>)

which does the work.

Signed-off-by: Andrei-Florin BENCSIK <andrei.bencsik@gmail.com>
2019-10-24 22:57:47 +03:00
gabime
a8f72424db Merge branch 'Issue-1248' of https://github.com/gabime/spdlog into Issue-1248 2019-10-21 13:43:57 +03:00
gabime
31ed133932 Added dir_name tests 2019-10-21 13:42:25 +03:00
Gabi Melman
d3c6974e99
Update os.h 2019-10-20 19:09:37 +03:00
Gabi Melman
1271081865
Update os-inl.h 2019-10-20 19:08:47 +03:00
Gabi Melman
8a638a95a0
Update os-inl.h 2019-10-20 18:31:04 +03:00
Gabi Melman
d9f726f2a5
Add global namespace qualifiers to global function calls in os-inl.h 2019-10-20 18:25:09 +03:00
Gabi Melman
5f3521b3d4
Update utils.cpp 2019-10-20 17:55:13 +03:00
gabime
9a68bd8cc8 Fixed missing include 2019-10-20 17:48:13 +03:00
gabime
9b7812a0f2 auto create log dir 2019-10-20 17:40:56 +03:00
gabime
4858d7e454 Fix #1274 2019-10-20 10:27:17 +03:00
gabime
fbb3f41dff Fix #1273 2019-10-20 10:22:44 +03:00
Gabi Melman
1472048b97
Merge pull request #1275 from flopp/spelling
Fix some spelling errors.
2019-10-19 11:09:11 +03:00
Florian Pigorsch
4aad51a352 Fix some spelling errors.
casese -> cases (1)
chache -> cache (1)
cirucal -> circular (1)
dependecy -> dependency (1)
detrmine -> determine (2)
eavluate -> evaluate (1)
exertnal -> external (1)
ony -> only (1)
registation -> registration (3)
registring -> registering (2)
regsistration -> registration (3)
seperate -> separate (2)
wit -> with (1)
withe -> with (1)
2019-10-19 09:42:38 +02:00
gabime
9a0a0c2d8c clang-format 2019-10-18 16:14:08 +03:00
gabime
fcc809f4f1 Refactored logger 2019-10-18 16:10:57 +03:00
Gabi Melman
f3369677ef
Merge pull request #1270 from jktjkt/fix-clang7-libc++
Fix build failure on clang 7 with libc++
2019-10-18 11:38:56 +03:00
Jan Kundrát
a03f9eb156 Fix build failure on clang 7 with libc++
Unlike the GNU C++ STL, there's no implicit include for <array> in this
one, apparently.
2019-10-18 10:14:44 +02:00
Gabi Melman
aa65dd8905
version 1.4.3 rc 2019-10-11 19:48:33 +03:00
Gabi Melman
856b4f4654
Update README.md 2019-10-09 23:22:45 +03:00
gabime
9369fe8c27 Fix #1262 2019-10-09 21:41:02 +03:00
gabime
1549ff12f1 Replace STRING(PREPEND ..) in CMakeLists.txt to support older CMake versions 2019-10-06 13:13:26 +03:00
gabime
70357ceff2 clang-format 2019-10-06 00:31:38 +03:00
gabime
cfe7cac1c4 version 1.4.2 2019-10-06 00:30:40 +03:00
gabime
fb70eca0a3 CmakeLists.txt: add -pthread to pkg-config 2019-10-04 21:56:17 +03:00
gabime
cf2bf488a2 CmakeLists.txt: Fixed package config generation 2019-10-04 21:49:20 +03:00
Gabi Melman
5c02fc47b9
Merge pull request #1253 from DasRoteSkelett/v1.x
CMakeLists.txt: removed spdlog subdir from library install
2019-10-01 22:45:58 +03:00
Matthias Schoepfer
4021e5eea9 CMakeLists.txt: removed spdlog subdir from library install
The library gets installed into ${CMAKE_INSTALL_LIBDIR}/spdlog, which
is for unix / linux a rather strange place, hence, put it where the linker
is more likely to find it.

Signed-off-by: Matthias Schoepfer <matthias.schoepfer@ithinx.io>
2019-10-01 17:14:01 +02:00
Gabi Melman
5cd0b6272d
Update logger-inl.h 2019-10-01 01:56:02 +03:00
Gabi Melman
bf49bebe7a
Update logger.h 2019-10-01 01:50:18 +03:00
Gabi Melman
1e8299e893
Merge pull request #1252 from bsergean/v1.x
Fix windows compile error where std::max is overriden by a macro (#1251)
2019-09-30 08:34:02 +03:00
Benjamin Sergeant
5381061d97 Fix windows compile error where std::max is overriden by a macro (#1251) 2019-09-29 22:03:47 -07:00
gabime
274558c430 Fix issue #1250 2019-09-28 11:39:06 +03:00
gabime
188afe20f9 Fix issue #1249 2019-09-28 11:20:26 +03:00
gabime
1add9c9a02 Added SPDLOG_WCHAR_FILENAMES options to CMake 2019-09-28 11:19:56 +03:00
Gabi Melman
e7d4b99350
Merge pull request #1246 from tcraigtyler/v1.x
Set additional CPACK variables for RPM generator
2019-09-27 21:58:27 +03:00
Craig Tyler
8627721533 Set additional CPACK variables for RPM generator
Sets the following when querying the generated RPM's info:

Group       : System Environment/Libraries
License     : MIT
URL         : https://github.com/gabime/spdlog
Summary     : Fast C++ logging library
Description :
Very fast, header-only/compiled, C++ logging library.
2019-09-27 09:40:09 -07:00
Gabi Melman
6696416107
Update README.md 2019-09-25 10:58:30 +03:00
gabime
453be2e08a clang-format 2019-09-23 12:38:19 +03:00
gabime
83497e4dc9 Update test_stdout_api.cpp 2019-09-23 12:11:12 +03:00
gabime
3806a9c320 Added wchar api tests to windows 2019-09-23 12:06:21 +03:00
Gabi Melman
4da95066a0
Merge pull request #1241 from orbea/fmt
cmake: Only install fmt headers when SPDLOG_FMT_EXTERNAL is not defined.
2019-09-23 10:25:48 +03:00
Gabi Melman
ab1105524f
Merge pull request #1238 from orbea/pkgconfig
cmake: Add a new spdlog.pc pkgconfig file.
2019-09-23 10:22:36 +03:00
Gabi Melman
d70b743e03
Merge pull request #1240 from Bak-Jin-Hyeong/fix1239
Fix #1239, Remove basic_string_view_t
2019-09-23 10:20:08 +03:00
orbea
920dd078f3 cmake: Only install fmt headers when SPDLOG_FMT_EXTERNAL is not defined. 2019-09-22 23:19:11 -07:00
Bak, Jin Hyeong
f8e780b9dd Fix #1239, Remove basic_string_view_t 2019-09-23 14:48:09 +09:00
orbea
588910129c cmake: Add a new spdlog.pc pkgconfig file.
Fixes https://github.com/gabime/spdlog/issues/1237.
2019-09-22 19:04:29 -07:00
gabime
e42867f0a8 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-09-21 18:35:33 +03:00
gabime
fe20afac17 clang-format 2019-09-21 18:16:38 +03:00
Gabi Melman
10578ff08c
Update test_mpmc_q.cpp 2019-09-21 15:49:54 +03:00
Gabi Melman
1f0513cf4e
Update .travis.yml 2019-09-21 15:35:22 +03:00
Gabi Melman
647470f3ae
Update .travis.yml 2019-09-21 15:33:03 +03:00
Gabi Melman
efd0dbe5c2
Update .travis.yml 2019-09-21 15:30:29 +03:00
Gabi Melman
bd2fe64bf1
Update .travis.yml 2019-09-21 15:24:37 +03:00
gabime
7153db954f Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-09-21 15:14:18 +03:00
gabime
3b425affd3 Fixed missing braces around initializer warnings about std::array initializations 2019-09-21 15:13:50 +03:00
Gabi Melman
d5a79ad5d7
Update .travis.yml 2019-09-21 14:46:09 +03:00
Gabi Melman
7951338d27
Update .travis.yml 2019-09-21 14:38:54 +03:00
Gabi Melman
90801267ee
Merge pull request #1234 from jbeich/dragonfly
Unbreak on more BSDs
2019-09-20 20:47:41 +03:00
Jan Beich
8d57823e51 fstat64 is missing on other DragonFly, NetBSD, OpenBSD
Modern operating systems don't need to implement transitional
extensions for large file support.
2019-09-20 13:27:58 +00:00
Gabi Melman
277ccc5e18
Update log_msg_buffer-inl.h 2019-09-20 16:17:48 +03:00
Gabi Melman
cff9db5044
Update log_msg_buffer-inl.h 2019-09-20 16:11:40 +03:00
Gabi Melman
216f905670
Fix log msg buffer operator= 2019-09-20 16:11:22 +03:00
Jan Beich
53b2308011 Implement _thread_id() on more Unices 2019-09-20 13:10:27 +00:00
gabime
c368500efd Reverted some external template declarations 2019-09-20 02:05:24 +03:00
gabime
2fed68a73b Reverted some external template declarations 2019-09-20 01:52:05 +03:00
gabime
e7ab49c973 Added extern tempalate declarations 2019-09-20 01:28:02 +03:00
gabime
5496491aa4 Added extern template declarations 2019-09-20 00:18:36 +03:00
Gabi Melman
53ca5b2870
Update spdlog.cpp 2019-09-19 12:06:53 +03:00
Gabi Melman
6aced26c35
Update spdlog.cpp 2019-09-19 12:06:22 +03:00
Gabi Melman
2331750b58
Update log_msg_buffer.h 2019-09-19 12:02:59 +03:00
Gabi Melman
b3fb4c1265
Update log_msg_buffer-inl.h 2019-09-19 12:01:11 +03:00
Gabi Melman
3ad7b9b117
Update log_msg_buffer-inl.h 2019-09-19 12:00:59 +03:00
gabime
5721debdf1 split to log_msg_buffer.h ito header and mpl 2019-09-19 11:52:03 +03:00
gabime
c1c23d1e7b Revert pull #1228 2019-09-18 16:16:44 +03:00
gabime
9605641982 Updatede meson 2019-09-18 15:31:09 +03:00
gabime
e52672c263 Fixed CMakeLists.txt 2019-09-18 15:08:15 +03:00
gabime
50f070980e Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-09-18 15:01:28 +03:00
gabime
7733849478 Updated meson build 2019-09-18 15:01:23 +03:00
Gabi Melman
4bbc8a89a0
Merge pull request #1228 from scatter-dev/arch_independent
Added ARCH_INDEPENDENT option
2019-09-18 14:55:19 +03:00
Christian
c87882e82f added version check 2019-09-18 09:20:01 -02:30
Christian
bd4301b2c1 added arch_independent option 2019-09-17 14:45:59 -02:30
gabime
e771f4e75e Fix mingw32 compilation 2019-09-17 13:27:42 +03:00
Gabi Melman
35835469d7
Update common.h 2019-09-17 12:52:59 +03:00
Gabi Melman
0d6992fcdd
Update common.h 2019-09-17 12:48:54 +03:00
gabime
29b3f471cf Added const vecsion to circula_q::front() 2019-09-17 12:28:02 +03:00
gabime
4985875a15 Renamed item_type => value_type in circular_q 2019-09-17 12:07:54 +03:00
gabime
4fffd3a111 Avoid un necessary move when popping circular_q 2019-09-17 12:05:23 +03:00
gabime
590749e8be Avoid un necessary move when popping circular_q 2019-09-17 12:03:54 +03:00
gabime
27cc76766c Avoid un necessary move when popping circular_q 2019-09-17 12:01:15 +03:00
gabime
d52cf87d71 Avoid un necessary move when popping circular_q 2019-09-17 11:56:17 +03:00
gabime
2ddd6895e1 Backported clang warning fix from fmt 2019-09-17 00:15:35 +03:00
gabime
545e7d2de8 Fixed clang warning 2019-09-16 23:50:56 +03:00
gabime
a9ed6b352b Update utils.cpp 2019-09-16 11:58:51 +03:00
gabime
523eebe47d Update utils.cpp 2019-09-16 11:58:26 +03:00
gabime
b303d8bc40 Update tests utils 2019-09-16 11:56:56 +03:00
Gabi Melman
68118f4233
Update daily_file_sink.h 2019-09-15 21:50:29 +03:00
Gabi Melman
fcc6b97f88
Update utils.cpp 2019-09-15 21:01:15 +03:00
gabime
adc4398cc5 Fixed widows tests 2019-09-15 20:56:20 +03:00
Gabi Melman
c53d26cfca
Update utils.cpp 2019-09-15 19:15:35 +03:00
Gabi Melman
c188bee229
Update utils.cpp 2019-09-15 19:09:57 +03:00
Gabi Melman
7f1a89e3f6
Update utils.cpp 2019-09-15 18:49:19 +03:00
gabime
5d46f3fcab Fix windows build 2019-09-15 18:44:45 +03:00
gabime
b55d95d365 Update test utils for windows 2019-09-15 18:38:31 +03:00
gabime
494cc8bace Implemented daily sink rotation #661 2019-09-15 18:34:29 +03:00
gabime
03e8c0f45c Fix issue #1219 2019-09-13 14:01:53 +03:00
gabime
b6388a15ff Fix issue #1223 2019-09-13 11:38:24 +03:00
gabime
45a18a61c6 CmakeLists.txt: Added version-number and debug suffixes + SPDLOG_BUILD_SHARED property 2019-09-08 00:42:23 +03:00
gabime
1857a44c7c Fix #1215 2019-09-07 20:11:58 +03:00
gabime
bd9e1475e2 clang-format 2019-09-07 20:11:35 +03:00
gabime
6883267996 Added const to circular_q empty() and full() 2019-09-06 18:55:45 +03:00
gabime
b88c784634 Improved circular_q move 2019-09-06 18:53:10 +03:00
gabime
31020f9eea Fixed vs 2015 warning abour fmt unused variable 2019-09-06 16:41:36 +03:00
gabime
e89d59995a Merge branch 'tgpfeiffer-bump-fmtlib-6.0.0' into v1.x 2019-09-06 15:18:52 +03:00
Tobias Pfeiffer
bf324a11cd made the declarations in fmt.c match the ones in fmt-6.0.0 2019-09-06 10:06:00 +09:00
Tobias Pfeiffer
e149433a80 Bumped fmt to version 6.0.0 2019-09-06 09:51:42 +09:00
gabime
65d02e495e Reverted the version() function 2019-09-05 19:50:00 +03:00
gabime
f196a9fd27 Fix dupllicate 2019-09-05 19:42:08 +03:00
gabime
7f0398ca25 Added version() function 2019-09-05 18:51:28 +03:00
gabime
d7f05722d4 Fixed example 2019-09-05 18:32:54 +03:00
gabime
26377a2195 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-09-05 18:31:16 +03:00
gabime
aa4eaa16bf Fixed missing includes 2019-09-05 18:31:08 +03:00
Gabi Melman
abc7bfe5c9
Update README.md 2019-09-05 14:46:07 +03:00
Gabi Melman
f0f4499540
Update README.md 2019-09-05 14:42:34 +03:00
gabime
dae4f9fef6 split spdlog.cpp to multiple .cpp files 2019-09-05 14:37:25 +03:00
gabime
4c45c6fbd8 Removed redundant func 2019-09-05 02:31:23 +03:00
gabime
172cf26d77 Update comment 2019-09-05 02:31:03 +03:00
gabime
feefb7e7e2 format 2019-09-05 01:58:34 +03:00
gabime
ced44a15ea format 2019-09-05 01:54:29 +03:00
gabime
5c2855e1c1 wip backtracer 2019-09-05 01:25:00 +03:00
gabime
433785dc64 fix warnings and build 2019-09-05 01:12:27 +03:00
gabime
28845b96bd Update circular_q.h 2019-09-05 00:46:08 +03:00
gabime
98ec35cee1 Update backtracer.h 2019-09-05 00:39:50 +03:00
gabime
f795297e15 try different apprach to backtracer object 2019-09-05 00:39:11 +03:00
gabime
3fd3c47e6d Update logger-inl.h 2019-09-03 18:20:27 +03:00
gabime
153c25dbb3 Update logger-inl.h 2019-09-03 17:55:34 +03:00
gabime
a1a6b7e64f Update backtracer.h 2019-09-03 14:56:06 +03:00
gabime
3ea7fb18d6 Fix potential race condidion when in logger copy ctor
Don't copy other.trace - just create a new one with same size instead
2019-09-03 14:54:17 +03:00
gabime
6ff52332a8 Remove unused member from backtracer 2019-09-03 14:33:30 +03:00
gabime
5e75b104d6 Fix backtracer 2019-09-03 14:04:31 +03:00
gabime
dc893701f9 Update circular_q.h 2019-09-03 13:47:55 +03:00
gabime
e6b0aaf94a typo 2019-09-03 11:53:28 +03:00
gabime
e754cbf763 Update daily_file_sink.h 2019-09-02 12:55:05 +03:00
gabime
5988895d69 Simplify daily sink filename creation 2019-09-02 12:40:47 +03:00
gabime
2af5eea2c6 SImplify filename creation in rotating sink 2019-09-02 12:35:33 +03:00
Gabi Melman
554acb7429
Merge pull request #1203 from matt77hias/v1.x
Fixed {fmt} include if using the non-bundled version
2019-08-31 22:46:06 +03:00
Matthias Moulin
9c5869ce5a
Fixed {fmt} include if using the non-bundled version 2019-08-31 21:30:36 +02:00
Gabi Melman
e641ff64fd
Merge pull request #1202 from Jerry-Ma/patch-2
Remove extra semicolon
2019-08-31 18:52:03 +03:00
Zhiyuan "Jerry" Ma
aa731e3297
Remove extra semicolon
... in macro SPDLOG_LOGGER_CALL
2019-08-31 11:21:36 -04:00
Gabi Melman
ac6407bb8e
Update README.md 2019-08-29 01:13:43 +03:00
Gabi Melman
baf08eee09
Update README.md 2019-08-29 01:12:07 +03:00
Gabi Melman
04a43cd6a1
Update README.md 2019-08-29 01:10:50 +03:00
gabime
ed8d099607 Fixed #1197 2019-08-29 01:05:23 +03:00
gabime
b693d0cd91 Fix #1195 2019-08-29 00:28:00 +03:00
gabime
fafedd2d59 Minor cleanup 2019-08-29 00:07:21 +03:00
gabime
f3a7ef1199 Fix compile bug 2019-08-28 23:53:00 +03:00
Gabi Melman
cb890c96b9
Update logger.h 2019-08-28 22:59:16 +03:00
Gabi Melman
37bfa092a5
Update README.md 2019-08-28 20:13:35 +03:00
Gabi Melman
c517cb64ae
Update README.md 2019-08-28 20:08:51 +03:00
Gabi Melman
51e09fa504
Update README.md 2019-08-28 20:07:31 +03:00
Gabi Melman
691172e28b
Update README.md 2019-08-28 19:56:06 +03:00
Gabi Melman
6cf6d2159b
Update README.md 2019-08-28 19:55:10 +03:00
Gabi Melman
17f0b417d5
Update README.md 2019-08-28 19:54:27 +03:00
gabime
d89baf4c5b Fixed tidy warning 2019-08-28 19:00:35 +03:00
gabime
2eb52cd047 Unified usage of fmt::memory_buffer across the codebase 2019-08-28 18:50:11 +03:00
gabime
f5492aed12 Unified usage of fmt::memory_buffer across the codebase 2019-08-28 18:46:09 +03:00
gabime
c2efd6ee58 Increased msg_buffer size to 250 2019-08-28 17:47:22 +03:00
gabime
be507bf1cc Updated bench to include backtrace testing 2019-08-28 17:37:36 +03:00
gabime
f11f3ce8b7 Updated bench 2019-08-28 16:56:24 +03:00
Gabi Melman
b2a3e930c1
Update README.md 2019-08-28 16:32:16 +03:00
Gabi Melman
147bf04d08
Merge pull request #1196 from gabime/backtrace_support
Backtrace support !
2019-08-28 16:28:32 +03:00
gabime
f4d3616c4b Update test_backtrace.cpp 2019-08-28 15:59:58 +03:00
gabime
c97c025adb clang-format 2019-08-27 20:22:07 +03:00
gabime
c55336e78d Better support for logger copy with backtrace 2019-08-27 20:20:15 +03:00
gabime
13e9135935 Update test_backtrace.cpp 2019-08-27 19:45:21 +03:00
gabime
5c1e44a93d Added bactrace tests 2019-08-27 18:06:27 +03:00
gabime
75adf9e75e Improved test_sink in unit tests 2019-08-27 17:18:09 +03:00
gabime
0fa09f6af4 Removed dead clode 2019-08-27 16:39:18 +03:00
gabime
011ed270e8 backtrace support for wchar api under windows 2019-08-27 15:06:53 +03:00
gabime
d7e58ce10e Fixed example 2019-08-27 13:08:45 +03:00
gabime
813536d4c6 Update latency bench 2019-08-27 02:35:00 +03:00
gabime
b89023efa1 Merge branch 'backtrace_support' of https://github.com/gabime/spdlog into backtrace_support 2019-08-27 02:29:38 +03:00
gabime
b155347560 Added forgotten lock in backtracer 2019-08-27 02:28:49 +03:00
Gabi Melman
15faf742f1
Update README.md 2019-08-27 02:27:21 +03:00
Gabi Melman
2ba7d1639e
Update README.md 2019-08-27 02:26:28 +03:00
Gabi Melman
a2de7cf070
Update README.md 2019-08-27 02:23:22 +03:00
Gabi Melman
c6d558b6f2
Update README.md 2019-08-27 02:20:17 +03:00
gabime
d1b97c0ba9 Updated async_logger include 2019-08-27 02:16:29 +03:00
gabime
755ce0a016 Updated async_logger flush 2019-08-27 02:15:08 +03:00
gabime
79334ca5ab Fixed bench 2019-08-27 02:02:35 +03:00
gabime
11e9752536 Fixed logger's copy ctor 2019-08-27 01:56:48 +03:00
gabime
72b0f9e8f7 Updated example 2019-08-27 01:51:59 +03:00
gabime
408a162044 Removed logger::clone() from API 2019-08-27 01:16:57 +03:00
gabime
7d6444491c Fixed registy::disable_backtrace() 2019-08-27 01:08:48 +03:00
gabime
7bfb6d6b76 Fixed example 2019-08-27 00:58:01 +03:00
gabime
e1be7f3d6f Refactoring to better support backtrace 2019-08-27 00:56:49 +03:00
gabime
04a8485b17 Replaced backtace implementation 2019-08-26 19:59:16 +03:00
gabime
f330dd210e Renamed file 2019-08-26 13:43:42 +03:00
gabime
97dc27b5fa minor code formatting 2019-08-26 01:16:53 +03:00
gabime
1fd43fe673 Fixed async_logger::clone 2019-08-26 01:11:22 +03:00
gabime
29e21cc7f3 Comment 2019-08-26 00:56:05 +03:00
gabime
292fc153ef clang-format 2019-08-26 00:55:14 +03:00
gabime
25d3c83d3b Update async bench 2019-08-26 00:53:52 +03:00
gabime
6b7f3db28e Fixed async sink_it 2019-08-26 00:23:09 +03:00
gabime
eec6e28b19 Async logger cleanup 2019-08-26 00:13:43 +03:00
gabime
f3e379cf78 Fixed async dump_backtrace 2019-08-25 23:55:35 +03:00
gabime
0258c47774 some cleanup in logger 2019-08-25 19:35:57 +03:00
gabime
f63df65245 some cleanup in logger 2019-08-25 19:33:12 +03:00
gabime
099137fe9a backtrace_sink code cleanup 2019-08-25 18:05:47 +03:00
gabime
36f253893e Pass logger name to tracer 2019-08-25 17:44:08 +03:00
gabime
8280c0d64c Merge branch 'backtrace_support' of https://github.com/gabime/spdlog into backtrace_support 2019-08-25 17:28:49 +03:00
gabime
4f98b000eb Fixed example 2019-08-25 17:27:21 +03:00
gabime
b5d61b963a Fixed example 2019-08-25 17:25:06 +03:00
gabime
a7f7984c4a backtrace support api 2019-08-25 17:24:17 +03:00
gabime
dd33c16aae Replace backtrace trigger with dump_backtrace() 2019-08-23 14:47:40 +03:00
Gabi Melman
e0bf0c0301
Update thread_pool.h 2019-08-23 03:30:56 +03:00
gabime
8d8aacf5e9 Protect from double call to enable_backtrace() 2019-08-23 03:17:45 +03:00
gabime
e085ba7fcc Fix example 2019-08-23 02:48:40 +03:00
gabime
33f881ac8b clang-format 2019-08-23 02:45:41 +03:00
gabime
b24ef39b9d Update example 2019-08-23 02:45:35 +03:00
gabime
a6d8b52686 Added enable_backtrace to spdlog_api 2019-08-23 02:28:52 +03:00
gabime
65407539bb Fixed log_msg_buffer 2019-08-23 01:10:48 +03:00
gabime
543060683b Clean log_msg_buffer 2019-08-23 00:16:44 +03:00
gabime
2848e51755 Clean log_msg_buffer 2019-08-23 00:16:13 +03:00
gabime
0db4978899 Fixed example 2019-08-22 19:58:49 +03:00
gabime
0284a23d0a Changed sink_it_ to accept const log_message& 2019-08-22 19:57:59 +03:00
gabime
7e728869cc comment 2019-08-22 19:48:11 +03:00
gabime
a19d93e1a2 brace initialize some ctors 2019-08-22 19:45:32 +03:00
gabime
5aefa1af3d Fixed clang-tidy warnings 2019-08-22 19:40:45 +03:00
gabime
f1718fb5b3 clang-format 2019-08-22 19:38:00 +03:00
gabime
6b527a50dd backtrace sink and refactoring 2019-08-22 19:36:47 +03:00
gabime
74df115fc1 Removed uneeded include 2019-08-22 00:59:16 +03:00
Gabi Melman
3adfeeec3e
Merge pull request #1189 from AMS21/patch-1
Fix Wundef in os-inl.h
2019-08-20 00:21:04 +03:00
AMS21
c4df94a1d9
Fix Wundef in os-inl.h 2019-08-19 20:50:46 +00:00
gabime
da1d98d603 Fix example 2019-08-19 13:12:22 +03:00
gabime
6683418983 Fix example 2019-08-19 13:06:30 +03:00
gabime
2c1d97f1ad Removed junk 2019-08-19 13:03:25 +03:00
Gabi Melman
2f854428bc
Merge pull request #1188 from gabime/no-exceptions
Support for -fno exceptions
2019-08-19 12:58:11 +03:00
gabime
c1a524a969 Fixed clang-tidy warnings 2019-08-19 12:20:37 +03:00
gabime
23807e12e8 Fixed throw macros and includes 2019-08-19 12:13:37 +03:00
gabime
87ec1ab97b Fixed clang warnings 2019-08-19 12:06:29 +03:00
gabime
b057b979fa Added missing include 2019-08-19 12:03:58 +03:00
gabime
7dc378e296 Update CMakeLists.txt 2019-08-19 11:38:19 +03:00
gabime
6d8cc30f12 fix conflict 2019-08-19 11:33:39 +03:00
gabime
0335e3fcc0 Print error and abort instead of throw if SPDLOG_NO_EXEPTIONS is defined 2019-08-19 11:31:33 +03:00
Gabi Melman
76aa1059cd
Update async.h 2019-08-18 20:16:52 +03:00
gabime
b0a25f0183 wip - no-exceptions support 2019-08-18 19:46:28 +03:00
gabime
db1babab5e Fixed some msvc code analysis warnings 2019-08-18 18:28:13 +03:00
gabime
7ea951613d Update logger-inl.h 2019-08-18 17:45:09 +03:00
gabime
6506b73523 Add noexcept to move ctor and operator= 2019-08-18 17:33:35 +03:00
gabime
639029007d Update .gitignore 2019-08-18 17:32:54 +03:00
gabime
01eb59ca9b Removed spdlog::default_level and its usage in registry 2019-08-16 19:04:49 +03:00
gabime
a8b5e3da29 Removed unneeded test targets from CMakeLists 2019-08-16 18:48:18 +03:00
gabime
8cc0997f79 Added SPDLOG_WCHAR_SUPPORT options to CMake under windows 2019-08-09 10:31:53 +03:00
gabime
ffb7c317b5 Fix #1176 again 2019-08-09 10:16:18 +03:00
Gabi Melman
bb7420fc22
Update logger.h 2019-08-07 06:15:46 +03:00
gabime
0df9164e7c Fix #1176 2019-08-07 01:29:59 +03:00
gabime
dcd590b9de fstat64(..) -> ::fstat64(..) 2019-08-07 00:59:29 +03:00
gabime
8dc3a66688 Fix #1180 2019-08-06 19:12:35 +03:00
Gabi Melman
88b4adebdc
Update README.md 2019-07-26 22:41:24 -04:00
Gabi Melman
01f2438c1f
Merge pull request #1169 from TranslucentTB/v1.x
Add more overloads to spdlog::log and spdlog::logger::log
2019-07-24 22:10:23 -04:00
Charles Milette
eb51f37c67
Fix ambiguous overload errors 2019-07-24 13:52:03 -04:00
Charles Milette
4ef4d0659d
Improve correctness of convertion checks 2019-07-24 13:30:43 -04:00
Charles Milette
2ce9a3f70f
Add overload to logger when T can be statically converted to wstring_view_t 2019-07-24 13:27:54 -04:00
Charles Milette
59cbdaaf49
Add more source_loc overloads in spdlog namespace 2019-07-24 13:26:42 -04:00
Gabi Melman
e0cf16b7e9
Fix #1168 2019-07-24 08:49:59 -04:00
Gabi Melman
1cdf09e9dd
Merge pull request #1164 from AMS21/patch-1
Fix use of old style cast in os-inl.h
2019-07-22 17:11:14 -04:00
AMS21
9966a6a4b7
Fix use old style cast 2019-07-22 20:35:30 +00:00
Gabi Melman
20a1d1c519
Merge pull request #1161 from mensinda/mesonSubInstall
meson: Do not install when used as a subproject
2019-07-20 08:30:22 -04:00
Daniel Mensinger
313ec87dc1
meson: Do not install when used as a subproject 2019-07-20 14:26:17 +02:00
gabime
a7ba6e447d clang-format 2019-07-18 14:26:36 +03:00
gabime
baa978ab0b Added stdout_sinks.h to the library build 2019-07-18 14:00:16 +03:00
Gabi Melman
9f1b4fc9e7
Update wincolor_sink-inl.h 2019-07-18 01:37:55 +03:00
gabime
38e5dbd866 Fix win-color sink redirection to file 2019-07-18 00:55:24 +03:00
Gabi Melman
50ed27946d
Update README.md 2019-07-17 21:34:26 +03:00
Gabi Melman
856ac7d773
Update README.md 2019-07-17 21:31:58 +03:00
Gabi Melman
81f12df8b5
Update README.md 2019-07-17 21:30:06 +03:00
Gabi Melman
9eca3234e8
Update README.md 2019-07-17 21:28:56 +03:00
Gabi Melman
5a540bdd42
Update README.md 2019-07-17 21:21:56 +03:00
Gabi Melman
6d394b132d
Update README.md 2019-07-17 21:20:38 +03:00
Gabi Melman
96a317ce68
Update README.md 2019-07-17 21:19:16 +03:00
Gabi Melman
bca8945c26
Merge pull request #1155 from raphaelts3/how-to-compile-from-source
Update README.md
2019-07-17 21:16:55 +03:00
raphaelts3
a4b108334f
Update README.md
Moving the instructions to Install section
2019-07-17 15:12:52 -03:00
raphaelts3
4f72cf9744
Update README.md
Add steps to compile and install from source
2019-07-17 13:05:29 -03:00
gabime
3c30f77d31 limit default error handler to 1 message/second to avoid flood 2019-07-17 18:05:01 +03:00
gabime
bcb6484062 Removed redundant include statements 2019-07-17 16:09:39 +03:00
gabime
11472eddbc Catch sink exceptions without affecting other sinks 2019-07-17 16:01:30 +03:00
gabime
12470f6221 Revert null_sink changes 2019-07-17 15:33:29 +03:00
gabime
a82d0e2f57 try to prevent optimizer to remove null sink code altogether 2019-07-17 14:48:44 +03:00
gabime
dca1d1e0d1 try to prevent optimizer to remove null sink code altogether 2019-07-17 14:45:52 +03:00
gabime
0cef8f3d26 try to prevent optimizer to remove null sink code altogether 2019-07-17 14:42:26 +03:00
gabime
fbde18fc02 try to prevent optimizer to remove null sink code altogether 2019-07-17 14:41:18 +03:00
gabime
b640c59087 try to prevent optimizer to remove null sink code altogether 2019-07-17 14:41:07 +03:00
gabime
1f3dea60d3 try to prevent optimizer to remove null sink code altogether 2019-07-17 14:38:01 +03:00
gabime
a7c06eadd0 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-07-17 14:02:27 +03:00
gabime
39910f5137 Fixed execption include 2019-07-16 15:50:42 +03:00
Gabi Melman
6fc4eb92db
Merge pull request #1150 from ainola/v1.x
meson: fix typo (extrenal -> external)
2019-07-15 18:12:21 +03:00
gabime
81e82fb2d3 Rename func name wincolor sink 2019-07-15 12:22:34 +03:00
gabime
c817254495 Update wincolor_sink-inl.h
minor formatting
2019-07-15 12:14:46 +03:00
gabime
4578b0ad11 Fixed gcc9 conversion warning 2019-07-15 01:36:20 +03:00
gabime
9fbf82b603 Fixed gcc9 conversion warning 2019-07-15 01:31:31 +03:00
gabime
4b0267910c Refactored padding handling in formatter using templates 2019-07-15 01:17:22 +03:00
gabime
54456aee9e Refactored padding handling in formatter using templates 2019-07-15 01:16:57 +03:00
gabime
2a31cdcded Fix clang tidy script 2019-07-15 01:16:29 +03:00
gabime
d3f31c6038 Fixed build 2019-07-14 18:42:51 +03:00
gabime
59dd9f6203 comment 2019-07-14 18:39:43 +03:00
gabime
05cac05c06 clang_format 2019-07-14 18:35:59 +03:00
gabime
724713ac80 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-07-14 18:33:56 +03:00
gabime
72f3d5291c Fix issue #1147 2019-07-14 18:32:24 +03:00
gabime
c138685364 Fix issue #1147 2019-07-14 18:31:58 +03:00
Brett Cornwall
4180d00a6c meson: fix typo (extrenal -> external) 2019-07-14 07:29:23 -06:00
gabime
2512ac1e3c Added const qualifier to padinfo 2019-07-14 14:31:55 +03:00
gabime
121fc0a273 Minor update to CMakelists 2019-07-14 13:27:09 +03:00
gabime
4d9281018f Minor update to CMakelists 2019-07-14 13:26:01 +03:00
Gabi Melman
3a94a60537
Update stdout_sinks-inl.h 2019-07-14 01:41:19 +03:00
Gabi Melman
161e6fb8fb
Merge pull request #1145 from k0zmo/v1.x
Fix compiler and linker errors
2019-07-14 01:38:39 +03:00
k0zmo
29fa474e4a Use SPDLOG_HEADER_ONLY uniformly 2019-07-13 10:56:22 +02:00
k0zmo
ddb19f4a4f Add missing include directive 2019-07-13 10:55:17 +02:00
k0zmo
789fb1e7c9 Move templated constructor definition to header file 2019-07-13 10:54:22 +02:00
gabime
521c5317a2 Fix #1143 2019-07-11 19:23:06 +03:00
Gabi Melman
e0d85e60a3
Merge pull request #1142 from PeterTh/v1.x
Prevent NEAR and FAR macro definitions from leaking on Windows platforms
2019-07-10 20:47:59 +03:00
PeterTh
ac7821f9bf Prevent NEAR and FAR macro definitions from leaking on Windows platforms 2019-07-10 16:54:40 +02:00
Gabi Melman
84809db955
Update example.cpp 2019-07-10 03:07:17 +03:00
Gabi Melman
e6cecd97ac
Update README.md 2019-07-10 02:51:32 +03:00
Gabi Melman
60e7deaaf5
Update README.md 2019-07-10 02:51:09 +03:00
Gabi Melman
23b07d8cb6
Update README.md 2019-07-10 02:49:52 +03:00
gabime
5f27697198 clang-format 2019-07-10 02:42:47 +03:00
gabime
261d2c5ae4 Protected from size_t to int overflow in systemd sink 2019-07-10 02:25:11 +03:00
gabime
847f7de003 Simplify syslog sinks overflow check 2019-07-10 02:19:16 +03:00
gabime
dffc8df3e0 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-07-10 02:03:48 +03:00
gabime
330d491eba Enable again test building by default in cmake 2019-07-10 01:45:05 +03:00
gabime
db103ff340 Replaced passing time by val istead of ref in helper 2019-07-10 01:42:43 +03:00
gabime
1ac46bacfe Updated formatter bench 2019-07-10 01:41:55 +03:00
gabime
c27a4ee61f Added elapsed flag to formatter 2019-07-10 01:35:22 +03:00
Gabi Melman
2d8c4b1c88
Merge pull request #1140 from mattiasj-axis/fix-syslog-termination
Fix syslog output
2019-07-08 14:25:54 +03:00
Mattias Jernberg
d969f8621d Fix syslog output
payload does not appear to be reliably null terminated and leaks
data. Use size to the formatter to reliably terminate messages.
2019-07-08 13:14:15 +02:00
gabime
a4ec91fd06 Cleaned bench folder 2019-07-07 17:58:36 +03:00
gabime
fd53472238 Cleaned common.h 2019-07-07 17:22:58 +03:00
gabime
b3ddef2fc2 Minor cmake fix in for tests 2019-07-07 14:09:23 +03:00
gabime
07d753176f Update CMakeLists.txt to not build tests by default 2019-07-07 13:36:46 +03:00
gabime
8d758add63 Relace remaining const char* with string_view_t in the API 2019-07-07 12:55:56 +03:00
gabime
506ab1c735 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-07-07 12:35:54 +03:00
Gabi Melman
945020e505
Merge pull request #1139 from matt77hias/v1.x
Added fmt::(w)string_view support (v2).
2019-07-06 20:17:16 +03:00
Matthias Moulin
5a7bcd0a4f
Update logger.h 2019-07-06 19:00:49 +02:00
Matthias Moulin
ae92279f5c
Update spdlog.h 2019-07-06 19:00:17 +02:00
Matthias Moulin
be33f5eb89
Added wstring_view_t 2019-07-06 18:59:45 +02:00
gabime
717a582085 Dont allow including of dup_filter_sink if SPDLOG_NO_DATETIME is defined 2019-07-05 14:28:03 +03:00
gabime
ee87aee4dd Updated bench 2019-07-05 13:39:19 +03:00
Gabi Melman
2d6afeebe1
Update README.md 2019-07-05 12:30:36 +03:00
gabime
49bc58da04 Moved .clang-tidy and .clang-format to scripts dir 2019-07-05 10:49:46 +03:00
gabime
f5831d5132 clang-format 2019-07-05 10:45:37 +03:00
gabime
517ccc4088 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-07-05 10:45:24 +03:00
gabime
90dd56b839 Fix #1130 2019-07-05 10:44:54 +03:00
Gabi Melman
d1794f4c1b
Merge pull request #1133 from Jerry-Ma/patch-1
Add missing include
2019-07-04 01:19:41 +03:00
Zhiyuan "Jerry" Ma
75bb4346b2
Add missing include 2019-07-03 17:01:17 -04:00
Gabi Melman
13477e5478
Update .travis.yml 2019-07-02 09:58:23 +03:00
Gabi Melman
1093897838
Update CMakeLists.txt 2019-07-02 09:57:42 +03:00
Gabi Melman
4d27419d7c
Update CMakeLists.txt 2019-07-02 09:50:13 +03:00
Gabi Melman
89e6d66872
Update .travis.yml 2019-07-02 08:41:15 +03:00
Gabi Melman
b97c16a636
Update appveyor.yml 2019-07-01 23:55:09 +03:00
Gabi Melman
751ff59e2a
Update .travis.yml 2019-07-01 23:51:05 +03:00
Gabi Melman
64a549d051
Update meson.build 2019-07-01 23:19:57 +03:00
Gabi Melman
7a686d4d21
Update CMakeLists.txt 2019-07-01 15:03:53 +03:00
Gabi Melman
7b218737cc
Merge pull request #1126 from mensinda/meson
Add meson support
2019-07-01 14:53:46 +03:00
Gabi Melman
b1520a87c3
Merge pull request #1129 from s-shin/hotfix/daily_file_sink_when_no_datetime_2
Fix one more `msg.time` in daily_file_sink.
2019-07-01 13:41:49 +03:00
Daniel Mensinger
2a2a34601c
moved scripts into subdirectory 2019-07-01 12:37:18 +02:00
Daniel Mensinger
3c64b3da97
Added example meson.build 2019-07-01 12:32:12 +02:00
Gabi Melman
e7889e9ce2
Delete spdlogConfigVersion.cmake 2019-07-01 13:19:25 +03:00
Gabi Melman
7c8f45747c
Delete spdlogConfig.cmake 2019-07-01 13:19:18 +03:00
Gabi Melman
d37def7a72
Delete CPackSourceConfig.cmake 2019-07-01 13:19:10 +03:00
Gabi Melman
452770e374
Delete CPackConfig.cmake 2019-07-01 13:19:03 +03:00
Shintaro Seki
54e44ab477 Fix one more msg.time. 2019-07-01 19:04:37 +09:00
Gabi Melman
6012d52fdb
Merge pull request #1128 from s-shin/hotfix/daily_file_sink_when_no_datetime
Fix rotation condition when SPDLOG_NO_DATETIME is defined.
2019-07-01 12:21:33 +03:00
Shintaro Seki
7ffa0766b4 Fix rotation condition when SPDLOG_NO_DATETIME is defined.
When SPDLOG_NO_DATETIME is defined, the rotation was never worked
because `msg.time` is always zero.
2019-07-01 16:22:56 +09:00
Gabi Melman
d8e17111b9
Merge pull request #1127 from TranslucentTB/v1.x
Fix deprecation warnings in filename_to_str and improve performance of wbuf_to_utf8buf
2019-07-01 05:34:16 +03:00
Charles Milette
9e602a491b
Silence narrowing warning 2019-06-30 21:43:28 -04:00
Charles Milette
f529afa625
Use stack allocated space when possible 2019-06-30 21:34:19 -04:00
Gabi Melman
5a4deb6e88
Update README.md 2019-07-01 03:14:08 +03:00
Charles Milette
3bcd3cef2f
Fix deprecation warnings in filename_to_str 2019-06-30 19:12:16 -04:00
gabime
fbe6f945f3 Updated travis and appveyor to new cmake options 2019-07-01 02:08:48 +03:00
gabime
bb0f3839c1 Updated CMake options and defaults 2019-07-01 02:06:09 +03:00
Daniel Mensinger
af4026104c
Extract version from header file 2019-06-30 16:48:20 +02:00
Daniel Mensinger
822aee2b4f
Added meson build support 2019-06-30 16:27:28 +02:00
gabime
f09334dc6f Updated pattern_foramtter tests 2019-06-28 17:31:55 +03:00
gabime
d1d2609f49 Updated syslog_sink 2019-06-28 17:31:28 +03:00
gabime
9aa6cdc494 Updated systemd sink and tests 2019-06-28 17:29:52 +03:00
Gabi Melman
8b403081c1
Merge pull request #1122 from jbelloncastro/v1.x
Provide source location support for systemd_sink.h
2019-06-28 08:07:38 +03:00
Gabi Melman
dc054c3f8a
Merge branch 'v1.x' into v1.x 2019-06-28 08:07:15 +03:00
gabime
94c2810b0a Reduced max padding 128=>64 2019-06-28 01:41:11 +03:00
gabime
6e83abdbf2 Removed stdout_sinks from spdlog.cpp for faster library compile time 2019-06-28 01:01:22 +03:00
gabime
f03eaaaf33 Fixed dup_filter test 2019-06-28 00:48:30 +03:00
gabime
71162ebdbb Fixed dup_filter test 2019-06-28 00:47:10 +03:00
gabime
c75549f6db Removed un needed #include 2019-06-28 00:14:16 +03:00
gabime
2ebc96d8eb Fixed windows build 2019-06-28 00:05:06 +03:00
gabime
29f2eeea31 Removed formatter_ member from the sink interface 2019-06-27 23:56:37 +03:00
Jorge Bellon-Castro
a13981ffe4 Provide source location support for systemd_sink.h 2019-06-27 18:18:48 +01:00
gabime
cf152e6030 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-06-27 17:41:17 +03:00
gabime
b279196af2 Added tests for dup_filter sink 2019-06-27 17:41:04 +03:00
gabime
98e151fda7 Added tests for dup_filter sink 2019-06-27 17:40:40 +03:00
gabime
7f3b5fb84d Fix dup filter 2019-06-27 17:17:25 +03:00
Gabi Melman
3d069f7b46
Update dist_sink.h 2019-06-26 01:25:06 +03:00
Gabi Melman
65c4f955a6
Update systemd_sink.h 2019-06-26 01:22:24 +03:00
Gabi Melman
246b4b01c5
Update syslog_sink.h 2019-06-26 01:21:40 +03:00
Gabi Melman
a680b71dc7
Update null_sink.h 2019-06-26 01:18:06 +03:00
Gabi Melman
d0b5b09318
Merge pull request #1120 from casperevan/patch-1
Fix missing include for null_mutex in rotating_file_sink.h
2019-06-26 00:10:47 +03:00
casperevan
67f3a83c31 Fix missing include for null_mutex in rotating_file_sink.h 2019-06-25 13:09:16 -07:00
gabime
5dd260c336 Added missing include to dist_sink 2019-06-25 17:56:25 +03:00
gabime
ee6f165a1f New duplicate filter sink 2019-06-25 17:55:20 +03:00
Gabi Melman
0cc2ff83ed
Merge pull request #1119 from MarkKoester/patch-1
Fix warning: redundant move in return statement
2019-06-21 22:33:05 +03:00
Mark Koester
a9e92d6c5c
Fix warning: redundant move in return statement 2019-06-21 15:24:52 -04:00
Gabi Melman
ea5f07110b
Merge pull request #1118 from DanielChabrowski/stdout-incomplete
Fix use of incomplete type in stdout sinks
2019-06-21 07:54:02 +03:00
DanielChabrowski
59746c2e36 Fix use of incomplete type in stdout sinks 2019-06-21 01:21:30 +02:00
gabime
6399e05209 clang-format 2019-06-20 01:05:57 +03:00
gabime
08de642536 Added stdout tests 2019-06-20 01:02:54 +03:00
gabime
ab9e1b3aa7 Removed unneeded includes 2019-06-20 01:02:25 +03:00
gabime
af6744b112 Fixed color 2019-06-20 01:00:50 +03:00
gabime
1d86803e38 Fix #1116 2019-06-20 00:29:23 +03:00
gabime
b12c19162b Added thread callback option to thread_pool 2019-06-19 18:38:35 +03:00
gabime
220608e52a clang-format 2019-06-19 18:31:21 +03:00
gabime
06fb5c7c69 Close issue #1113 2019-06-19 18:30:50 +03:00
gabime
8970fd5d2f CMake cosmetic 2019-06-19 18:01:34 +03:00
gabime
67d5f65507 CMake support for building shared lib (not for win32) 2019-06-19 17:52:50 +03:00
gabime
7d678be07a CMake - turn off examples by default 2019-06-19 17:31:25 +03:00
gabime
74e2aa9c66 Micoro optimize macros 2019-06-19 17:13:48 +03:00
Gabi Melman
b9cc158e52
Fix #1115 2019-06-19 01:24:06 +03:00
gabime
e68cf1c9ed Add formatting option to syslog in ctor. Fix issue #729 #1107 2019-06-19 00:52:38 +03:00
gabime
f0fcc73f92 Minor improvments to ansicolor sink 2019-06-18 23:45:18 +03:00
gabime
a340b3812c Add missing template instantiation 2019-06-18 23:42:36 +03:00
gabime
78c833a09f clang-format 2019-06-18 17:05:27 +03:00
gabime
38888ba5b3 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-06-18 16:56:17 +03:00
gabime
99e519cf0f Simplify color sinks 2019-06-18 12:32:51 +03:00
gabime
09cb45001b Added copy ctor and assignment to logger 2019-06-15 19:46:41 +03:00
gabime
9d3aa5a253 Revert last commit 2019-06-14 20:44:46 +03:00
gabime
314308f975 Removed unused template from spdlog.cpp 2019-06-14 19:01:28 +03:00
gabime
b658ff2124 Fix unittests 2019-06-14 18:45:16 +03:00
Gabi Melman
c844ea4423
Update test_pattern_formatter.cpp 2019-06-14 01:30:43 +03:00
gabime
db5af8ead1 clang-format 2019-06-14 00:23:51 +03:00
gabime
c09dee7717 Moved source filename shortening to pattern formatter instead of macro 2019-06-14 00:23:25 +03:00
Gabi Melman
352281313f
Update README.md 2019-06-11 23:17:08 +03:00
gabime
8afe18f148 Minor improvement CMakeLists to use generators 2019-06-10 20:10:28 +03:00
gabime
90f348d26a Version 2019-06-10 19:55:26 +03:00
gabime
8d3d06b7a0 Fixed version extraction in CMake 2019-06-10 19:53:39 +03:00
Gabi Melman
c56ee8ec03
Update version.h 2019-06-10 19:19:29 +03:00
Gabi Melman
76f6c10434
Update README.md 2019-06-10 19:18:47 +03:00
gabime
cf64f2baca Fixed CMake address sanitizer 2019-06-10 18:32:10 +03:00
gabime
68a0193d95 CMake refactoring to functions 2019-06-10 18:09:36 +03:00
Gabi Melman
80740f0e46
Merge pull request #1105 from jktjkt/do-not-impose-extra-warnings
Do not impose -Wextra -Wconversion etc on library users
2019-06-10 12:35:42 +03:00
Jan Kundrát
c60f790793 Do not impose -Wextra -Wconversion etc on library users
I had to nuke the flags targetting spdlog_header_only because in CMake,
an interface target apparently really only supports the INTERFACE
option.

As I am only targeting Linux, the MSVC changes rely on spdlog's CI and
manual code review. That said, it makes sense to also stop forcing these
options on third party code, assuming that the CMake installations work
the same on Windows.

Fixes #1104
2019-06-10 10:54:49 +02:00
gabime
e0b4ec54bd Fix warning in bench 2019-06-07 16:39:32 +03:00
gabime
d1bed6bf45 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-06-06 19:26:17 +03:00
Gabi Melman
b82966e775
Update README.md 2019-06-06 19:25:07 +03:00
Gabi Melman
19a9d87486
Update README.md 2019-06-06 19:23:55 +03:00
gabime
3448e5867e Added oberrun policy bench to async-bench and removed async from bench 2019-06-06 19:23:15 +03:00
Gabi Melman
e013d6b98c
Update README.md 2019-06-06 18:50:03 +03:00
gabime
d392739049 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-06-06 18:31:21 +03:00
gabime
12266ad004 Fix async bench under msvc 2019-06-06 18:31:12 +03:00
gabime
e03c160e27 Optmize set_formatter to avoid redundant clone 2019-06-06 18:19:36 +03:00
gabime
03f0e2196e Fix async bench under msvc 2019-06-06 18:13:30 +03:00
Gabi Melman
34ea38c12e
Update README.md 2019-06-04 23:42:13 +03:00
gabime
a33de607df Fix issue #1099 2019-06-04 16:41:24 +03:00
gabime
e39959a132 Updated tests to catch v2.8.0 2019-06-04 16:35:34 +03:00
gabime
33a42202c7 Replace string pointer with string_view in log_msg 2019-06-04 16:10:49 +03:00
gabime
efc358da9f Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-06-04 15:39:02 +03:00
gabime
c1b39eb2ce Fix circular include 2019-06-04 15:38:26 +03:00
Gabi Melman
12e30f0eb4
Update format.sh 2019-06-04 12:26:49 +03:00
Gabi Melman
94bf971f72
Update clang_tidy.sh 2019-06-04 12:26:00 +03:00
gabime
bcfa9241b8 Updated copyright headers 2019-06-04 00:09:16 +03:00
gabime
eea9d6136f Moved default sync factory to seperate file to avoid cyclic includes 2019-06-03 23:56:18 +03:00
gabime
c35f33e61a Fixed clang warning about size_t indexing 2019-06-03 23:24:57 +03:00
gabime
78eeba940a Fix issue #114 2019-06-03 23:20:53 +03:00
gabime
b3ed5f77f2 Updated tweakme 2019-06-03 23:10:01 +03:00
gabime
38f6b5ea71 Keep clang-tidy happy 2019-06-03 22:49:21 +03:00
gabime
c000a6164c Removed unused member from log_msg 2019-06-03 22:20:46 +03:00
Gabi Melman
cb6208a6fa
Update .clang-tidy 2019-06-03 12:53:36 +03:00
Gabi Melman
b540558db6
Update INSTALL 2019-06-03 12:51:42 +03:00
Gabi Melman
e70b2dfbb2
Update INSTALL 2019-06-03 12:51:20 +03:00
Gabi Melman
f64cad89c4
Update INSTALL 2019-06-03 12:50:52 +03:00
Gabi Melman
935b3de2ad
Update INSTALL 2019-06-03 12:50:27 +03:00
Gabi Melman
abc0359522
Update INSTALL 2019-06-03 12:49:35 +03:00
Gabi Melman
fcd48d9b2d
Update INSTALL 2019-06-03 12:48:43 +03:00
Gabi Melman
97a79a4511
Update README.md 2019-06-03 12:23:33 +03:00
Gabi Melman
31172b0ecc
Update README.md 2019-06-03 12:21:17 +03:00
Gabi Melman
74bd1613bd
Update README.md 2019-06-03 12:19:57 +03:00
Gabi Melman
1fb3f95fdb
Update README.md 2019-06-03 12:19:34 +03:00
gabime
ca571e7a7a Updated bench of empty logger 2019-06-01 15:00:14 +03:00
gabime
52b6be0dfe Added logger ctor that accepts only name(empty logger) 2019-06-01 14:57:57 +03:00
gabime
abd6a6784e Set default queue size in async bench to 8192 2019-06-01 13:44:21 +03:00
gabime
978df46611 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-06-01 13:41:57 +03:00
gabime
31c428cece Report memory consumption in async bench 2019-06-01 13:41:39 +03:00
Gabi Melman
67c892991a
Update README.md 2019-05-30 10:20:29 +03:00
gabime
5743adc467 CMake use extract version from version.h 2019-05-29 15:15:35 +03:00
gabime
76fc166e11 CMakeLists.txt minor improvments 2019-05-29 01:41:48 +03:00
gabime
459cd21070 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-05-29 01:33:44 +03:00
gabime
fc53e3339f CMakeLists.txt minor improvments 2019-05-29 01:33:20 +03:00
Gabi Melman
9b788a882d
Update README.md 2019-05-29 01:07:42 +03:00
Gabi Melman
5a3e0d5e85
Update README.md 2019-05-29 01:06:31 +03:00
Gabi Melman
ce4da69cc0
Update README.md 2019-05-29 01:04:54 +03:00
Gabi Melman
1a779077db
Update README.md 2019-05-29 01:04:33 +03:00
Gabi Melman
e79531b292
Update README.md 2019-05-29 01:03:34 +03:00
Gabi Melman
7fea60183f
Update README.md 2019-05-29 01:02:19 +03:00
Gabi Melman
41df6c4df2
Update README.md 2019-05-29 01:01:44 +03:00
Gabi Melman
b6a28b497b
Update README.md 2019-05-29 01:00:29 +03:00
Gabi Melman
c75fbabc0f
Update README.md 2019-05-29 00:59:36 +03:00
Gabi Melman
4cc0876efa
Update README.md 2019-05-29 00:57:56 +03:00
Gabi Melman
abe1e37253
Update README.md 2019-05-29 00:57:29 +03:00
Gabi Melman
4dec965569
Update README.md 2019-05-29 00:57:00 +03:00
Gabi Melman
f478eaa98e
Update README.md 2019-05-29 00:56:22 +03:00
Gabi Melman
1e105f88ca
Update README.md 2019-05-29 00:53:50 +03:00
Gabi Melman
6586f3ed29
Update README.md 2019-05-29 00:52:59 +03:00
Gabi Melman
ba7019de8a
Update README.md 2019-05-29 00:52:18 +03:00
Gabi Melman
9562ce3b87
Update README.md 2019-05-29 00:51:30 +03:00
Gabi Melman
a48fe674ee
Update README.md 2019-05-29 00:51:04 +03:00
gabime
d439f75491 Minor CMake cosmetic fix 2019-05-29 00:17:38 +03:00
gabime
c559067f77 CMake refactoring 2019-05-29 00:13:02 +03:00
gabime
30bd80bd85 CMake improvements 2019-05-29 00:05:24 +03:00
Gabi Melman
5709cb10d1
Merge pull request #1089 from gabime/static-lib
Static lib support using -DSPDLOG_COMPILED_LIB
2019-05-25 23:14:32 +03:00
gabime
9329f8d3cd Merge v1.x 2019-05-24 12:46:20 +03:00
gabime
884c23a9c9 Merge v1.x 2019-05-24 12:44:51 +03:00
gabime
7a3a560c44 Merge v1.x 2019-05-24 12:33:14 +03:00
gabime
2963da1392 Updated travis 2019-05-24 08:47:29 +03:00
gabime
54f1941691 Fixed target_compile_options in cmake 2019-05-24 01:39:02 +03:00
gabime
ca14ae19db Turn off tsan in travis - gives false positives 2019-05-24 01:38:26 +03:00
gabime
6636ae6e63 CmakeLists.txt compiler warnings 2019-05-23 23:35:30 +03:00
gabime
2e75f42c69 Install using GNUInstallDirs in cmake 2019-05-23 19:17:52 +03:00
gabime
c9547f383a Fixed appveyor cmake 2019-05-23 18:33:02 +03:00
gabime
65576707bf Removed shared_lib option (not supported by windwos) and remove example and test from default build 2019-05-23 18:26:47 +03:00
gabime
6ec8a06a09 Fixed Cmake under windows and disable bench build from default config 2019-05-22 12:32:59 +03:00
gabime
9205c9d031 Merge branch 'static-lib' of https://github.com/gabime/spdlog into static-lib 2019-05-22 12:19:55 +03:00
gabime
1ef80d6330 Updated CMakeLists.txt 2019-05-19 19:39:38 +03:00
Gabi Melman
322665a22f
Delete example.cpp 2019-05-19 17:59:00 +03:00
Gabi Melman
cfa6d12691
Delete Application.mk 2019-05-19 17:58:52 +03:00
Gabi Melman
c264c3e2dd
Delete Android.mk 2019-05-19 17:58:44 +03:00
Gabi Melman
d21bcd2f87
Delete utils.h 2019-05-19 17:57:18 +03:00
Gabi Melman
84f25b9f18
Update CMakeLists.txt 2019-05-19 17:19:35 +03:00
Gabi Melman
576fec4c36
Update CMakeLists.txt 2019-05-19 17:17:58 +03:00
Gabi Melman
48acafd10d
Update CMakeLists.txt 2019-05-19 17:16:22 +03:00
Gabi Melman
a532a072ce
Update CMakeLists.txt 2019-05-19 17:06:22 +03:00
gabime
2cd53c6ff1 Updated cmake example 2019-05-19 16:34:38 +03:00
gabime
18ccd55725 Removed multisink and test in example 2019-05-19 15:57:22 +03:00
gabime
87eb569929 More updates to CMake (version support , cmake.in) 2019-05-19 15:47:49 +03:00
gabime
92387b1527 Merge branch 'static-lib' of https://github.com/gabime/spdlog into static-lib 2019-05-19 12:27:11 +03:00
David Zemon
dd2f293f33 Clean up CMake a bit more 2019-05-17 23:33:44 -05:00
David Zemon
24e4f0aa87 Allowed overriding of SPDLOG_MASTER_PROJECT to better support Conan 2019-05-17 23:31:30 -05:00
David Zemon
6fe899af10 Set Threads::Threads dependency on spdlog libs - don't make user do it 2019-05-17 23:28:53 -05:00
David Zemon
107fe0a142 Ensure header_only library works by adding another example exe 2019-05-17 23:27:44 -05:00
David Zemon
b021be29e5 Add support for .tar.gz and .zip packages via CPack 2019-05-17 23:27:44 -05:00
David Zemon
55e7844ca0 Remove the namespaced
Namespaces are good for avoiding collisions, but since the
non-namespaced targets still exist, it does no good to add the
namespaced targets on top.
2019-05-17 23:27:44 -05:00
David Zemon
8dd85285e7 Allow user to choose between static or shared library 2019-05-17 23:26:06 -05:00
David Zemon
dbcbeb7a57 Ignore CLion's default build directories 2019-05-17 23:05:48 -05:00
David Zemon
a9aee1c5b3 Disable automatic handling of line endings 2019-05-17 23:02:39 -05:00
gabime
b3fe4b54c8 Fixed CMakeLists.txt 2019-05-13 01:28:06 +03:00
gabime
872ea6bf09 Deleted redundant Make files and solutions 2019-05-13 01:13:58 +03:00
gabime
32fb9d51b9 Cmake update to support both header-only and static 2019-05-13 01:06:25 +03:00
gabime
ce637440bb wip static-lib 2019-05-13 00:09:00 +03:00
gabime
61e4597488 Removed include of fmt_helper from thrad_pool.h 2019-05-13 00:02:55 +03:00
gabime
26a064ed2d wip static-lib 2019-05-12 23:36:48 +03:00
gabime
d5c9bac3c7 wip static-lib 2019-05-12 23:08:14 +03:00
gabime
1665006401 Minor fix in example 2019-05-12 17:12:08 +03:00
gabime
5220ac4a9e Added missing header 2019-05-12 17:05:14 +03:00
gabime
ee0fdf016a Minore cmake fix 2019-05-12 16:13:13 +03:00
gabime
8b4eedb594 More template instantiations for static lib 2019-05-12 16:11:35 +03:00
gabime
01f5efa1d9 Added wincolor sink to static build 2019-05-12 15:32:54 +03:00
gabime
130bc26b9a wip static-lib 2019-05-12 02:16:31 +03:00
gabime
09e83937de wip static-lib 2019-05-12 02:10:39 +03:00
gabime
42e30468a9 added rotating_file_sink to static build 2019-05-12 01:43:30 +03:00
gabime
3834acad5b #error if compiling spdlog.cpp under header only configuration 2019-05-12 01:12:46 +03:00
gabime
654f7eceee #error if compiling spdlog.cpp under header only configuration 2019-05-12 01:04:48 +03:00
gabime
ca9c8ae5fb Warn if compiling spdlog.cpp under header only configuration 2019-05-12 01:01:37 +03:00
gabime
1752086cfd Don't include fmt format.cc source if using external fmt 2019-05-12 00:50:43 +03:00
gabime
369b2f7cd2 Moved format.cpp into spdlog.cpp - this way only one src file is needed 2019-05-12 00:44:26 +03:00
gabime
8b244ca988 Moved format.cpp into spdlog.cpp - this way only one src file is needed 2019-05-12 00:43:58 +03:00
gabime
fb9e51d943 Fixed include order and example 2019-05-12 00:34:55 +03:00
gabime
bb3dc87953 Fixed include order and example 2019-05-12 00:32:57 +03:00
gabime
6bcb422c80 clang format and SPLDOG_HEADER_ONLY macro 2019-05-12 00:22:39 +03:00
gabime
540f865355 Normalized copyright message 2019-05-11 20:15:03 +03:00
gabime
46ef71e3ec Normalized copyright message 2019-05-11 20:06:17 +03:00
gabime
005450ff13 wip 2019-05-11 13:52:46 +03:00
gabime
f809427575 Moved cpp files to inl.h 2019-05-11 13:20:11 +03:00
gabime
9564eb2edb Moved cpp files to inl.h 2019-05-11 13:19:53 +03:00
gabime
49708f209b fix inclusion of fmt 2019-05-11 12:28:36 +03:00
Gabi Melman
14381fe8d0
Update os.h 2019-05-11 03:05:22 +03:00
gabime
17bec5c3ce Use fmt src file instead of inline in static lib build 2019-05-11 01:33:48 +03:00
gabime
2b90ab496a ansicolor_sink.cpp 2019-05-10 18:48:03 +03:00
gabime
74dbf4cf70 mutex protect should_color() 2019-05-10 18:46:13 +03:00
Gabi Melman
e504aceeb5
Update wincolor_sink.h 2019-05-10 17:59:48 +03:00
gabime
3ce9ac74a6 Mutex protect set_color_mode() 2019-05-10 17:41:21 +03:00
Gabi Melman
3b0e7b4d0d
Merge pull request #1075 from psalz/add-force-color-output-option
Add option to force color output without TTY
2019-05-10 17:20:12 +03:00
Philip Salzmann
5e856c6b4d Add mode enum to control output of color sinks
This adds a new "color_mode" enum that can be used to control the color
code output behavior of sinks with color support. It can be one of three
values: always, automatic and never.
2019-05-10 09:47:16 +02:00
gabime
6651a48c4d wip 2019-05-08 17:50:23 +03:00
gabime
c031ae2aab Cmake message 2019-05-08 17:37:25 +03:00
gabime
1ac6c9f9c2 clang-format static-lib 2019-05-08 17:17:11 +03:00
gabime
5d0eb6dda5 wip static-lib 2019-05-08 17:16:56 +03:00
gabime
29c949ab03 static lib by default 2019-05-08 16:36:14 +03:00
gabime
576e389788 static lib by default and tests 2019-05-08 16:34:20 +03:00
gabime
7b15a3d345 wip cmake 2019-04-27 19:42:19 +03:00
gabime
eedb43d756 wip cmake 2019-04-27 19:41:25 +03:00
gabime
338125b93a wip cmake 2019-04-27 19:40:24 +03:00
gabime
3ecc3ab798 wip cmake 2019-04-27 19:38:39 +03:00
gabime
de1cdb2dbe wip cmake 2019-04-27 19:38:26 +03:00
gabime
c9887874bc wip cmake 2019-04-27 19:37:59 +03:00
gabime
69fcaf14e5 wip static-lib 2019-04-27 18:44:48 +03:00
gabime
f414198fee Cmake fix 2019-04-27 02:42:33 +03:00
gabime
2de924a187 clang-format 2019-04-27 02:34:50 +03:00
gabime
c1c2ff2d07 wip 2019-04-27 02:33:33 +03:00
gabime
ff89f1476d Restored error_handler as std::function 2019-04-26 18:14:59 +03:00
gabime
e8d99cee70 fix formatter bench 2019-04-26 17:52:47 +03:00
gabime
ccfa3f03b0 Fixed clang tidy 2019-04-26 17:39:58 +03:00
gabime
baefe0b3f6 wip 2019-04-26 15:11:01 +03:00
Gabi Melman
3669351427
Merge pull request #1064 from jhasse/extra-semi
Remove unnecessary semicolons (-Wextra-semi)
2019-04-17 20:57:59 +02:00
Jan Niklas Hasse
79938b98da Remove unnecessary semicolons (-Wextra-semi) 2019-04-17 15:24:25 +02:00
Gabi Melman
411d588fea
Merge pull request #1058 from mnemotic/cmake-fmt-header-only
Add a CMake option to use a header-only external fmt
2019-04-10 10:24:53 +03:00
Martin Green
7e63d773ef Make header-only external fmt the default 2019-04-10 06:49:57 +03:00
gabime
3e378f009d Fixed build 2019-04-09 16:49:19 +03:00
gabime
13db9d9452 Fix build 2019-04-09 16:46:17 +03:00
gabime
c1c6e6265c Fixed header only build 2019-04-09 16:42:44 +03:00
Martin Green
a984b1b073 Add a CMake option to use a header-only external fmt 2019-04-07 17:29:27 +03:00
gabime
215b6aea95 file_helper.cpp and filename_t fix 2019-04-06 13:45:33 +03:00
gabime
96b7214ae2 fix common.h 2019-04-06 13:13:47 +03:00
gabime
1b0752b0a9 Merge branch 'static-lib' of https://github.com/gabime/spdlog into static-lib 2019-04-06 13:08:30 +03:00
Gabi Melman
02329f61e3
Merge pull request #1057 from martinkrammer/patch-1
Update README.md
2019-04-06 12:58:05 +03:00
gabime
7e29c48379 removed spdlite 2019-04-06 12:57:09 +03:00
Martin Krammer
ad63efdaf7
Update README.md
In order to use basic_logger_mt an additional include is required.
2019-04-06 11:17:11 +02:00
Gabi Melman
6bec53dcd2
Update logger.h 2019-04-06 02:14:08 +03:00
gabime
fef405ac98 Merge branch 'static-lib' of https://github.com/gabime/spdlog into static-lib 2019-04-06 01:44:18 +03:00
gabime
97f9cc4bc0 some cleanup 2019-04-06 01:44:03 +03:00
gabime
7ab6fd9db6 source_loc change line to int 2019-04-06 01:40:53 +03:00
gabime
b7ecec0c23 some cleanup 2019-04-06 01:37:51 +03:00
gabime
d12a858897 some cleanup 2019-04-06 01:37:27 +03:00
gabime
9716ff69c4 added inline statemetns 2019-04-06 01:32:15 +03:00
gabime
4dd1a24d0b wip static lib 2019-04-06 01:25:33 +03:00
gabime
c69c49047b wip static lib 2019-04-06 00:15:14 +03:00
gabime
bfbb4e4050 some err handler cleanup 2019-04-05 23:40:27 +03:00
gabime
2aceb13f3e fix support for utf8 logging under win32 2019-04-05 23:34:55 +03:00
gabime
e9f34fbd26 wip 2019-04-05 23:10:12 +03:00
gabime
17f9cdd401 static lib wip 2019-04-05 23:05:46 +03:00
gabime
156b856a80 static lib wip 2019-04-05 16:57:49 +03:00
gabime
e2e3df9013 static lib wip 2019-04-05 16:44:17 +03:00
gabime
ef8773a89b Moved logger_impl back into logger.h 2019-04-05 13:26:33 +03:00
Gabi Melman
536f5d8203
Merge pull request #1055 from db-panda/v1.x
Fix unexpected log macro expansion.
2019-04-04 17:44:43 +03:00
Daniel Binsmaier
631416d54a Fix missing ';' in log macros 2019-04-04 12:04:53 +02:00
Daniel Binsmaier
d366a06461 Fix unexpected log macro expansion 2019-04-04 09:25:21 +02:00
Gabi Melman
7bf8f14879
Merge pull request #1045 from p-po/v1.x
Namespace qualify stat functions
2019-04-01 02:00:48 +03:00
Ponnuvel Palaniyappan
cd65d6de69 namespace qualify stat functions 2019-03-31 22:05:37 +01:00
gabime
b57d514b1e added missing files 2019-03-30 16:56:37 +03:00
gabime
f36be4d5e4 Moved lite source to folders| 2019-03-30 16:49:02 +03:00
gabime
c2b0e223fa wip lite 2019-03-30 14:53:02 +03:00
gabime
e32c856a04 wip lite 2019-03-30 13:49:54 +03:00
gabime
bc7cd2ccc2 move lite namespace to topelevel spdlite 2019-03-30 10:58:56 +03:00
gabime
1842669104 Merge branch 'lite' of https://github.com/gabime/spdlog into lite 2019-03-29 14:46:54 +03:00
gabime
c7535a91a6 wip lite 2019-03-29 14:46:32 +03:00
gabime
99a5484dfb added header to cmake 2019-03-29 14:46:32 +03:00
gabime
b78ae5ab10 comment 2019-03-29 14:46:32 +03:00
gabime
f74d3e7e94 comment 2019-03-29 14:46:32 +03:00
gabime
eba37e8fbe clone support in lite logger 2019-03-29 14:46:32 +03:00
gabime
84fb11599e Removed default ctor from lite logger 2019-03-29 14:46:32 +03:00
gabime
099812d219 Renamed source file 2019-03-29 14:46:32 +03:00
gabime
c4291510e8 renamed printf 2019-03-29 14:46:32 +03:00
gabime
775a411215 renamed printf 2019-03-29 14:46:32 +03:00
gabime
59b4dd4c46 update example 2019-03-29 14:46:32 +03:00
gabime
2f907e3a92 clang-format 2019-03-29 14:46:32 +03:00
gabime
9971fd2864 Fixed examples 2019-03-29 14:46:32 +03:00
gabime
23a394d1fc moved macros to seprate headers 2019-03-29 14:46:32 +03:00
gabime
91d450df4e Removed source logging 2019-03-29 14:46:32 +03:00
gabime
ea3943a87a added printf syntax support for even faster compilation! 2019-03-29 14:46:32 +03:00
gabime
019eda5b0c wip lite 2019-03-29 14:46:32 +03:00
gabime
5056437ca1 support for const char* messages 2019-03-29 14:46:32 +03:00
gabime
90c912a5e2 wip lite 2019-03-29 14:46:32 +03:00
gabime
9219613957 Dont check level in macros (redundant) 2019-03-29 14:46:32 +03:00
gabime
9858f2e499 renamed 2019-03-29 14:46:31 +03:00
gabime
6b0bf33f8e clang-format 2019-03-29 14:46:31 +03:00
gabime
9ea6079072 wip lite 2019-03-29 14:46:31 +03:00
gabime
478f16234d wip lite 2019-03-29 14:46:31 +03:00
gabime
57a312cb1a lite wip 2019-03-29 14:46:31 +03:00
gabime
bb88a74f92 wip lite 2019-03-29 14:38:40 +03:00
gabime
4a07ce5fae added header to cmake 2019-03-29 13:56:44 +03:00
Gabi Melman
043c4acc7e
Merge pull request #1035 from tt4g/add-public-api-initialize-logger
Add spdlog::initialize_logger
2019-03-25 12:02:31 +02:00
tt4g
eb478e38b2 Add spdlog::initialize_logger 2019-03-25 12:58:55 +09:00
gabime
bf307e24c5 comment 2019-03-24 01:50:56 +02:00
gabime
4a00590a1b comment 2019-03-24 01:44:40 +02:00
gabime
4ccca079a5 clone support in lite logger 2019-03-24 01:40:20 +02:00
gabime
9e5d1b3ba5 Removed default ctor from lite logger 2019-03-24 01:34:21 +02:00
gabime
240f13a0a6 Renamed source file 2019-03-24 01:27:05 +02:00
gabime
221ce33eb5 renamed printf 2019-03-24 01:23:14 +02:00
gabime
722943000e renamed printf 2019-03-24 01:21:07 +02:00
gabime
509a503761 update example 2019-03-24 01:18:05 +02:00
gabime
bac1e4a850 clang-format 2019-03-24 00:41:22 +02:00
gabime
934cc892eb Fixed examples 2019-03-24 00:40:27 +02:00
gabime
b1c90f08cc moved macros to seprate headers 2019-03-24 00:38:00 +02:00
gabime
680f19a424 Removed source logging 2019-03-24 00:31:55 +02:00
gabime
621e0a8330 added printf syntax support for even faster compilation! 2019-03-24 00:30:08 +02:00
gabime
4449bf6f83 wip lite 2019-03-23 23:13:38 +02:00
gabime
569c62e528 support for const char* messages 2019-03-23 20:06:49 +02:00
gabime
4c240edf94 wip lite 2019-03-23 19:34:50 +02:00
gabime
0e977d66c1 Dont check level in macros (redundant) 2019-03-23 19:23:37 +02:00
gabime
3dee10772d renamed 2019-03-23 17:25:50 +02:00
gabime
1d72edcc4f clang-format 2019-03-23 16:39:32 +02:00
gabime
c29b7d22d9 wip lite 2019-03-23 16:39:05 +02:00
gabime
ee502aed49 wip lite 2019-03-23 16:15:58 +02:00
gabime
414ff25564 lite wip 2019-03-23 13:31:57 +02:00
gabime
b084b8b1d8 Cleaned systemd test 2019-03-22 14:16:16 +02:00
gabime
3ca19a8580 fix link to systemd in tests 2019-03-22 14:01:34 +02:00
Gabi Melman
9c12a44d6e
Merge pull request #1027 from WarShoe/v1.x
Add systemd sink.
2019-03-20 17:22:52 +02:00
Alexander Zvyagin
4706b0ada4 Add signature. 2019-03-20 15:32:47 +01:00
Alexander Zvyagin
cc98e9850d Avoid unnecessary conversion of log_msg::payload to std::string. 2019-03-20 15:29:38 +01:00
Alexander Zvyagin
af80db8c22 Add systemd sink. 2019-03-14 16:20:58 +01:00
Gabi Melman
053d5ad24d
Update README.md 2019-03-11 19:19:36 +02:00
Gabi Melman
e2805ac68a
Merge pull request #1022 from floouuu/v1.x
Expose should_do_colors_ in ansicolor_sink.h
2019-03-11 19:12:03 +02:00
Florian Wörter
1caf05cc52 Renamed exposed method. [#1004] 2019-03-11 14:15:58 +01:00
Florian Wörter
63cfb7db25 Exposed should_do_colors_ in ansicolor_sink.h. [#1004] 2019-03-11 14:12:26 +01:00
Gabi Melman
bdfc7d2a5a
Merge pull request #996 from MFornander/v1.x
Add tweak support for user short level names
2019-02-18 23:59:15 +02:00
Mattias Fornander
0ccbdcdd1f Add tweak support for user short level names 2019-02-18 14:33:41 -07:00
Gabi Melman
c598b2fa2d
Merge pull request #994 from romainthomas/fix/README
Fix typo in Android logger
2019-02-13 11:51:28 +02:00
Romain Thomas
4f86448bd4 Fix typo in Android logger 2019-02-13 09:19:29 +01:00
Gabi Melman
d235e7d46f
Fix #992 2019-02-08 12:14:17 +02:00
Gabi Melman
e25b323d1b
Merge pull request #990 from mnemotic/cmake-conditional-install
Add CMake option for conditional installation
2019-02-07 21:20:44 +02:00
Gabi Melman
42093c48b2
Merge pull request #988 from DanielChabrowski/remove-log-func
Remove unnecessary log function
2019-02-07 21:15:02 +02:00
Martin Green
9fca0b20f0 Add CMake option for conditional installation 2019-02-06 07:38:26 +02:00
DanielChabrowski
a6229d9e87 Remove pointless log with enable_if 2019-02-06 05:24:25 +01:00
Gabi Melman
c443896644
Merge pull request #986 from DanielChabrowski/sink-allow-custom-formatter
Allow custom formatter in sink's ctor
2019-02-03 19:50:22 +02:00
DanielChabrowski
79f11bd655 Allow custom formatter in sink ctor 2019-02-03 16:49:29 +01:00
Gabi Melman
c5552dac1f
Merge pull request #985 from FrancoisChabot/v1.x
Allow the inclusion of an external fmtlib as as sub_directory
2019-02-01 22:33:05 +02:00
Francois Chabot
734af31c13
Allow the inclusion of an external fmtlib as as sub_directory 2019-02-01 12:12:58 -05:00
Gabi Melman
2d96896fae
Merge pull request #984 from ZGCDDoo/shadowed_parameter
Shadowed parameter
2019-02-01 17:34:08 +02:00
charles-david
20a0f82701 Renamed input parameters to "params_in". 2019-02-01 07:59:50 -05:00
charles-david
e4b7dbce7f CMakeLists.txt same as v1.x branch. 2019-01-31 23:05:38 -05:00
charles-david
0f128fd561 Warning for shadowed parameter corrected in common.h
However, not in bundled fmt. Corrects compiling with basic logger with header only and -Werror.
2019-01-31 22:47:02 -05:00
Gabi Melman
ac8a7bc12d
Merge pull request #981 from ksergey/cmake-fix
CMAKE_BINARY_DIR -> CMAKE_CURRENT_BINARY_DIR
2019-01-28 12:10:49 +02:00
Sergey Kovalevich
90a299f424 CMAKE_BINARY_DIR -> CMAKE_CURRENT_BINARY_DIR 2019-01-28 11:48:45 +03:00
Gabi Melman
00a7f5d75d
Update README.md 2019-01-27 19:10:34 +02:00
Gabi Melman
2463fe92bd
Merge pull request #958 from pwm1234/pwm1234/rotate_on_open
Pwm1234/rotate on open
2019-01-24 18:23:48 +02:00
Philip Miller
4f65fcd7b1 remove minor optimization for the sake of simplicity 2019-01-24 09:19:52 -05:00
Philip Miller
e41b92c55a fix inadvertent rename to original test function 2019-01-24 00:13:14 -05:00
Philip Miller
3925f8fa16 streamline constructor logic
and improve test for rotate_on_open=true
2019-01-24 00:06:15 -05:00
Philip Miller
cce1e36e26 Merge remote-tracking branch 'origin/v1.x' into pwm1234/rotate_on_open 2019-01-23 21:44:27 -05:00
Gabi Melman
3466c9c8cb
Merge pull request #978 from markniebur/file-sink-filename-method
Add method to filesinks to return filename
2019-01-23 23:07:57 +02:00
Mark Niebur
6e2dadc63a Add method to filesinks to return filename 2019-01-23 11:35:55 -07:00
Gabi Melman
00e89a23f6
Merge pull request #977 from Myz/cmake-baseline-configuration-without-google-benchmark
Disable building benchmarks by default
2019-01-23 12:00:36 +02:00
Pius Raeder
a29e518cfe Disable building benchmarks by default
Building the benchmarks requires google-benchmark to be installed which is
not the case for most of the build systems. The option now has a tiny
hint what the requirement is and where to get it.

closes #975
2019-01-23 10:03:03 +01:00
gabime
a7148b718e Version 1.3.1 2019-01-18 12:13:07 +02:00
gabime
23fdc0eae4 Fixed issue #959 2019-01-17 17:09:35 +02:00
Gabi Melman
8cb1bc89f1
Merge pull request #969 from scribam/patch-1
Update log_msg.h
2019-01-17 03:18:36 +02:00
scribam
1798a1fa12
Update log_msg.h
`SPDLOG_NO_THREAD_ID` should only affect thread retrieval.
2019-01-17 00:23:06 +01:00
Gabi Melman
f4c737ef42
Merge pull request #962 from myd7349/bench-patch
Fix #961 benchmark link error
2019-01-14 15:53:28 +02:00
myd7349
611df4964d Fix #961 benchmark link error 2019-01-14 20:18:35 +08:00
Gabi Melman
0a4ccf22da
Update README.md 2019-01-14 11:39:35 +02:00
Philip Miller
4fe98bf6e6 Merge remote-tracking branch 'origin/v1.x' into pwm1234/rotate_on_open 2019-01-11 10:04:42 -05:00
gabime
57c3023881 Moved SPDLOG_FUNCTION define to common.h 2019-01-10 19:18:31 +02:00
gabime
4408e079ff Refactored log macros 2019-01-10 17:04:27 +02:00
gabime
2991057aef Add check log level before evaluating the logging macros 2019-01-10 16:45:06 +02:00
gabime
6b4fea39ab clang-format 2019-01-10 16:31:06 +02:00
Gabi Melman
a08ffcff50
Merge pull request #956 from possiblyhuman/v1.x-macrochanges
Allow filename/line number at all levels. Add function name %! support.
2019-01-10 02:15:50 +02:00
possiblyhuman
6bd9f4a13a Merge branch 'v1.x' into v1.x-macrochanges 2019-01-09 21:38:33 +00:00
possiblyhuman
32420b77c8 Reduced amount of macros used.
Removed SPDLOG_SOURCE_MACROS_ON and SPDLOG_FUNCTION_SUFFIX.
2019-01-09 21:15:19 +00:00
Gabi Melman
0b8a84f536
Update README.md 2019-01-09 15:56:05 +02:00
gabime
f18a55831c Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2019-01-09 11:28:36 +02:00
gabime
58fb0decbf Removed old header 2019-01-09 11:28:22 +02:00
possiblyhuman
2124b7bf64 Allow filename/line number at all levels. Add function name %! support. 2019-01-08 22:52:40 +00:00
Gabi Melman
5b273a33b4
Merge pull request #955 from brridder/fix-typo
Fix typo in file_helper.h
2019-01-08 20:36:06 +02:00
Ben Ridder
fb702f989f Fix typo in file_helper.h
* "extenstion" -> "extension"
2019-01-08 10:09:11 -08:00
gabime
0203a0fdaf Fixed issue #948 2019-01-08 17:35:34 +02:00
gabime
112a7ada74 Fixd copy ellision warning in tests 2019-01-08 17:33:31 +02:00
gabime
452ba76507 Fixed conversion warnings 2019-01-08 17:31:46 +02:00
gabime
2ac42c0d14 Bumped fmt to version 5.3.0 2019-01-08 17:09:07 +02:00
Gabi Melman
0955ea5b85
Merge pull request #945 from cneumann/fix-external-fmt
Fix handling of external fmt lib
2018-12-17 19:34:49 +02:00
Carsten Neumann
084bc72d90 Fix handling of external fmt lib
Using an external fmt lib should cause the spdlog::spdlog target to have
a dependency on fmt lib - so that a consuming project does not need
to call find_package(fmt) and target_link_libraries(... fmt::fmt).

To this end a new cmake option SPDLOG_FMT_EXTERNAL is introduced which
makes spdlog depend on fmt lib and defines the SPDLOG_FMT_EXTERNAL macro
to avoid using the bundled fmt lib. The value of SPDLOG_FMT_EXTERNAL is
also stored in the installed spdlogConfig.cmake and if it is ON
find_dependency() is used to ensure the fmt::fmt target is imported.
2018-12-17 10:18:16 -06:00
Gabi Melman
57e2193432
Merge pull request #939 from peergynt/fix-typos
Fix typos
2018-12-06 23:21:22 +02:00
Jerome Meyer
ce8cf1e152 Fix typos 2018-12-06 16:06:01 -05:00
gabime
3da189f7c0 SPDLOG_TRACE to check log level before calling the logger 2018-12-06 13:27:00 +02:00
gabime
058d2d1bd4 Use default pattern in latency test 2018-12-06 11:37:49 +02:00
Gabi Melman
f70f2f8c62
Merge pull request #936 from bzindovic/v1.x
Corrected the text alignment in the example
2018-12-06 03:22:21 +02:00
Budo Zindovic
8d6086da48
Corrected the text alignment in the example
I've changed the alignment character in the example to illustrate left alignment of text.
2018-12-06 01:30:07 +01:00
gabime
bd6d88b884 Removed uneeded locale include 2018-12-05 18:03:56 +02:00
gabime
4003218ceb Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2018-12-04 12:29:01 +02:00
gabime
ec3f2b76b0 Strip path from __FILE__ in SPDLOG_TRACE macros 2018-12-04 12:28:21 +02:00
gabime
fcb661d0e9 Fixed tests 2018-12-02 19:04:44 +02:00
gabime
d8eb0558e9 Fix test for mingw 2018-12-02 17:13:50 +02:00
Gabi Melman
5191948b64
Update appveyor.yml 2018-12-02 16:40:02 +02:00
Gabi Melman
7442d720f4
Update appveyor.yml 2018-12-02 16:30:07 +02:00
Gabi Melman
bbc859ca19
Update .travis.yml 2018-12-02 15:25:03 +02:00
gabime
7275fb6f52 simplify SPDLOG_BUILD_TESTS Cmake option 2018-12-02 12:25:46 +02:00
Gabi Melman
2d50202b2d
Merge pull request #934 from dpacbach/ctest-fix
CMake: include(CTest) only when building tests.
2018-12-02 13:49:50 +02:00
David P. Sicilia
f5dc16603e Enable testing in the Travis config file.
This is needed because ENABLE_TESTING is no longer enabled by
default.
2018-12-01 20:57:45 -05:00
David P. Sicilia
85b4d7c8d6 CMake: include(CTest) only when building tests.
This is needed in order to support usage of this library as a
subdirectory in a parent project.  In that situation, prior
to this change, the inclusion of CTest would unconditionally
enable BUILD_TESTING which would then bleed into other parts
of the project.

Also added some comments explaining how this logic works.
2018-12-01 20:37:06 -05:00
gabime
f0c962d274 source_loc ctor: brace init members 2018-11-29 12:55:14 +02:00
Gabi Melman
486b6937d3
Merge pull request #929 from dpacbach/warnings-fix
Fix some minor warnings found with a recent clang version
2018-11-28 07:59:32 +02:00
David P. Sicilia
a6152ebadd Make an implicit cast from int --> uint32_t explicit.
Perhaps this casting should not happen to begin with, but better
to make it explicit where it is happening for readability.  This
fixes a compiler warning.
2018-11-27 20:24:21 -05:00
David P. Sicilia
63a475d88c Do not attempt to default operator= when it is implicitly deleted 2018-11-27 20:23:51 -05:00
Gabi Melman
3eba3224c8
Merge pull request #926 from lestera/patch-1
Fix exceptions on file size calculation on Windows XP x64 and Windows Server 2003 x64
2018-11-27 16:08:30 +02:00
Adi Lester
247c4e55e7
Update os.h 2018-11-27 14:39:41 +02:00
Adi Lester
26d7c27bee
Use _filelengthi64 instead of _fstat64 to calculate file size on x64 machines
For some reason, `_fstat64` fails with errno 22 on Windows Server 2003 x64 when compiled using the `v141_xp` toolset.
Using `_filelengthi64` instead solves this issue
2018-11-27 14:16:25 +02:00
Gabi Melman
b492642282
Update fmt_helper.h 2018-11-27 11:37:09 +02:00
gabime
cff78f5833 Move logging macros outside the spdlog namespace 2018-11-25 11:20:27 +02:00
gabime
4ba19821ce Fixed compilation for vs2013 2018-11-25 10:54:06 +02:00
gabime
1e385851d7 Removed padding from from bench_formatters/all 2018-11-25 01:12:12 +02:00
gabime
4643f74a03 Added the all flag to bench formatter 2018-11-25 00:46:24 +02:00
gabime
6453d396bf Added the all flag to bench formatter 2018-11-25 00:45:43 +02:00
gabime
92921f767e clang-format 2018-11-25 00:44:51 +02:00
gabime
c251c4ccbb Added the all flag to bench formatter 2018-11-25 00:44:27 +02:00
gabime
0ce670e45a Store level names as string_views 2018-11-25 00:36:14 +02:00
gabime
2671b48a6c Minor performance fix in full formatter 2018-11-24 23:57:39 +02:00
gabime
382478259f Fix compilation for msvc 2015 2018-11-24 18:27:27 +02:00
gabime
e3c333be47 pattern_formatter - padding_info small refactor 2018-11-24 18:21:25 +02:00
gabime
a1a463787f Updated example's comment 2018-11-24 18:15:24 +02:00
gabime
a16ff07a06 Show source location if present in default formatter 2018-11-24 18:00:56 +02:00
gabime
3218caf34a Added some comments 2018-11-24 17:34:33 +02:00
gabime
01583ef540 Clean macros 2018-11-24 17:15:58 +02:00
gabime
dc13700094 Fixed source location and make SPDLOG_TRACE: that only one that inject source location info. 2018-11-24 17:08:13 +02:00
Gabi Melman
1293af093c
call flush_() instead of flush() from looger::sink_it_() 2018-11-24 11:11:03 +02:00
gabime
2998815166 Added missing test file 2018-11-22 21:35:11 +02:00
gabime
9484c4dc05 clang-format 2018-11-22 19:18:43 +02:00
gabime
521b0733d4 Support for source location in async loggers 2018-11-22 19:17:41 +02:00
gabime
a463989278 keep clang-tidy happy 2018-11-22 18:50:56 +02:00
gabime
a31719b546 clang-format 2018-11-22 18:49:14 +02:00
gabime
f97cb00737 Updated macros tests 2018-11-22 18:48:32 +02:00
gabime
f2305fe5bf Support for source file/line logging 2018-11-22 18:47:50 +02:00
gabime
216cd6935f Updated formatter-bench to include source location 2018-11-22 17:05:27 +02:00
gabime
3a8f9484d2 Cleaned bench.cpp a little 2018-11-22 16:58:20 +02:00
gabime
3fa76b2d8f Renamed test filename 2018-11-22 12:31:16 +02:00
gabime
50648553cf clang-format 2018-11-21 16:02:02 +02:00
gabime
70d03fd9c3 Minor optimization 2018-11-21 16:01:28 +02:00
gabime
0a8cce6984 comments 2018-11-21 14:21:26 +02:00
gabime
fb1a3a3a12 Micro optimized some formatter flags 2018-11-20 15:40:51 +02:00
gabime
52e2722412 Renamed test filenames 2018-11-20 12:14:21 +02:00
Gabi Melman
b64e4464a7
Update current_size_ to 0 in after of truncating in rotation error 2018-11-20 10:26:10 +02:00
Gabi Melman
f1ab6feba2
Merge pull request #919 from DanielChabrowski/fix-compilation
Fix template error
2018-11-19 20:02:24 +02:00
Daniel Chabrowski
e751461ff1 Fix template error 2018-11-19 18:59:17 +01:00
Gabi Melman
c7f42d1a4a
Merge pull request #917 from DanielChabrowski/fix-xcode-ci
Fix osx build
2018-11-19 19:39:59 +02:00
Daniel Chabrowski
6232ec78f7 Change count_digits to depend on template param, not size_t 2018-11-19 18:34:52 +01:00
Daniel Chabrowski
f09d0f2301 Add helper for count_digits 2018-11-19 18:12:50 +01:00
Daniel Chabrowski
14a071c478 Fix osx build 2018-11-19 02:54:02 +01:00
gabime
e601ebe19b Updated formatter-bench 2018-11-16 14:13:29 +02:00
gabime
7068c45115 Fixed issue #908 2018-11-16 13:28:34 +02:00
gabime
3bfcb0468e clang-format 2018-11-16 12:56:57 +02:00
gabime
b2735eb30c Fixed fmt_helper tests 2018-11-16 12:56:36 +02:00
gabime
552416bda4 fmt_helper cleanup 2018-11-16 12:55:19 +02:00
gabime
b522413085 Replaced SPDLOG_DISABLE_TID_CACHING with SPDLOG_NO_TLS 2018-11-16 10:07:31 +02:00
gabime
8a0fc92f20 Replaced SPDLOG_DISABLE_TID_CACHING with SPDLOG_NO_TLS 2018-11-15 16:42:42 +02:00
gabime
4a34cd0662 Optimized nano seconds formatting 2018-11-12 16:44:34 +02:00
gabime
11d83515dd Added formatter becnhmarks 2018-11-12 16:13:52 +02:00
gabime
7ce8ae72e8 Added test of pattern_formatter::clone() 2018-11-12 16:04:35 +02:00
gabime
cc7e122915 Added test of pattern_formatter::clone() 2018-11-12 16:04:09 +02:00
gabime
da84893921 Added test of pattern_formatter::clone() 2018-11-12 16:00:32 +02:00
gabime
1d5b6d7ae6 Added test of pattern_formatter::clone() 2018-11-12 15:59:03 +02:00
gabime
314991ac60 Fixed pattern formatter constructor bug 2018-11-12 12:46:07 +02:00
gabime
9b5b4cd505 comment 2018-11-12 12:12:33 +02:00
gabime
c5069135d7 Improved compile time level support 2018-11-12 12:01:10 +02:00
gabime
971c1f46b0 Updated latency tests 2018-11-12 11:07:51 +02:00
gabime
34c60e5486 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2018-11-12 10:44:43 +02:00
gabime
526f21ae7f Fixed #902 2018-11-12 10:39:34 +02:00
gabime
48597a94e8 Updated example 2018-11-11 18:20:53 +02:00
gabime
0e77c3391b New compile time API using SPDLOG_ACTIVE_LEVEL 2018-11-11 18:15:24 +02:00
Gabi Melman
f1e79bde2e
Update pattern_formatter.h 2018-11-11 02:27:03 +02:00
gabime
7b6849578b Fixed some clang-tidy warnings 2018-11-11 01:53:51 +02:00
gabime
617fcc92cf clang-format 2018-11-11 01:48:50 +02:00
gabime
18f0e4ba1a Added some pattern-formatter padding tests 2018-11-11 01:43:40 +02:00
gabime
6fedffe6d6 Moved the SPDLOG_CATCH_AND_HANDLE to logger_impl.h 2018-11-11 01:33:08 +02:00
gabime
d54e302a28 clang-format 2018-11-11 01:26:57 +02:00
gabime
d99179f822 Small refactoring to registry class 2018-11-11 01:26:22 +02:00
gabime
a6fbb3ef4c Minor fix to test 2018-11-11 01:25:17 +02:00
gabime
65cff673b8 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2018-11-11 01:19:13 +02:00
gabime
dc166cad92 Added default pattern support for pattern_formatter to avoid parsing pattern when using default pattern 2018-11-11 01:18:57 +02:00
gabime
7d7ccac416 Updated bench cmake 2018-11-11 01:17:14 +02:00
gabime
e933c5f481 Fixed example 2018-11-11 01:11:09 +02:00
gabime
2ba4b23b85 added padder bench 2018-11-11 00:52:21 +02:00
gabime
ba4ed0eb7f micro optimize scoped_padder 2018-11-11 00:48:25 +02:00
gabime
3cdf2b7f04 micro optimize scoped_padder 2018-11-11 00:31:14 +02:00
Gabi Melman
99b68c8352
Merge pull request #892 from pabloariasal/disable_global_logger_registration
Global option that disables global registration of loggers
2018-11-10 19:46:45 +02:00
Pablo Arias
a446f187c1 Fixed deadlock by recursive mutex 2018-11-10 17:38:23 +01:00
gabime
3ff541cf77 Optimized scoped_pad 2018-11-10 18:03:11 +02:00
Pablo Arias
10895796b2 Added mutexes to protect logger initialization and toggling automatic registration 2018-11-10 16:55:35 +01:00
Pablo Arias
fbc58ebef8 * using API call instead of macro for toggling automatic registration
* added unit test for disabling automatic registration
2018-11-10 14:34:04 +01:00
gabime
5c54414be7 Padding support in pattern formatter 2018-11-09 15:18:45 +02:00
gabime
4df28728e2 clang-format 2018-11-09 14:56:48 +02:00
Gabi Melman
f14a4c0b18
Merge pull request #893 from ZaMaZaN4iK/ZaMaZaN4iK-patch-1
Fix typo in Android example
2018-11-07 11:05:22 +02:00
Alexander Zaitsev
f5a27250b1
Fix typo in Android example 2018-11-05 03:04:22 +03:00
Pablo Arias
f95b189fe3 Added a global option in tweakme.h that disabled global registration of
loggers. fixes #712
2018-11-04 20:12:42 +01:00
Gabi Melman
1aace95c8d
Update periodic_worker.h 2018-11-02 17:53:27 +02:00
Gabi Melman
7844471971
Merge pull request #890 from rwen2012/v1.x
change the log_msg&& to log_msg&
2018-10-31 07:33:31 +02:00
rwen2012
794a636dd3 change the log_msg&& to log_msg& 2018-10-31 11:01:28 +08:00
gabime
e35414a0f1 Removed redundant casts to string_view 2018-10-30 01:23:17 +02:00
gabime
0d0706a204 Small fix to pattern formatter 2018-10-30 01:14:42 +02:00
gabime
80f19324bc Small update to async bench 2018-10-30 01:08:32 +02:00
gabime
1b04c222cf Fixed issue #888 2018-10-30 00:54:22 +02:00
gabime
5d04848886 Updated latency Makefile 2018-10-30 00:11:29 +02:00
gabime
fc14e831eb Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2018-10-30 00:08:58 +02:00
gabime
04d577262a Updated latency tests 2018-10-30 00:08:49 +02:00
Gabi Melman
7be3d2afe9
Update appveyor.yml 2018-10-29 23:58:19 +02:00
Gabi Melman
d1237d8984
Merge pull request #887 from peergynt/peergynt-cleanup
Cleanup header file: remove log_msg.h include from fmt_helper.h
2018-10-29 19:18:04 +02:00
Jerome Meyer
1b391ccd06 Cleanup header file: remove log_msg.h include from fmt_helper.h 2018-10-29 09:55:41 -04:00
gabime
7377bfcf07 Updated latency makefile 2018-10-26 18:59:00 +03:00
gabime
665b708e6e Update cmake 2018-10-26 18:57:53 +03:00
gabime
f87049370f latency test update 2018-10-26 18:57:34 +03:00
gabime
47948a34dd latency using google-benchmark 2018-10-26 16:34:14 +03:00
gabime
121a7dcedf Use google benchmark to test latency 2018-10-24 22:31:50 +03:00
gabime
240a58fd6e Fixed issue #881 2018-10-24 08:47:02 +03:00
gabime
99e23b41eb use static_cast<string_view> instead of ctor in logger impl 2018-10-22 00:47:51 +03:00
gabime
cadb3d7da2 Fixed test 2018-10-22 00:14:07 +03:00
gabime
392d126372 Renamed string_view_type -> string_view_t 2018-10-21 23:50:07 +03:00
gabime
871cca2401 Fixed pattern formatter 2018-10-21 23:48:11 +03:00
gabime
1bdd556d3b code formatting 2018-10-21 23:23:40 +03:00
gabime
9daad800a8 Fix mingw compilation 2018-10-21 19:26:11 +03:00
gabime
8d2c956563 Optimize log(const T&) if can be statically converted to string_view 2018-10-21 19:04:55 +03:00
gabime
0584d6d89b Removed logn declaration 2018-10-21 18:38:37 +03:00
gabime
5763733490 Fix sdk version in msvc example 2018-10-21 12:49:04 +03:00
gabime
894438d5fb Better support for string_view 2018-10-21 12:46:58 +03:00
Gabi Melman
2ad191aeba
Update log_msg.h 2018-10-20 18:27:58 +03:00
gabime
dd9d7e62d5 bench C-string title 2018-10-19 17:16:51 +03:00
gabime
4e3e80109a Code formatting 2018-10-19 17:12:35 +03:00
gabime
70bef682b0 Fixed clang-tidy warning about implicit conversion to string_view 2018-10-19 17:12:02 +03:00
gabime
c2a9bf9974 Small refactoring and support wchar again 2018-10-19 16:48:22 +03:00
gabime
23da9f13b0 Fixed valgrind warning in example 2018-10-19 16:31:43 +03:00
gabime
a5a39c52b0 Added nullptr check to append_string_view 2018-10-19 02:45:35 +03:00
gabime
6355e9895d Major change to log_msg - contain only string_view instead of buffer 2018-10-19 02:15:50 +03:00
gabime
abf4af2645 Merge branch 'sized_buf' of https://github.com/peergynt/spdlog into peergynt-sized_buf 2018-10-18 23:29:42 +03:00
Jerome Meyer
cb71fea0f6 Use fmt::string_view when logging a C string to avoid unnecessary copy 2018-10-18 11:04:20 -04:00
gabime
3e2d593dde always initialize level and thread_id in log_msg 2018-10-18 11:18:02 +03:00
gabime
4b66e94ecf Code formatting 2018-10-16 19:32:12 +03:00
gabime
40143cae1e async-bech to use spdlog for output 2018-10-16 19:31:25 +03:00
gabime
b1277caeeb Typo 2018-10-16 19:30:38 +03:00
gabime
13cc6478fb Bench: eat our own dog food 2018-10-16 16:11:28 +03:00
gabime
c465250c21 Fixed clang-tidy warning (added move) 2018-10-16 14:39:29 +03:00
gabime
815b52b8fb Fixed implicit conversion to str in c_formatter 2018-10-16 00:12:54 +03:00
gabime
275167d1b0 Micro optimize eol in formatter 2018-10-15 16:22:00 +03:00
gabime
45717147f7 Improved null_logger factory 2018-10-13 20:01:05 +03:00
gabime
f2f9f324ec Updated default API impl and tests 2018-10-13 19:23:11 +03:00
gabime
8131d3e127 Added SPDLOG_DISABLE_DEFAULT_LOGGER option to tweakme.h 2018-10-12 03:21:21 +03:00
gabime
226d5a1d36 Added SPDLOG_DISABLE_DEFAULT_LOGGER option to tweakme.h 2018-10-12 03:17:51 +03:00
gabime
312fe4775d Added SPDLOG_DISABLE_DEFAULT_LOGGER option to tweakme.h 2018-10-12 03:16:22 +03:00
gabime
b368d18b0f Added default logger API 2018-10-12 03:04:55 +03:00
gabime
8e4996baf4 Replaced constexpr with SPDLOG_CONSTEXPR 2018-10-12 01:32:21 +03:00
gabime
b7cd502054 Removed redundant file 2018-10-12 01:25:11 +03:00
gabime
53ac379bc5 Removed extra whitespace from SDPLOG_TRACE message 2018-10-11 19:14:02 +03:00
Gabi Melman
10e809cf64
Merge pull request #864 from DimRochette/v1.x
fix namespace of make_unique
2018-10-10 12:58:46 +03:00
DimRochette
3079551d30
fix namespace of make_unique 2018-10-10 11:23:25 +02:00
gabime
f4c5c5a367 Replaced noexcept with SPDLOG_NOEXCEPT 2018-10-10 01:01:37 +03:00
gabime
2a7b995723 Added noexcept some function in common.h 2018-10-10 00:57:16 +03:00
gabime
d0beac70bd Removed dead code from os.h 2018-10-10 00:29:34 +03:00
gabime
cbf66ac653 Removed dead code from os.h 2018-10-10 00:29:21 +03:00
gabime
98f9cb8c1f Added noexcept to most of details::os functions 2018-10-10 00:26:52 +03:00
Gabi Melman
8bd4c87d2f
Merge pull request #856 from ulvgard/cmake_android_log_dependency
Add dependency to Android's log target in CMake
2018-10-08 12:12:29 +03:00
Gabi Melman
c88b568685
Update example.cpp 2018-10-08 01:46:01 +03:00
gabime
c83c9a3193 Version 1.2.0 2018-10-07 22:31:36 +03:00
Gabi Melman
410c46f1ab
Update README.md 2018-10-06 15:38:26 +03:00
gabime
1b8bf35acc Micro optimize: don't init log_msg.msg_id on construction. It will be set anyway later 2018-10-06 01:49:34 +03:00
gabime
aa47ac85c9 add constexpr to hex chars 2018-10-05 23:23:09 +03:00
gabime
3eadda9466 code formating 2018-10-05 15:21:05 +03:00
gabime
dea6a7c217 Tests: Fixed some clang-tidy warnings 2018-10-05 15:20:14 +03:00
gabime
887a104dd0 Fixed clang-tidy warning 2018-10-05 15:19:03 +03:00
gabime
1808e3c4c8 Fixed bug in async_bench 2018-10-05 14:52:38 +03:00
gabime
1f4cae4bf7 Changed forward<log_msg> to std::move(log_msg) in thread pool 2018-10-05 14:50:30 +03:00
gabime
3b009f5aa6 Changed forward<worker_ptr> to std::move in async logger 2018-10-05 14:33:53 +03:00
gabime
36112371c0 Reverted const qualifier to log_msg& args, fixed issue #849, and added counter tests 2018-10-05 14:23:37 +03:00
gabime
2fa538779f Fixed static_assert 2018-10-04 02:20:47 +03:00
gabime
b7a6659451 code formatting 2018-10-04 02:10:46 +03:00
gabime
102c31a04c Accecpt iterators by value in logger ctor insted of ref 2018-10-04 02:06:39 +03:00
Tobias Ulvgard
f01da91abf Add dependency to Android's log target in CMake 2018-10-03 10:10:37 +02:00
gabime
10000c383a Better error message if WideCharToMultiByte fails 2018-10-03 00:26:58 +03:00
gabime
8b42b7d269 Fix support for wchar to utf8 under windows (fix issue #851 and #764) 2018-10-02 18:27:49 +03:00
gabime
17702969fa Upgrded to fmt version 5.2.1 2018-10-02 16:14:39 +03:00
Gabi Melman
cc3613e012
Update README.md 2018-10-02 15:24:43 +03:00
Gabi Melman
0258418a99
Merge pull request #853 from blackball/v1.x
return nothing if it's a void function.
2018-10-02 15:22:58 +03:00
Hui
397c2a934f
Merge pull request #1 from blackball/blackball-patch-1
Fix return type in README file.
2018-10-02 19:22:02 +08:00
Hui
796986f38c
Fix return type in README file.
void function should not return 1.
2018-10-02 19:21:41 +08:00
Gabi Melman
c5011181bb
Update log_msg.h 2018-10-01 14:27:43 +03:00
gabime
dace099348 Added fmt_helper tests 2018-09-28 01:30:29 +03:00
gabime
0876e39c4f pad3 small optimization 2018-09-28 01:27:37 +03:00
gabime
0b516733db user buffer.clear() insread of resize(0) 2018-09-27 17:08:21 +03:00
Gabi Melman
e15deead32
Update README.md 2018-09-27 03:59:43 +03:00
gabime
18df6138a7 clang-format 2018-09-27 02:03:12 +03:00
gabime
8c125ed009 Added clang-tidy script 2018-09-27 02:02:13 +03:00
gabime
4720b703f4 Fixed clang-tidy warnings 2018-09-27 01:58:39 +03:00
gabime
cd8e15dcd1 Fixed clang-tidy warnings 2018-09-27 01:39:26 +03:00
gabime
a06d32ae19 Fixed clang-tidy warnings 2018-09-27 01:14:35 +03:00
gabime
7af3f014af Fixed clang-tidy warning 2018-09-27 00:59:28 +03:00
gabime
8e80081f99 Fixed clang-tidy warning 2018-09-27 00:56:19 +03:00
gabime
14c0417f3e Fixed clang-tidy warning 2018-09-27 00:47:09 +03:00
gabime
0879dea444 Fixed clang-tidy warning 2018-09-27 00:39:17 +03:00
gabime
a8c4aef6bd fix typo 2018-09-26 23:50:47 +03:00
gabime
669a66f18a format 2018-09-26 23:48:59 +03:00
gabime
e8dae26176 Moved spdlog::make_unique to spdlog::details::make_unique and prevent T to be array 2018-09-26 23:48:36 +03:00
gabime
e3a66473b2 Small cleanup in set_formatter 2018-09-26 15:53:54 +03:00
gabime
7704e41336 Fixed issue #833 2018-09-26 15:43:23 +03:00
gabime
a74bbe7381 base_sink default ctor 2018-09-26 15:41:57 +03:00
gabime
729ec21629 Added virtual protected functions to base_sink 2018-09-26 15:29:19 +03:00
gabime
b393715bee Added virtual protected functions to base_sink 2018-09-26 15:27:48 +03:00
gabime
5ec4e60424 Replaced SPDLOG_FINAL macro with final 2018-09-26 15:26:34 +03:00
gabime
5cd24f3033 Replaced SPDLOG_FINAL macro with final 2018-09-26 15:26:27 +03:00
gabime
27a03c5cec Replaced SPDLOG_FINAL macro with final 2018-09-26 15:24:22 +03:00
gabime
5d34d21f40 Fixed issue #842 in tests 2018-09-26 14:45:57 +03:00
gabime
ca8accbaa8 Replaced SPDLOG_FINAL macro with final 2018-09-26 14:45:38 +03:00
gabime
65defd3806 Replaced SPDLOG_FINAL macro with final 2018-09-26 14:33:37 +03:00
Gabi Melman
be7e7237e9
Update README.md 2018-09-25 01:51:03 +03:00
gabime
234cb2dfba Updated becnhmark info 2018-09-25 01:43:05 +03:00
Gabi Melman
b922ae0fb8
Update README.md 2018-09-25 01:26:17 +03:00
gabime
8649fb5118 Added binary logging example 2018-09-25 01:25:10 +03:00
Gabi Melman
a4bae6aba9
Update bench.cpp 2018-09-25 01:22:28 +03:00
gabime
808bc1f4ed clang format 2018-09-25 01:11:36 +03:00
gabime
41d879e292 Added support for binary logging using to_hex(..) 2018-09-25 01:03:57 +03:00
Gabi Melman
2e7b3cae2a
Update bench.cpp 2018-09-21 11:22:57 +03:00
gabime
a0ae62a733 format.sh 2018-09-18 00:19:16 +03:00
gabime
06eb69b93a format.sh 2018-09-18 00:18:22 +03:00
gabime
7025ff4280 format.sh don't format bundled src 2018-09-18 00:16:13 +03:00
gabime
2fa7410c0e Improve rotating sink error handling 2018-09-18 00:09:58 +03:00
gabime
3771d12992 Upgraded to fmt ver 5.2.0 2018-09-17 14:40:52 +03:00
Gabi Melman
f4ac67ae1c
Merge pull request #837 from myrgy/missing_include_ansicolor_sing
ansicolor_sink.h - add missing sink include
2018-09-17 12:50:17 +03:00
Alexander Dalshov
d48d6939c2 ansicolor_sink.h - add missing sink include 2018-09-17 11:26:40 +03:00
Gabi Melman
188cff7d65
Merge pull request #831 from taketwo/fix-830
Change the default value for SPDLOG_BUILD_xxx
2018-09-12 23:33:36 +03:00
Sergey Alexandrov
75925762e8
Change the default value for SPDLOG_BUILD_xxx
The value based on whether spdlog is used as a third-party dependency or
as a standalone project. If spdlog is included through add_subdirectory,
the tests/examples/benchmarsk are disabled by default, and if spdlog is
configured standalone, then they are enabled by default.
2018-09-12 16:11:45 -04:00
Gabi Melman
f2ac7d730c
Update README.md 2018-09-07 02:12:28 +03:00
Gabi Melman
c5c1c5458b
Update README.md 2018-09-07 02:09:13 +03:00
Gabi Melman
1649597eae
Update README.md 2018-09-07 02:07:25 +03:00
Philip Miller
22f85deb2c Merge remote-tracking branch 'origin/v1.x' into pwm1234/rotate_on_open 2018-09-06 11:40:46 -04:00
Gabi Melman
1cb49bfe72
Merge pull request #824 from gabime/revert-822-patch-1
Revert "Add `conda` to package managers in README"
2018-09-06 13:31:09 +03:00
Gabi Melman
1aa4b657d6
Revert "Add conda to package managers in README" 2018-09-06 13:30:25 +03:00
Philip Miller
52a01b2cf2 add argument to rotating file sink for rotate_on_open
when true, the log file will be rotated when it is opened so the newly constructed file will start off being empty
2018-09-06 02:47:48 -04:00
Gabi Melman
d803e7003f
Merge pull request #822 from epruesse/patch-1
Add `conda` to package managers in README
2018-09-06 06:02:45 +03:00
Elmar Pruesse
18efcd62ff
Add conda to package managers in README 2018-09-05 19:25:11 -06:00
Gabi Melman
9fda1cb421
Merge pull request #813 from jwnimmer-tri/dist_sink_reset_v1.x
Add set_sinks method to dist_sink
2018-09-04 23:56:03 +03:00
Gabi Melman
bcc6db4a06
Update README.md 2018-09-04 19:34:59 +03:00
Gabi Melman
37cd707294
Fix issue #819 2018-09-03 19:08:57 +03:00
gabime
3698c1d2f1 added spdlog namespace when calling make_unique 2018-09-02 01:27:28 +03:00
Gabi Melman
00acb8ba41
Update registry.h 2018-09-01 22:41:56 +03:00
Gabi Melman
a6ee1cf590
fix vc compliation error about make_unique 2018-09-01 21:56:19 +03:00
gabime
ebce97947d use make_unique 2018-09-01 21:30:05 +03:00
gabime
f4bbe8b2b3 Fixed some extra warnings from clang 2018-08-31 14:17:11 +03:00
Gabi Melman
e52e258f15
Update README.md 2018-08-31 04:14:23 +03:00
Jeremy Nimmer
679fcd787f Add set_sinks method to dist_sink
This allows users to set exactly the sinks they want, even if other
unknown application code has added bespoke sinks in the meantime.
2018-08-29 12:29:32 -04:00
Gabi Melman
f3798159e7
Merge pull request #814 from maciekgajewski/no-pessimizing-move
Pessimizing move removed
2018-08-29 19:21:56 +03:00
Maciej Gajewski
c4de214cea Pessimizing move removed 2018-08-29 17:21:38 +02:00
gabime
6c5bbca0c1 Added clone tests 2018-08-25 18:10:42 +03:00
gabime
447a6a15d9 Fixed readme 2018-08-25 17:57:41 +03:00
gabime
5d7845c138 Added "clone()" support to loggers 2018-08-25 17:55:31 +03:00
gabime
91d8869f36 Added "clone()" support to loggers 2018-08-25 17:35:20 +03:00
Gabi Melman
1f8b2cbb8b
Update file_helper.h 2018-08-24 13:27:49 +03:00
Gabi Melman
d0cfca0820
Update file_helper.h 2018-08-24 13:27:10 +03:00
Gabi Melman
f6049cd333
Update file_helper.h 2018-08-24 13:26:45 +03:00
Gabi Melman
a25fd62349
Merge pull request #806 from emruiz81/v1.x
WIN32: Don't deny access to file sinks from other processes
2018-08-23 19:15:28 +03:00
eruiz
39492436ec WIN32: Don't deny access to file sinks from other processes 2018-08-23 12:20:26 -03:00
Gabi Melman
df962e5c53
Merge pull request #804 from DanielChabrowski/globals-include
Add missing include in console_globals.h
2018-08-23 00:12:17 +03:00
Daniel Chabrowski
2990126054 Change console_globals include to windows.h only 2018-08-22 22:47:16 +02:00
Daniel Chabrowski
3edc7f1d18 Add missing include in console_globals.h 2018-08-22 21:46:46 +02:00
Gabi Melman
2870afdeae
Update stdout_sinks.h 2018-08-21 03:37:29 +03:00
gabime
d3c1ad29a0 Optimize logging for const char* messages 2018-08-20 12:43:31 +03:00
Gabi Melman
23db7a213d
Merge pull request #801 from yhchen/v1.x
remove invalid files from project
2018-08-19 13:02:35 +03:00
yhchen
3151081ff3 remove invalid files from project 2018-08-19 17:21:15 +08:00
gabime
0758b39061 Stop compilation on first error 2018-08-18 02:19:52 +03:00
gabime
45d3c8341c Fixed mpmc_q test for osx in travis 2018-08-17 17:45:48 +03:00
gabime
8418131ae3 Fixed mpmc_q test for osx in travis 2018-08-17 17:30:33 +03:00
gabime
9ad9cfb898 Fixed mpmc_q test for osx in travis 2018-08-17 17:17:16 +03:00
gabime
a281d21fbf Removed valgrind from travis 2018-08-17 16:26:52 +03:00
gabime
af5962450e Try adding osx to travis 2018-08-17 16:15:02 +03:00
gabime
3b3af1ab1e Try adding osx to travis 2018-08-17 16:00:14 +03:00
gabime
acd7a88bf2 Try adding osx to travis 2018-08-17 15:59:52 +03:00
Gabi Melman
176cab4fee
Update file_helper.h 2018-08-17 14:07:49 +03:00
Gabi Melman
28435dc736
Normalized spdlog includes in file_helper 2018-08-17 14:06:48 +03:00
gabime
a58d7594cb Fixed issue #798 and added -Wconversion compiler flag to build 2018-08-17 00:32:13 +03:00
Gabi Melman
06181720fb
Merge pull request #800 from DanielChabrowski/fix-registry-test
Fix registry test
2018-08-16 19:25:34 +03:00
Daniel Chabrowski
b51c8cfd0f Fix registry test 2018-08-16 17:53:55 +02:00
gabime
b6b9d835c5 Version 1.1.0 2018-08-15 19:34:10 +03:00
gabime
ebea09c8b4 Added pedantic flag to compiler in cmake 2018-08-15 19:09:37 +03:00
gabime
137f801ec7 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2018-08-15 19:02:07 +03:00
gabime
3d58f8d471 code formatting 2018-08-15 19:01:54 +03:00
gabime
b962fbb15c Fixed issue #797 2018-08-15 19:01:44 +03:00
Gabi Melman
e8927dc75f
Merge pull request #796 from DanielChabrowski/cmake-refactor
Little cmake and tests refactor
2018-08-14 23:21:11 +03:00
Daniel Chabrowski
fb37585bc1 Little cmake and tests refactor
Change from spdlog_ex to const spdlog_ex& got rid of the GCC8 warning.
2018-08-14 21:33:47 +02:00
gabime
4a871b9792 Added some mpmc_q tests 2018-08-14 17:59:14 +03:00
gabime
057bf1b92d Added some mpmc_q tests 2018-08-14 17:57:55 +03:00
gabime
750b520f41 Fix broken build 2018-08-14 16:38:35 +03:00
Gabi Melman
c23f36c734
Merge pull request #795 from indiosmo/queue_full_counter
Expose a counter for how many messages were dropped in async mode
2018-08-14 16:36:38 +03:00
Luiz Siqueira
4eb80dd8d2 acquire lock before reading overrun_counter 2018-08-14 10:11:03 -03:00
Luiz Siqueira
c543985cf4 use size_t instead of int for overrun counter 2018-08-14 09:21:52 -03:00
Luiz Siqueira
863f704f47 increment counter every time we overrid a message in async mode. 2018-08-14 08:51:20 -03:00
gabime
54896763ab Update readme 2018-08-14 01:51:22 +03:00
Gabi Melman
0272bd2846
Update README.md 2018-08-14 01:50:09 +03:00
gabime
70f3ed66f4 Update readme 2018-08-14 01:46:57 +03:00
gabime
1dba3162c4 Fixed travis 2018-08-14 01:19:29 +03:00
gabime
cb0d8cfbbd Fixed travis 2018-08-14 01:15:39 +03:00
gabime
08064716b3 Fixed cmake for bench 2018-08-14 01:05:16 +03:00
gabime
dca20731a2 Added thread sanitizer tests to travis CI 2018-08-14 01:02:05 +03:00
gabime
530e209f66 Fixed async tests to pass TASN checks 2018-08-14 00:58:50 +03:00
gabime
566df7e826 Added missing include to q 2018-08-14 00:58:09 +03:00
gabime
56b3a17e56 Udpated README 2018-08-13 12:38:36 +03:00
gabime
d6cc5847fa Udpated README 2018-08-13 12:37:15 +03:00
gabime
1d672d39cf Udpated README 2018-08-13 12:33:58 +03:00
gabime
aefde13858 formatting 2018-08-13 12:27:25 +03:00
gabime
607779cccf micro optimization in log_msg constructor 2018-08-13 12:27:11 +03:00
gabime
da2af6ea2e Fixed some clang-tidy warning 2018-08-13 11:43:00 +03:00
gabime
ba337d1393 Fixed warning in tests 2018-08-13 11:16:50 +03:00
gabime
6ae240c0b6 code formatting and clang tidy warnings fixes 2018-08-13 10:32:07 +03:00
gabime
05d6960ebc code formatting and clang tidy warnings fixes 2018-08-13 10:30:02 +03:00
gabime
4866f2ac05 Put override kw again 2018-08-13 09:27:11 +03:00
gabime
4456f96ae3 Fixed clang warnings 2018-08-13 09:21:47 +03:00
gabime
8008d7fe53 Replace emplace_back with push_back in pattern_formatter 2018-08-13 09:09:49 +03:00
gabime
0a585092dc Added ASAN test in release build to travis 2018-08-13 02:02:17 +03:00
gabime
387ccae7d8 Removed gcc7 debug from travis 2018-08-13 01:59:49 +03:00
gabime
d951ea32a6 travis improvments 2018-08-13 01:44:10 +03:00
gabime
da30e2ef18 Improved CMakeLists and added bench 2018-08-13 01:22:35 +03:00
Gabi Melman
cb299375f6
Merge pull request #789 from DanielChabrowski/ci-v1
Modify travis-ci, fix compilation issues
2018-08-12 21:52:26 +03:00
Daniel Chabrowski
4534d5239f Remove tsan and gcc 4.9 jobs 2018-08-12 20:34:30 +02:00
Daniel Chabrowski
af5a516443 Add valgrind to a clang6 addon
Unfortunately valgrind is required for all addons
2018-08-12 18:51:34 +02:00
Daniel Chabrowski
368b3699d0 Run ASAN/TSAN jobs with clang
Bring back removed tests/Makefile
2018-08-12 18:42:54 +02:00
Daniel Chabrowski
49d663f6c8 Move tsan/asan flag management to cmake
Add sudo: required to fix asan builds
2018-08-12 17:11:56 +02:00
Daniel Chabrowski
7e32ccbd8f Modify travis-ci, fix issues
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
* multisink build

Workarounds:
* gcc7 with tsan and asan needs gold linker, otherwise build
  fails becase of unrecognized option '--push-state'
2018-08-11 02:24:45 +02:00
Gabi Melman
f8f2d7b950
Merge pull request #786 from rajesh-p/v1.x
Namespace fix  for the issue 785
2018-08-10 09:45:31 +03:00
rajesh-p
769f11109d
Namespace fix for the issue 785
Added namespace fix
2018-08-09 21:17:53 -07:00
Gabi Melman
85a2bf1c17
Merge pull request #784 from baishuai/v1.x
add new line at end of file, fix compiler warnings #778
2018-08-08 22:29:14 +03:00
baishuai
a2fa7a833c add new line at end of file, fix compiler warnings 2018-08-08 22:59:57 +08:00
Gabi Melman
8179b26388
Update file_log.cpp 2018-08-07 03:29:45 +03:00
Gabi Melman
12bbef308b
Update README.md 2018-08-06 22:19:16 +03:00
gabime
caff7296b1 small fix to example.sln 2018-08-05 01:33:52 +03:00
gabime
779328a940 Fixed async_bench 2018-08-05 01:25:40 +03:00
gabime
01e05a4495 clang format 2018-08-05 00:35:32 +03:00
gabime
af6b3fe599 delay the release mutex in the async queue only for mingw 2018-08-05 00:34:59 +03:00
gabime
74e8bebb75 Added async_bench 2018-08-05 00:14:01 +03:00
gabime
8bfec30d48 Fix deadlock issue with mingw in async logger 2018-08-03 13:38:41 +03:00
Gabi Melman
2880eceeae
Merge pull request #773 from slapenko/v1.x
We can control should daily_file_sink truncate an underlying file or not
2018-08-02 17:13:40 +03:00
slapenko
34ada56f5d Refactoring. Rid of open_file for clarity 2018-08-02 07:27:49 -05:00
slapenko
64521005ab We can control should daily_file_sink truncate an underlying file or not 2018-08-01 22:58:15 -05:00
Gabi Melman
16b18f7962
Update README.md 2018-08-01 22:01:35 +03:00
Gabi Melman
986af6ea9e
Update README.md 2018-07-26 21:53:40 +03:00
Gabi Melman
691011c473
Update README.md 2018-07-26 21:52:52 +03:00
gabime
fd54719351 clang-format 2018-07-26 21:13:19 +03:00
gabime
420b17ae65 Fix issue #769 2018-07-26 21:09:40 +03:00
gabime
ef5e7af68a Fixed bench Makefile 2018-07-26 00:29:13 +03:00
gabime
05b68b8581 Fixed example and inline 2018-07-26 00:23:44 +03:00
gabime
de6ddf4e2a Some code refactoring in formatter 2018-07-26 00:20:31 +03:00
gabime
a12a21a18e Improved millis formatting 2018-07-25 23:33:03 +03:00
gabime
d8053dd6a6 -Ofast in bench Makefile 2018-07-25 20:15:27 +03:00
gabime
7d38e2b01e Removed junk folder 2018-07-25 18:48:45 +03:00
gabime
53cd47e19f Remove un needed declaration from thread_pool 2018-07-25 16:50:14 +03:00
gabime
ce5c1c24cf added explicit kw to ctor 2018-07-25 00:33:11 +03:00
gabime
2894e8de5e clang format 2018-07-25 00:06:10 +03:00
gabime
74c10df169 Changed SPDLOG_VERSION to be numeric 2018-07-25 00:03:27 +03:00
gabime
0da977f9c7 Fixed bench Makefile 2018-07-24 23:32:11 +03:00
gabime
0b7c505b50 Fixed forgotten inline keyword 2018-07-24 23:07:32 +03:00
gabime
cb9c984aa7 registery and periodic flusher fixes. 2018-07-24 22:59:34 +03:00
Gabi Melman
516a8e4212
Update periodic_worker.h 2018-07-24 03:08:49 +03:00
Gabi Melman
40aeaaee54
Update periodic_worker.h 2018-07-24 03:01:27 +03:00
Gabi Melman
5fd56ec463
Update README.md 2018-07-23 22:53:23 +03:00
gabime
33329c80a9 code formatting 2018-07-23 00:13:52 +03:00
gabime
fe73255452 Fixed issue #759 2018-07-23 00:13:24 +03:00
gabime
9d497d5afd Fix issue #765 2018-07-22 21:55:47 +03:00
gabime
693103af9c support set_formatter in spdlog.h 2018-07-22 21:52:46 +03:00
gabime
7184c42376 Changed some static string array to char* arrays 2018-07-22 13:06:16 +03:00
Gabi Melman
349829fa96
Update periodic_worker.h 2018-07-22 02:02:36 +03:00
Gabi Melman
3684228cd5
Update periodic_worker.h 2018-07-22 02:02:01 +03:00
gabime
9e4925eff0 clang format 2018-07-21 23:48:07 +03:00
gabime
a96b4d7529 Added periodic flusher support, and fixed some registry issues 2018-07-21 23:30:26 +03:00
gabime
d5af87a8e1 Added periodic flusher support, and fixed some registry issues 2018-07-21 22:43:36 +03:00
gabime
683dc0b216 Added async test to tests 2018-07-21 00:35:22 +03:00
gabime
989a10e48b Added async test to tests 2018-07-21 00:33:27 +03:00
gabime
41d248f442 Fixed Makefile.mingw example 2018-07-21 00:24:30 +03:00
gabime
2dfea6bee3 Fixed tests under windows 2018-07-21 00:13:37 +03:00
gabime
0c07df7005 Fixed async factory 2018-07-20 23:58:21 +03:00
gabime
599981e2e6 Fixed mingw build 2018-07-20 23:34:02 +03:00
gabime
b0059b290f Fix issue #761 2018-07-20 23:26:52 +03:00
gabime
9cbdd5ffd4 Added async_nonblocking factory 2018-07-20 23:20:48 +03:00
gabime
ddb3002bc1 Added non const sinks() function to support addition/removal of sinks from existing logger 2018-07-20 12:49:30 +01:00
Gabi Melman
63db70aacc
Update README.md 2018-07-20 14:35:57 +03:00
gabime
6225a9fa4f Minor cleaning of spdlog.h 2018-07-19 15:09:10 +03:00
gabime
3aaefc48ec Minor cleaning of common.h 2018-07-19 15:07:54 +03:00
gabime
c832a39d44 fixed example msvc solution 2018-07-19 15:03:37 +03:00
gabime
0a3c81826f Changed some functions to accept strings instead of ref to strings for better semantics 2018-07-19 15:03:08 +03:00
gabime
b710e0fe86 Changed some functions to accept strings instead of ref to strings for better semantics 2018-07-19 15:00:05 +03:00
gabime
9df2bd256e Changed some functions to accept strings instead of ref to strings for better semantics 2018-07-19 14:54:26 +03:00
Gabi Melman
b238bf9512
fix issue #755 2018-07-17 20:09:05 +03:00
Gabi Melman
07928109af
Update README.md 2018-07-17 15:28:53 +03:00
Gabi Melman
2e4e80f2a9
Update README.md 2018-07-17 15:27:21 +03:00
Gabi Melman
4b62819da0
Update README.md 2018-07-17 15:26:12 +03:00
Gabi Melman
e3af4124de
Update README.md 2018-07-17 15:20:02 +03:00
Gabi Melman
653c4d6472
Update README.md 2018-07-17 15:19:38 +03:00
Gabi Melman
b96a244984
Update README.md 2018-07-17 15:17:31 +03:00
Gabi Melman
2656a031e1
Update README.md 2018-07-17 15:16:14 +03:00
Gabi Melman
532671662d
Update README.md 2018-07-17 15:15:18 +03:00
Gabi Melman
58f244a003
Update README.md 2018-07-17 15:13:31 +03:00
Gabi Melman
51c851ce3d
Update README.md 2018-07-17 15:09:36 +03:00
gabime
c2a49080aa Refactored sink interface and base_sink 2018-07-14 16:21:53 +03:00
Gabi Melman
2bc05b6b17
Merge pull request #752 from baishuai/v1.x
fix bug in android_sink.h
2018-07-13 20:18:14 +03:00
baishuai
41f708e438 fix bug in android_sink.h 2018-07-13 23:41:26 +08:00
gabime
7d40244a89 Fixed issue #726 and changed default filename calculator to dateonly 2018-07-13 01:44:29 +03:00
gabime
08ef5a2a66 Updated null_mt bench report 2018-07-12 23:48:24 +03:00
gabime
16ee72da7c clang format 2018-07-10 23:53:00 +03:00
gabime
d409e5367b Revert d5468e50f6fd4673df2f8b94714de1002c07cd58 2018-07-10 23:51:20 +03:00
gabime
d5468e50f6 Small optimization in thread pool 2018-07-10 20:42:27 +03:00
gabime
ef111ddba2 Fix issue #736 2018-07-10 20:20:55 +03:00
gabime
81f29a9a7a Fixed wchar support in messages 2018-07-10 17:01:49 +03:00
gabime
898e1f2641 Fixed bench 2018-07-10 16:11:01 +03:00
gabime
23ad1aa243 Fixed bench 2018-07-10 16:08:39 +03:00
gabime
4e9fafac75 comment 2018-07-10 14:35:54 +03:00
gabime
b9180f8f5a Fix to a windows issue, where very high rotation rates sometimes fail if antivirus is running. 2018-07-10 14:33:38 +03:00
gabime
cf6e9461af Fixed comversion warning in bench under msvc 2018-07-10 10:48:29 +03:00
gabime
97c201297f Udpated example 2018-07-10 10:40:25 +03:00
gabime
4a59ea3b1e Fixedconversion warning in 32 bits 2018-07-10 10:40:09 +03:00
gabime
f9019870da Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2018-07-10 10:34:08 +03:00
gabime
60ca07c2d5 fixed latency test 2018-07-09 23:56:07 +03:00
gabime
8baa8cf8ea fixed latency test 2018-07-09 23:55:17 +03:00
gabime
a776a774e1 cache millis in full_formatter 2018-07-09 21:07:44 +03:00
gabime
374a22b4b9 bench fix 2018-07-09 21:06:59 +03:00
gabime
bc495bbc63 Added latency bench 2018-07-09 21:06:15 +03:00
gabime
c887907d4a faster reset of cached buffer 2018-07-09 15:10:43 +03:00
gabime
b4dcd592d8 faster reset of cached buffer 2018-07-09 15:10:24 +03:00
gabime
21524c16fa faster reset of cached buffer 2018-07-09 15:05:48 +03:00
Gabi Melman
bbff8abf58
Update CMakeLists.txt 2018-07-08 19:25:15 +03:00
Gabi Melman
99cc35384b
Update common.h 2018-07-08 19:24:26 +03:00
Gabi Melman
8266dde556
Update README.md 2018-07-08 17:03:13 +03:00
Gabi Melman
2277fdc80d
Update README.md 2018-07-08 17:02:26 +03:00
Gabi Melman
9cc731001b
Update README.md 2018-07-08 17:00:57 +03:00
gabime
80855329e7 Updated readme.md 2018-07-08 16:50:56 +03:00
gabime
5851fb9de9 Updated readme.md 2018-07-08 16:49:57 +03:00
gabime
866e593138 Updated readme.md 2018-07-08 16:48:58 +03:00
gabime
7f26ad29a0 Updated bench.cpp 2018-07-08 16:46:52 +03:00
gabime
f766b6d882 Updated bench.cpp 2018-07-08 16:46:12 +03:00
gabime
ca2724d82e Updated readme 2018-07-08 16:45:35 +03:00
gabime
a8b026bd70 Updated readme 2018-07-08 16:43:55 +03:00
gabime
2292f7a27a Updated readme 2018-07-08 16:43:04 +03:00
gabime
3ea1d27aac Updated readme 2018-07-08 16:42:21 +03:00
gabime
df779f66a2 Updated readme 2018-07-08 16:39:25 +03:00
gabime
81f3cc5575 clang format 2018-07-08 16:26:25 +03:00
gabime
1fd166d417 Updated example 2018-07-08 16:26:14 +03:00
gabime
5bfeb672f7 updated slot size in async queue 2018-07-08 16:22:04 +03:00
gabime
3c40c5ca5d Added mulitsink example 2018-07-08 16:20:28 +03:00
gabime
f4771be70e Upgraded to fmt 5.1.0 2018-07-08 11:03:43 +03:00
gabime
887326e715 minor code cleanup 2018-07-08 01:41:32 +03:00
gabime
45da6c9c33 spelling 2018-07-08 00:56:05 +03:00
gabime
7ed8e1b59d renamed async block policy 2018-07-08 00:53:50 +03:00
gabime
4f1ce9189f Fixed issue #747 2018-07-07 16:40:29 +03:00
gabime
775e410b00 Fixed issue #747 2018-07-07 16:29:05 +03:00
gabime
c9331594bb Renamed file to pattern_forammter.h and fixed utc support 2018-07-07 16:15:17 +03:00
gabime
cbc4db8649 Renamed filename and other small formatter changes 2018-07-07 15:34:25 +03:00
gabime
b07069fb4d Fixed example 2018-07-07 15:27:17 +03:00
Gabi Melman
4fc59e3e7b
Update example.cpp 2018-07-07 15:05:01 +03:00
Gabi Melman
5fddfca7c6
Update example.cpp 2018-07-07 15:03:57 +03:00
Gabi Melman
745b9e32ed
Update example.cpp 2018-07-07 15:03:34 +03:00
gabime
9dc44c39e7 Fixed bugs in stdout_sinks and in msvc 2018-07-07 14:04:31 +03:00
gabime
bde4c7149f Renamed traits to console globals 2018-07-07 13:38:15 +03:00
gabime
39c6eb752a Code formatting 2018-07-07 13:22:43 +03:00
gabime
a9a7309001 fixed dist_sink.h 2018-07-07 13:22:09 +03:00
gabime
72f4fae207 updated example 2018-07-07 12:53:56 +03:00
gabime
b0bf457538 updated example 2018-07-07 12:37:17 +03:00
gabime
98ab8e0d73 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2018-07-07 12:12:54 +03:00
gabime
cd4dcbab36 Renamed simple_file_sink -> basic_file_sink 2018-07-07 12:12:45 +03:00
Gabi Melman
3ebdb2fd8b
Update logger.h 2018-07-06 08:40:55 +03:00
gabime
69c11ea7d2 Updated bench 2018-07-05 16:35:07 +03:00
gabime
bd759bfca7 removed force_flush from simple logger 2018-07-05 16:34:20 +03:00
gabime
4a90950fe5 updated bench 2018-07-05 16:19:23 +03:00
gabime
005468248b Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2018-07-05 14:56:19 +03:00
gabime
ecd7669e42 Fixed gcc warning 2018-07-05 12:57:14 +03:00
gabime
36a823df70 Fixed msvc example solution 2018-07-05 10:55:19 +03:00
gabime
3643db6821 Fixed msvc conversion warning 2018-07-05 10:54:02 +03:00
gabime
59f54cda10 Fixed msvc conversion warnings 2018-07-04 10:44:05 +03:00
gabime
95de24e4f6 fixed tests and renamed to_short_str 2018-07-04 09:59:26 +03:00
gabime
1d9e2304be renamed level::to_str() to level::to_c_str() 2018-07-04 02:08:28 +03:00
gabime
1f801828a5 pad6 thread id and micros in formatter 2018-07-04 01:41:05 +03:00
gabime
94a7152afc async queue - overrun oldsest policy option 2018-07-04 01:24:52 +03:00
gabime
0358d115e0 removed std::string from async messages 2018-07-04 00:46:50 +03:00
gabime
b4349e4226 pre allocate async q memory 2018-07-04 00:38:23 +03:00
gabime
92e2cef67f remove unneeded includes from file 2018-06-26 02:37:35 +03:00
gabime
91264ea2f0 small improvment to formatter 2018-06-26 02:32:19 +03:00
gabime
e66ee8b710 fix gcc and clang warnings 2018-06-26 02:00:33 +03:00
gabime
a6e2f23780 Pattern formatter optimizations 2018-06-26 01:13:02 +03:00
gabime
87e013534c wincolor sink fix 2018-06-25 16:32:22 +03:00
gabime
1d9ec2373a Better support for 32bits 2018-06-25 16:31:56 +03:00
gabime
46cf0f86b8 Added set_pattern() to sink class 2018-06-24 01:55:30 +03:00
gabime
e574f57511 Fixed stdout_color_sinks.h namespace 2018-06-24 01:55:09 +03:00
gabime
8fdd26da82 Fixed example.cpp 2018-06-24 01:37:34 +03:00
gabime
0c19bdd772 pattern per sink and pattern caching 2018-06-24 01:32:39 +03:00
gabime
9d7a5c253a Moved fmt helpers to new file 2018-06-15 14:15:35 +03:00
gabime
ac6a2a4c0f -mpattern_formatter small change in pad3 2018-06-15 13:56:12 +03:00
Gabi Melman
58e09dbd33
Update common.h 2018-06-13 21:14:18 +03:00
Gabi Melman
e770673f11
Update common.h 2018-06-13 21:13:22 +03:00
gabime
6d5670fde7 format 2018-06-13 20:19:13 +03:00
gabime
da0d6d0478 Removed printf support 2018-06-13 20:16:45 +03:00
gabime
5683c06d9a solve issue #724 2018-06-13 20:16:31 +03:00
gabime
65506136e2 solve issue #724 2018-06-13 19:10:22 +03:00
gabime
2989e998ee Speed up pattern_formatter 2018-06-13 18:47:02 +03:00
gabime
3f438a8084 added bundled fmt 5.x 2018-06-13 10:55:14 +03:00
gabime
f2a8847902 Speed up pattern_formatter 2018-06-13 01:47:03 +03:00
gabime
94ac1261e4 Speed up default pattern 2018-06-13 01:06:37 +03:00
gabime
8b7e19e92f Bug fixes in pattern_formatter and async_logger 2018-06-13 00:20:54 +03:00
gabime
81fa788bca Updated tests 2018-06-12 22:43:49 +03:00
gabime
cdbf2e361b Upgrade to fmt 5.x 2018-06-12 18:48:22 +03:00
gabime
378c7789ba Fixed issue #720 2018-06-10 23:16:00 +03:00
gabime
15f3b0fea5 format 2018-06-10 23:03:55 +03:00
gabime
28ef15d669 updated example 2018-06-10 23:02:53 +03:00
gabime
145fc367f9 updated example 2018-06-10 23:01:46 +03:00
gabime
a21594bec7 move underscores to the end of private members 2018-06-10 22:59:17 +03:00
gabime
7d975de193 removed message_counter from tp 2018-06-01 18:56:51 +03:00
gabime
5833c1dec8 cleaned bench source folder 2018-06-01 17:58:57 +03:00
gabime
4b9949de7b format 2018-06-01 17:52:05 +03:00
gabime
5997e5aae7 cleaned bench folder to contain only spdlog tests 2018-06-01 17:50:59 +03:00
gabime
52d1c08896 cleaned tests 2018-06-01 17:30:38 +03:00
gabime
7815d39807 removed wait_empty() from tp and q 2018-06-01 17:25:23 +03:00
gabime
7f6220d960 increase errno string buffer size 2018-06-01 17:21:00 +03:00
gabime
8a3c858d36 bench 2018-06-01 17:09:22 +03:00
gabime
38b3ecb02e use fmt::safe_strerror 2018-06-01 17:07:39 +03:00
gabime
f2bc1571b4 update example 2018-05-27 03:21:59 +03:00
gabime
4d7245bb67 update example 2018-05-27 03:18:12 +03:00
gabime
ef5c4f027c added tp getter to async api 2018-05-27 03:14:55 +03:00
gabime
c568640595 update bench 2018-05-27 03:02:51 +03:00
gabime
8338b45b2b added tp->wait_empty() 2018-05-27 02:53:16 +03:00
gabime
0d0a841e8d format 2018-05-27 02:21:49 +03:00
gabime
31ff43ef81 more async tests 2018-05-27 02:21:31 +03:00
gabime
a43a44bb88 update example 2018-05-27 01:29:13 +03:00
gabime
cfbc8e52ba use underscore at end of private members names 2018-05-26 19:21:20 +03:00
gabime
72506b3bab use underscore at end of private members names 2018-05-26 19:02:58 +03:00
gabime
b002a21c36 use underscore at end of private members names 2018-05-26 19:02:20 +03:00
gabime
7a339e2b5e Updated usage message in async null bench 2018-05-26 18:57:29 +03:00
gabime
e033a0da9a Fixed usage message in async null bench 2018-05-26 18:54:52 +03:00
gabime
0d7a1d1ef9 format 2018-05-26 18:48:39 +03:00
gabime
80f19d7136 updated null-async bench command line flags 2018-05-26 18:48:33 +03:00
gabime
15d6432302 Fixed bench 2018-05-26 17:42:49 +03:00
gabime
59a15c02d3 use std::string in async_msg instead of fmt::MemoryWriter 2018-05-26 14:56:20 +03:00
gabime
e4ed7528e3 fixed class name 2018-05-26 14:50:42 +03:00
gabime
8932b77d63 fixed example 2018-05-26 14:50:27 +03:00
Gabi Melman
b3543452c2
Update simple_file_sink.h 2018-05-25 19:01:24 +03:00
Gabi Melman
16376c18aa
Update thread_pool.h 2018-05-25 18:44:43 +03:00
Gabi Melman
a23eb3769a
Update async.h 2018-05-25 18:28:29 +03:00
Gabi Melman
001e22ebee
Update registry.h 2018-05-25 18:20:08 +03:00
Gabi Melman
e8a726df03
Update stdout_color_sinks.h 2018-05-25 18:09:30 +03:00
gabime
8901cbffe0 added catch macro and fixed some tests 2018-05-24 00:18:55 +03:00
gabime
b9d7c45e40 Use blocking queue 2018-05-22 21:59:27 +03:00
gabime
cf63bcb808 catch exceptions during flush and cal handler 2018-05-22 21:59:14 +03:00
Gabi Melman
d0b8ecb6dd
Update README.md 2018-04-29 01:56:18 +03:00
Gabi Melman
13774e62bd
Update README.md 2018-04-29 01:55:09 +03:00
gabime
4ec17f1a1a Normalized spdlog include paths 2018-04-29 01:43:42 +03:00
gabime
f886ae0005 Removed unneeded include 2018-04-29 01:39:36 +03:00
gabime
7db5b56dd7 Removed unneeded include 2018-04-29 01:38:21 +03:00
gabime
3c7103d90d Format 2018-04-29 01:36:45 +03:00
gabime
5ec37c05f7 Normalized spdlog include paths 2018-04-29 01:35:49 +03:00
gabime
780dab6977 Fixed tests 2018-04-29 01:34:36 +03:00
gabime
caa26a2a47 Normalized spdlog include paths 2018-04-29 01:31:09 +03:00
gabime
d389bda2cc moved file sinks sinks folder 2018-04-29 01:26:10 +03:00
gabime
60f8a68ae0 Splitted file sinks to seperate headers 2018-04-29 01:23:18 +03:00
gabime
99ca7f1cbe Comments 2018-04-29 00:52:56 +03:00
gabime
3e28d9ab5a Renamed default factory 2018-04-29 00:44:35 +03:00
gabime
4bee0ec294 Fixed stderr_logger typedef 2018-04-29 00:43:24 +03:00
gabime
b3a23039b1 Renamed default factory 2018-04-29 00:42:24 +03:00
gabime
e500fa013f example 2018-04-29 00:35:32 +03:00
gabime
b393c9d6e6 Fixed console traits 2018-04-29 00:23:59 +03:00
gabime
e4f0d6446b Small template rename 2018-04-29 00:21:15 +03:00
gabime
9b5c5b4f3d Small template rename 2018-04-29 00:20:04 +03:00
gabime
0d61ab82e4 small makefile fix for example 2018-04-29 00:09:56 +03:00
gabime
67ddd59701 Move msg and remove spinning 2018-04-29 00:08:46 +03:00
gabime
78ea362e27 Don't rethrow after catch(...) 2018-04-28 23:30:35 +03:00
gabime
d51102a168 example.cpp fix 2018-04-28 19:29:10 +03:00
gabime
f2023e80a8 Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x 2018-04-22 00:26:02 +03:00
gabime
384ae1dc1b Removed unneeded intializers from async_msg 2018-04-22 00:25:20 +03:00
Gabi Melman
c63f8a6ea0
Delete spdlog_impl.h 2018-04-20 15:55:00 +03:00
gabime
64c725cee2 Fixed multisink example 2018-04-20 14:03:36 +03:00
gabime
110bdd93c8 Fixed stdout_sinks 2018-04-20 14:03:15 +03:00
gabime
c962c88342 Fixed linux port of v1.x 2018-04-20 13:20:19 +03:00
gabime
c80cc3306f Fixed tests 2018-04-20 03:04:53 +03:00
gabime
e4d3eb64e6 Udpated example and spdlog.h 2018-04-20 02:57:05 +03:00
gabime
0969118ce7 added default_factory alias 2018-04-20 01:55:31 +03:00
gabime
ba7c4c0530 stdout and color logger factories 2018-04-20 01:50:09 +03:00
gabime
d6cb447667 fixed compile error 2018-04-19 18:41:00 +03:00
gabime
b9fac2b179 added missing header 2018-04-19 18:40:58 +03:00
gabime
11e068d7a3 Added missing #include 2018-04-19 17:50:18 +03:00
gabime
924ef84241 Refactred spdlog.h and console sinks. Added global lock for all console sinks (traits) 2018-04-18 02:04:10 +03:00
gabime
9bffa921ae global mutex stdout stderr sinks 2018-04-16 01:07:22 +03:00
gabime
c50ba69689 removed un needed includes 2018-04-14 04:16:05 +03:00
gabime
b4cde3fc21 Added missing files 2018-04-14 04:11:03 +03:00
gabime
6f1dc624e6 fix example 2018-04-14 03:47:26 +03:00
gabime
7378cc297c fix example 2018-04-14 03:43:00 +03:00
gabime
6f4cd8d397 thread_pool and refactoring async 2018-04-14 03:34:57 +03:00
Gabi Melman
5e08950ed2
Created contrib/sinks directory 2018-04-13 12:45:33 +03:00
Gabi Melman
bce3b75c53
Created contrib directory 2018-04-13 12:44:43 +03:00
gabime
3fdc7996db code formatting 2018-04-09 15:14:13 +03:00
gabime
e9bb008f15 Fixed example 2018-04-09 15:12:51 +03:00
gabime
d352aa0990 Fixed example 2018-04-09 15:11:42 +03:00
gabime
cfb450c059 Fixed eol write in pattern_formatter_impl 2018-04-09 14:14:52 +03:00
Gabi Melman
b416685d6f
Fix gcc warning on stat (32 bits) 2018-04-09 02:06:33 +03:00
gabime
64c2fe180b Fixed bug in wrapping colors around level name in default pattern 2018-04-08 18:27:18 +03:00
gabime
309327187a Fixed example makefile for clang 2018-04-06 04:36:22 +03:00
gabime
1dea46e1ab code formatting 2018-04-06 04:06:02 +03:00
Gabi Melman
4abe403544
Update README.md 2018-04-06 04:05:23 +03:00
Gabi Melman
21d437fbf5
Update README.md 2018-04-06 04:04:50 +03:00
Gabi Melman
84c7f927c2
Merge pull request #679 from gabime/color-formatting
Color formatting
2018-04-06 04:00:17 +03:00
gabime
644c81b9fb Added color ranges to formatter tests 2018-04-06 03:42:24 +03:00
gabime
3452892f76 minor renaming 2018-04-06 03:22:27 +03:00
gabime
2f7fdf2663 wincolor color formatting support 2018-04-06 03:06:41 +03:00
gabime
d040ab93ea wincolor color formatting support 2018-04-06 03:04:18 +03:00
gabime
c8610d9a86 support for color formatting 2018-04-06 02:24:07 +03:00
gabime
93d41b2c0e fixed gcc warning about struct stat 2018-03-22 20:35:49 +02:00
gabime
c03ae5fafd Merge branch 'master' of https://github.com/gabime/spdlog 2018-03-22 20:08:33 +02:00
Gabi Melman
b3988d6e1f
Merge pull request #665 from kasru/more_bench
More benchmarks
2018-03-21 20:58:11 +02:00
Alexander Kiselev
ad2c7b3959 Add README 2018-03-21 17:15:33 +03:00
Alexander Kiselev
5e1e897d10 Remove p7-bench binary 2018-03-21 16:51:43 +03:00
Alexander Kiselev
37f209079e Update spdlog-bench 2018-03-21 16:50:45 +03:00
Alexander Kiselev
0f66c63f72 Update easyloggingpp, Add plog 2018-03-21 16:46:52 +03:00
Gabi Melman
abde900cd7
Merge pull request #663 from kasru/more_bench
More bench
2018-03-19 21:27:03 +02:00
Alexander Kiselev
fd1c4d7877 Fix: unknown conversion specifier 'Y' 2018-03-19 20:03:47 +03:00
Alexander Kiselev
70ad1aa409 Changes: boost, easylogging, g2log, glog, spdlog. 2018-03-19 19:22:02 +03:00
Alexander Kiselev
c83dd5d60e Added: g3log, log4cplus, log4cpp, p7. Changes: boost, easylogging, g2log, glog, spdlog. 2018-03-19 19:17:26 +03:00
gabime
18c99682a8 fixed clang warning about uninitialized values 2018-03-17 14:08:10 +02:00
gabime
200815892f Fix clang-tidy warnings about missing braces around if and for statements 2018-03-17 13:42:09 +02:00
gabime
7eb6ca6337 formatting 2018-03-17 12:49:45 +02:00
gabime
5a0f90bc82 clang format namespace fix 2018-03-17 12:49:31 +02:00
gabime
2a86cdb203 Merge branch 'master' of https://github.com/gabime/spdlog 2018-03-17 12:47:56 +02:00
gabime
56e4a201ec formatting 2018-03-17 12:47:46 +02:00
gabime
c739e68021 clang format namespace fix 2018-03-17 12:47:04 +02:00
Gabi Melman
fe8a519434
Update logger.h 2018-03-16 22:03:54 +02:00
gabime
4445f6f869 formatting 2018-03-16 17:35:56 +02:00
gabime
4ee89877d5 Changed clang formatting for templates 2018-03-16 17:35:50 +02:00
gabime
ea95ea8295 Fix potential issue #660 2018-03-16 17:20:56 +02:00
gabime
fe5aaf4932 Fixed example 2018-03-16 17:17:33 +02:00
gabime
5afb5dc782 Changed clang formatting for templates 2018-03-16 17:13:50 +02:00
gabime
f4ce52d206 Changed clang formatting for templates 2018-03-16 17:13:22 +02:00
gabime
1108515738 format.sh small fix 2018-03-16 17:04:35 +02:00
gabime
8ee7b772a9 Added -O3 flag to CMakeLists.txt 2018-03-16 14:15:35 +02:00
Gabi Melman
650daf7542
Update common.h
Updated spdlog version macro to 0.16.4-rc
2018-03-09 23:26:28 +02:00
Gabi Melman
1946818292
Update .clang-format 2018-03-09 23:11:48 +02:00
gabime
cbe98c0fd2 clang format 2018-03-09 15:30:48 +02:00
gabime
ad221b0990 Changed function name to level::from_str 2018-03-09 15:27:53 +02:00
gabime
a2653d409f clang-format 2018-03-09 15:26:33 +02:00
gabime
461b5ef28a Fixed missing ; 2018-03-09 15:26:00 +02:00
gabime
7f1f7b6232 Changed function name to level::from_str 2018-03-09 15:24:37 +02:00
gabime
d741f1b654 some clang format fixes 2018-03-09 15:02:15 +02:00
gabime
f0606bcdb7 Merge branch 'master' of https://github.com/gabime/spdlog 2018-03-09 14:29:23 +02:00
gabime
03bc9ebb1f .clang-format 2018-03-09 14:29:20 +02:00
gabime
1f79c01dc4 Use clang-format-5.0 instead of astyle 2018-03-09 14:27:15 +02:00
Gabi Melman
dcf803de73
Merge pull request #622 from fegomes/to_level
New function to convert level_enum from string
2018-03-09 14:27:01 +02:00
fegomes
46f9768599 change of scope the name_to_level variable 2018-03-09 09:04:44 -03:00
gabime
2e098421f1 added .log extension to bench test 2018-03-09 12:08:56 +02:00
fegomes
c21dd874d1 removed class to return size of array. 2018-03-08 19:09:46 -03:00
fegomes
48c8755d06 include test to convert functions and change suggested by @gabime 2018-03-08 19:08:24 -03:00
fegomes
f9750dddee Merge branch 'master' into to_level 2018-03-08 18:16:10 -03:00
Gabi Melman
e8a39c894f
Update test_pattern_formatter.cpp 2018-03-06 10:31:36 +02:00
Gabi Melman
97cdbc45e8
Merge pull request #653 from tbastos/master
Fix implicit conversion warnings (-Wsign-conversion)
2018-03-05 22:29:51 +02:00
Thiago Bastos
d044369e3b Fix implicit conversion warnings (-Wsign-conversion) 2018-03-05 20:00:48 +01:00
gabime
84d3c90b93 Fixed g++ 4.9 warnings after the clang-tidy fixes 2018-02-28 00:11:50 +02:00
Gabi Melman
2e973c8b3d
Merge pull request #647 from DanielChabrowski/clang-tidy
Applied some of clang-tidy fixes
2018-02-27 23:41:24 +02:00
Daniel Chabrowski
de642b6263 astyle applied 2018-02-25 12:41:18 +01:00
Daniel Chabrowski
5355bd3a8f readability-named-parameter 2018-02-25 12:39:37 +01:00
Daniel Chabrowski
35a843f8b6 modernize-return-braced-init-list 2018-02-25 12:24:21 +01:00
Daniel Chabrowski
17caf77784 google-build-namespaces 2018-02-25 12:12:34 +01:00
Daniel Chabrowski
0c94ce0039 deleted copy op and a little format 2018-02-25 03:35:20 +01:00
Daniel Chabrowski
af50d5ef1f readability-inconsistent-declaration-parameter-name 2018-02-25 02:19:26 +01:00
Daniel Chabrowski
9ce66f2c9a modernize-pass-by-value 2018-02-25 01:58:09 +01:00
Daniel Chabrowski
ad624432d8 google-explicit-constructor 2018-02-25 01:40:46 +01:00
Daniel Chabrowski
1e1ca23101 modernize-use-equals-default 2018-02-25 01:25:15 +01:00
Daniel Chabrowski
e5bbe57f01 cppcoreguidelines-pro-type-member 2018-02-25 01:15:35 +01:00
Daniel Chabrowski
68f91822ed performance-unnecessary-value-param 2018-02-25 00:54:14 +01:00
Daniel Chabrowski
7aed498540 modernize-use-default-member-init 2018-02-25 00:38:54 +01:00
Daniel Chabrowski
d5a3bb5234 readability-else-after-return 2018-02-25 00:24:47 +01:00
Daniel Chabrowski
9ebb9ff318 readability-implicit-bool-cast 2018-02-25 00:16:18 +01:00
Daniel Chabrowski
fb6df0512f modernize-use-override 2018-02-24 23:56:56 +01:00
Daniel Chabrowski
7f4c1bb77c modernize-use-using 2018-02-24 22:35:09 +01:00
gabime
abc0d43995 astyle 2018-02-23 18:33:03 +02:00
gabime
3826ac1433 bumped bundled fmt version to 4.1.0 2018-02-23 18:32:06 +02:00
gabime
d650fa2456 Fixed tests for older gcc compilers 2018-02-23 18:25:39 +02:00
gabime
80163dc6c1 Better support for WinRT 2018-02-23 18:16:43 +02:00
gabime
a8b5bb894e fixed cmake for tests 2018-02-23 16:49:26 +02:00
gabime
3620b31ef2 added pattern formatter tests 2018-02-23 16:40:45 +02:00
gabime
7709fc70eb small fix to pattern_formatter ctor 2018-02-23 15:10:21 +02:00
Gabi Melman
bce33698be
Merge pull request #628 from emadwill/eol
Support for custom EOL per formatter -Thanks @emadwill
2018-02-23 15:11:10 +02:00
gabime
04d0dd5987 moved SPDLOG_VERSION macro to common.h 2018-02-23 14:39:41 +02:00
gabime
051048ebd7 Fixed issue #645 (include tweakme.h from common.h) 2018-02-23 14:34:25 +02:00
gabime
7fe3912f12 astyle 2018-02-23 14:29:31 +02:00
gabime
7eb41ccf0f Use -O3 flag in tests 2018-02-23 14:29:14 +02:00
gabime
79d55fd802 Merge branch 'master' of https://github.com/gabime/spdlog 2018-02-23 14:07:45 +02:00
gabime
6df52df5b4 Use emplace_back in pattern_formatter 2018-02-23 14:05:48 +02:00
gabime
bdca50e6a7 Fixed issue #637 2018-02-23 13:26:53 +02:00
Gabi Melman
851b49e147
Update CMakeLists.txt 2018-02-22 13:37:50 +02:00
Gabi Melman
e64847bd09
Merge pull request #644 from grzadr/patch-1
Fix indentation in tests/catch.hpp:2916
2018-02-22 11:44:55 +02:00
grzadr
8e861728a0
Fix indentation in line 2916
Compiling with -Wmisleading-indentation triggers warning:
/data/Git/spdlog/tests/catch.hpp: In member function ‘bool Catch::TestSpec::Filter::matches(const Catch::TestCaseInfo&) const’:
/data/Git/spdlog/tests/catch.hpp:2913:17: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
                 for( std::vector<Ptr<Pattern> >::const_iterator it = m_patterns.begin(), itEnd = m_patterns.end(); it != itEnd; ++it )
                 ^~~
/data/Git/spdlog/tests/catch.hpp:2916:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
                     return true;
                     ^~~~~~
2018-02-22 09:46:54 +01:00
Gabi Melman
8cfd71a9be
Merge pull request #635 from DanielChabrowski/cmake_explicit_lang
CMake explicit language
2018-02-12 01:16:49 +02:00
Daniel Chabrowski
5d08bd1709 Bump example's cmake version to 3.1
CMake 3.1 is used in main CMakeLists file, no reason not to use it in example.
Threads::Threads is introduced in cmake 3.1.
2018-02-11 21:16:15 +01:00
Daniel Chabrowski
646a140ed4 Specify CXX language explicitly in CMake
Marking project as CXX will disable detecting C compiler and other checks.
Removed 'INCLUDES DESTINATION' as it made the include path appear doubled.
2018-02-11 21:13:33 +01:00
Gabi Melman
5eef243ab6
Merge pull request #634 from ColinDuquesnoy/patch-1
Fix compilation error with GCC 8
2018-02-10 19:05:33 +02:00
Colin Duquesnoy
11ee6834f6
Fix compilation error with GCC 8
error: need 'typename' before 'std::conditional<std::is_same<char, char>::value, fmt::BasicMemoryWriter<char>, fmt::BasicMemoryWriter<wchar_t> >::type' because 'std::conditional<std::is_same<char, char>::value, fmt::BasicMemoryWriter<char>, fmt::BasicMemoryWriter<wchar_t> >' is a dependent scope
         std::conditional<std::is_same<filename_t::value_type, char>::value, fmt::MemoryWriter, fmt::WMemoryWriter>::type w;
2018-02-10 15:15:46 +01:00
Gabi Melman
c07e81a049
Merge pull request #632 from bschindler/wincolor_set_color_public
Make set_color public in wincolor_sink to retain configurability
2018-02-08 11:04:29 +02:00
Benjamin Schindler
05b2aabe0e Make set_color public in wincolor_sink to retain configurability 2018-02-08 09:14:45 +01:00
Emad William Farag
55680db160 Support for custom EOL per formatter 2018-02-05 21:51:01 -05:00
Fernando Gomes
f4ffddc942
Merge branch 'master' into to_level 2018-02-05 09:52:30 -02:00
gabime
5ab033fba5 Fix issue #629 2018-02-05 12:20:57 +02:00
Gabi Melman
1dfc8282df
Merge pull request #624 from yisonPylkita/modern_cmake_tests
Modern CMake in /tests
2018-02-03 19:10:44 +02:00
gabime
f8aec1bdf1 Merge branch 'master' of https://github.com/gabime/spdlog.git 2018-02-03 18:58:10 +02:00
gabime
51a83da578 Repplaced map with unordered_map for level->colos mapping 2018-02-03 18:57:57 +02:00
yisonPylkita
38ccd51399 Modern CMake in /tests 2018-01-28 00:49:03 +01:00
fegomes
8696ad8739 new function to convert level_enum from string 2018-01-24 23:08:46 -02:00
Gabi Melman
c336470320
Merge pull request #621 from rcarmich/fix_example_spelling_errors
Fixed spelling mistake in example.cpp
2018-01-24 22:42:31 +02:00
Ryan Carmichael
da51d8dfd3 Fixed spelling mistake in example.cpp 2018-01-24 14:18:05 -06:00
Gabi Melman
22fdd3bf0f
Merge pull request #615 from Qix-/master
A few small ANSI color improvements
2018-01-18 22:01:46 +02:00
Josh Junon
cae749fc9b clear line after writing log message contents 2018-01-18 15:06:47 +01:00
Josh Junon
58e68725ae rename grey to black 2018-01-18 15:03:26 +01:00
Josh Junon
a59f74e8a2 remove needless zeros in reset code 2018-01-18 15:03:03 +01:00
Gabi Melman
f258af4364
Update CMakeLists.txt 2018-01-12 16:06:30 +02:00
gabime
ccd675a286 version 0.16.3 2018-01-12 14:09:34 +02:00
gabime
5372d58adc comment 2018-01-12 14:09:07 +02:00
Gabi Melman
751520f0cf
Merge pull request #610 from joaomoreno/fix609
Use Sleep in Windows instead of sleep_for
2018-01-11 23:09:38 +02:00
Joao Moreno
357a63d914 fix spdlog namespace 2018-01-11 21:58:02 +01:00
Joao Moreno
a938045135 use Sleep in Windows instead of sleep_for
fixes #609
2018-01-11 14:50:47 +01:00
Gabi Melman
32177aa77a
Merge pull request #604 from sam-lunt/improve-macros
Ensure marcos always expand to expressions
2018-01-03 18:05:25 +02:00
Gabi Melman
ce1df17262
Merge pull request #605 from sam-lunt/add-flush-on
Add global flush_on function
2018-01-03 18:00:08 +02:00
Sam Lunt
9f8413308a add global flush_on function 2018-01-03 09:36:09 -06:00
Sam Lunt
f25f0e0e40 add (void)0 when logging is disabled 2018-01-03 09:07:58 -06:00
Gabi Melman
a2890f2778
Merge pull request #596 from Broekman/master
Issue fix for spdlog #595. Conversion warning.
2017-12-26 21:22:08 +02:00
Stefan Broekman
de4644b44a Issue fix for spdlog #595. Conversion warning.
See: https://github.com/gabime/spdlog/issues/595

On line 85 in file sinks/wincolor_sink.h:
back_color &= ~(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE |
FOREGROUND_INTENSITY);

'back_color' is of type 'WORD' (unsigned short) whereas a bitwise
complement/NOT returns an int. This results in a conversion warning with
-Wconversion enabled.

85:20: warning: conversion to 'WORD {aka short unsigned int}' from 'int'
may alter its value [-Wconversion] back_color &= ~(FOREGROUND_RED |
FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);

Possible solution:
We know that the result of ~(FOREGROUND_RED | FOREGROUND_GREEN |
FOREGROUND_BLUE | FOREGROUND_INTENSITY) is always within the limits of
an unsigned short so a simple cast should suffice (correct me if I'm
wrong):

back_color &= static_cast<unsigned short>(~(FOREGROUND_RED |
FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY));
2017-12-26 19:23:29 +01:00
Gabi Melman
03db102375
Update README.md 2017-12-26 13:26:04 +02:00
gabime
3d967dd716 added catch license in tests folder 2017-12-24 19:37:54 +02:00
Gabi Melman
b53d207f44
Update file_helper.h 2017-12-23 11:43:41 +02:00
Gabi Melman
fde12195ee
Update file_helper.h 2017-12-22 19:06:01 +02:00
gabime
4ca6991828 astyle 2017-12-22 18:55:19 +02:00
gabime
813dcbcf63 version 0.16.2 2017-12-22 18:50:08 +02:00
gabime
7663f58379 Fixed file_helper::split_by_extenstion tests for gcc 2017-12-22 18:48:02 +02:00
gabime
8e3f968ba4 Fixed file_helper::split_by_extenstion and added more tests for it 2017-12-22 18:41:03 +02:00
gabime
f695e536dd Fixed file_helper::split_by_extenstion and added more tests for it 2017-12-22 18:37:51 +02:00
gabime
f257e4ea8c gitignore tests/logs 2017-12-22 18:36:54 +02:00
gabime
0ed3e4cf76 Merge branch 'master' of https://github.com/gabime/spdlog 2017-12-22 14:38:54 +02:00
gabime
6d355fd602 report about unknown excepptions before rethrow 2017-12-22 14:38:44 +02:00
Gabi Melman
dd0b7b2d13
Merge pull request #590 from fcharlie/master
fix split_by_extenstion parse error extenstion
2017-12-22 12:50:52 +02:00
Force Charlie
42e5d98a48 fix split_by_extenstion parse error extenstion 2017-12-22 17:52:50 +08:00
Gabi Melman
c060a10c10
update to version 0.16.1 2017-12-20 10:08:49 +02:00
Gabi Melman
79a3a633c7
uupdate version to 0.16.1 2017-12-20 10:07:50 +02:00
Gabi Melman
52dfd478d6
Merge pull request #584 from horar/master
Update version strings to 0.16.0
2017-12-20 10:02:17 +02:00
Gabi Melman
48eca46680
Merge pull request #586 from horar/fix/warnings
Solve compiler warning in tests
2017-12-20 09:50:34 +02:00
Ľubomír Carik
f93277d271 Solve compiler warning in tests
Signed-off-by: Ľubomír Carik <Lubomir.Carik@anritsu.com>
2017-12-20 04:34:08 +01:00
Ľubomír Carik
dda8af0092 Update version strings to 0.16.0
Signed-off-by: Ľubomír Carik <Lubomir.Carik@anritsu.com>
2017-12-20 03:43:47 +01:00
236 changed files with 32285 additions and 23578 deletions

19
.clang-format Normal file
View File

@ -0,0 +1,19 @@
---
Language: Cpp
BasedOnStyle: Google
AccessModifierOffset: -4
Standard: c++17
IndentWidth: 4
TabWidth: 4
UseTab: Never
ColumnLimit: 100
AlignAfterOpenBracket: Align
BinPackParameters: false
AlignEscapedNewlines: Left
AlwaysBreakTemplateDeclarations: Yes
PackConstructorInitializers: Never
BreakConstructorInitializersBeforeComma: false
IndentPPDirectives: BeforeHash
SortIncludes: Never
...

53
.clang-tidy Normal file
View File

@ -0,0 +1,53 @@
Checks: 'cppcoreguidelines-*,
performance-*,
modernize-*,
google-*,
misc-*
cert-*,
readability-*,
clang-analyzer-*,
-performance-unnecessary-value-param,
-modernize-use-trailing-return-type,
-google-runtime-references,
-misc-non-private-member-variables-in-classes,
-readability-braces-around-statements,
-google-readability-braces-around-statements,
-cppcoreguidelines-avoid-magic-numbers,
-readability-magic-numbers,
-readability-magic-numbers,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-avoid-c-arrays,
-modernize-avoid-c-arrays,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-readability-named-parameter,
-cert-env33-c
'
WarningsAsErrors: ''
HeaderFilterRegex: '*spdlog/[^f].*'
FormatStyle: none
CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'

6
.git-blame-ignore-revs Normal file
View File

@ -0,0 +1,6 @@
# clang-format
1a0bfc7a89f2d58e22605a4dc7e18a9a555b65aa
95c226e9c92928e20ccdac0d060e7241859e282b
9d52261185b5f2c454c381d626ec5c84d7b195f4
4b2a8219d5d1b40062d030441adde7d1fb0d4f84
0a53eafe18d983c7c8ba4cadd02d0cc7f7308f28

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
* text=false

87
.github/workflows/linux.yml vendored Normal file
View File

@ -0,0 +1,87 @@
name: linux
on: [push, pull_request]
permissions:
contents: read
jobs:
# -----------------------------------------------------------------------
# Linux build matrix
# -----------------------------------------------------------------------
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
config:
- { compiler: gcc, version: 7, build_type: Release, cppstd: 11 }
- { compiler: gcc, version: 9, build_type: Release, cppstd: 17 }
- { compiler: gcc, version: 11, build_type: Debug, cppstd: 20 }
- { compiler: gcc, version: 12, build_type: Release, cppstd: 20 }
- { compiler: gcc, version: 12, build_type: Debug, cppstd: 20, asan: ON }
- { compiler: clang, version: 12, build_type: Debug, cppstd: 17 }
- { compiler: clang, version: 15, build_type: Release, cppstd: 20, tsan: ON }
container:
image: ${{ matrix.config.compiler == 'clang' && 'teeks99/clang-ubuntu' || matrix.config.compiler }}:${{ matrix.config.version }}
name: "${{ matrix.config.compiler}} ${{ matrix.config.version }} (C++${{ matrix.config.cppstd }} ${{ matrix.config.build_type }} ${{ matrix.config.asan == 'ON' && 'ASAN' || '' }}${{ matrix.config.tsan == 'ON' && 'TSAN' || '' }})"
steps:
- uses: actions/checkout@v4
- name: Setup
run: |
apt-get update
apt-get install -y curl git pkg-config libsystemd-dev
CMAKE_VERSION="3.24.2"
curl -sSL https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.sh -o install-cmake.sh
chmod +x install-cmake.sh
./install-cmake.sh --prefix=/usr/local --skip-license
- name: Setup Compiler
if: matrix.config.compiler == 'clang'
run: |
scripts/ci_setup_clang.sh "${{ matrix.config.version }}"
echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV
echo "CC=clang-${{ matrix.config.version }}" >> $GITHUB_ENV
echo "CXX=clang++-${{ matrix.config.version }}" >> $GITHUB_ENV
- name: Build
run: |
mkdir -p build && cd build
cmake .. \
-DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \
-DCMAKE_CXX_STANDARD=${{ matrix.config.cppstd }} \
-DSPDLOG_BUILD_EXAMPLE=${{ matrix.config.examples || 'ON' }} \
-DSPDLOG_BUILD_EXAMPLE_HO=${{ matrix.config.examples || 'ON' }} \
-DSPDLOG_BUILD_WARNINGS=ON \
-DSPDLOG_BUILD_BENCH=OFF \
-DSPDLOG_BUILD_TESTS=ON \
-DSPDLOG_BUILD_TESTS_HO=OFF \
-DSPDLOG_SANITIZE_ADDRESS=${{ matrix.config.asan || 'OFF' }} \
-DSPDLOG_SANITIZE_THREAD=${{ matrix.config.tsan || 'OFF' }}
make -j 4
ctest -j 4 --output-on-failure
# -----------------------------------------------------------------------
# OS X build matrix
# -----------------------------------------------------------------------
build_osx:
runs-on: macOS-latest
name: "OS X Clang (C++11, Release)"
steps:
- uses: actions/checkout@v4
- name: Build
run: |
mkdir -p build && cd build
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=11 \
-DSPDLOG_BUILD_EXAMPLE=ON \
-DSPDLOG_BUILD_EXAMPLE_HO=ON \
-DSPDLOG_BUILD_WARNINGS=ON \
-DSPDLOG_BUILD_BENCH=OFF \
-DSPDLOG_BUILD_TESTS=ON \
-DSPDLOG_BUILD_TESTS_HO=OFF \
-DSPDLOG_SANITIZE_ADDRESS=OFF
make -j 4
ctest -j 4 --output-on-failure

38
.github/workflows/macos.yml vendored Normal file
View File

@ -0,0 +1,38 @@
name: macos
on: [push, pull_request]
permissions:
contents: read
jobs:
build:
runs-on: macOS-latest
name: "macOS Clang (C++11, Release)"
strategy:
fail-fast: true
matrix:
config:
- USE_STD_FORMAT: 'ON'
BUILD_EXAMPLE: 'OFF'
- USE_STD_FORMAT: 'OFF'
BUILD_EXAMPLE: 'ON'
steps:
- uses: actions/checkout@v4
- name: Build
run: |
mkdir -p build && cd build
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=11 \
-DSPDLOG_BUILD_EXAMPLE=${{ matrix.config.BUILD_EXAMPLE }} \
-DSPDLOG_BUILD_EXAMPLE_HO=${{ matrix.config.BUILD_EXAMPLE }} \
-DSPDLOG_BUILD_WARNINGS=ON \
-DSPDLOG_BUILD_BENCH=OFF \
-DSPDLOG_BUILD_TESTS=ON \
-DSPDLOG_BUILD_TESTS_HO=OFF \
-DSPDLOG_USE_STD_FORMAT=${{ matrix.config.USE_STD_FORMAT }} \
-DSPDLOG_SANITIZE_ADDRESS=OFF
make -j 4
ctest -j 4 --output-on-failure

148
.github/workflows/windows.yml vendored Normal file
View File

@ -0,0 +1,148 @@
name: windows
on: [push, pull_request]
permissions:
contents: read
jobs:
build:
runs-on: windows-latest
strategy:
fail-fast: true
matrix:
config:
- GENERATOR: "Visual Studio 17 2022"
BUILD_TYPE: Release
BUILD_SHARED: 'ON'
FATAL_ERRORS: 'ON'
WCHAR: 'OFF'
WCHAR_FILES: 'OFF'
BUILD_EXAMPLE: 'OFF'
USE_STD_FORMAT: 'ON'
CXX_STANDARD: 20
- GENERATOR: "Visual Studio 17 2022"
BUILD_TYPE: Release
BUILD_SHARED: 'ON'
FATAL_ERRORS: 'ON'
WCHAR: 'ON'
WCHAR_FILES: 'ON'
BUILD_EXAMPLE: 'OFF'
USE_STD_FORMAT: 'ON'
CXX_STANDARD: 20
- GENERATOR: "Visual Studio 17 2022"
BUILD_TYPE: Release
BUILD_SHARED: 'ON'
FATAL_ERRORS: 'ON'
WCHAR: 'OFF'
WCHAR_FILES: 'OFF'
BUILD_EXAMPLE: 'ON'
USE_STD_FORMAT: 'OFF'
CXX_STANDARD: 17
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: CMake ${{ matrix.config.GENERATOR }} CXX=${{matrix.config.CXX_STANDARD}} WCHAR=${{matrix.config.WCHAR_FILES}} STD_FORMAT=${{matrix.config.USE_STD_FORMAT}}
shell: pwsh
run: |
mkdir build
cd build
cmake -G "${{ matrix.config.GENERATOR }}" -A x64 `
-D CMAKE_BUILD_TYPE=${{ matrix.config.BUILD_TYPE }} `
-D BUILD_SHARED_LIBS=${{ matrix.config.BUILD_SHARED }} `
-D SPDLOG_WCHAR_SUPPORT=${{ matrix.config.WCHAR }} `
-D SPDLOG_WCHAR_FILENAMES=${{ matrix.config.WCHAR_FILES }} `
-D SPDLOG_BUILD_EXAMPLE=${{ matrix.config.BUILD_EXAMPLE }} `
-D SPDLOG_BUILD_EXAMPLE_HO=${{ matrix.config.BUILD_EXAMPLE }} `
-D SPDLOG_BUILD_TESTS=ON `
-D SPDLOG_BUILD_TESTS_HO=OFF `
-D SPDLOG_BUILD_WARNINGS=${{ matrix.config.FATAL_ERRORS }} `
-D SPDLOG_USE_STD_FORMAT=${{ matrix.config.USE_STD_FORMAT }} `
-D CMAKE_CXX_STANDARD=${{ matrix.config.CXX_STANDARD }} ..
- name: Build
shell: pwsh
run: |
cd build
cmake --build . --parallel --config ${{ matrix.config.BUILD_TYPE }}
- name: Run Tests
shell: pwsh
env:
PATH: ${{ env.PATH }};${{ github.workspace }}\build\_deps\catch2-build\src\${{ matrix.config.BUILD_TYPE }};${{ github.workspace }}\build\${{ matrix.config.BUILD_TYPE }}
run: |
build\tests\${{ matrix.config.BUILD_TYPE }}\spdlog-utests.exe
# -----------------------------------------------------------------------
# MSVC 2019 build matrix
# -----------------------------------------------------------------------
build_2019:
runs-on: windows-2019
strategy:
fail-fast: true
matrix:
config:
- GENERATOR: "Visual Studio 16 2019"
BUILD_TYPE: Release
BUILD_SHARED: 'ON'
FATAL_ERRORS: 'ON'
WCHAR: 'OFF'
WCHAR_FILES: 'OFF'
BUILD_EXAMPLE: 'ON'
USE_STD_FORMAT: 'OFF'
CXX_STANDARD: 17
- GENERATOR: "Visual Studio 16 2019"
BUILD_TYPE: Release
BUILD_SHARED: 'ON'
FATAL_ERRORS: 'ON'
WCHAR: 'OFF'
WCHAR_FILES: 'OFF'
BUILD_EXAMPLE: 'ON'
USE_STD_FORMAT: 'OFF'
CXX_STANDARD: 14
- GENERATOR: "Visual Studio 16 2019"
BUILD_TYPE: Release
BUILD_SHARED: 'ON'
FATAL_ERRORS: 'ON'
WCHAR: 'OFF'
WCHAR_FILES: 'OFF'
BUILD_EXAMPLE: 'ON'
USE_STD_FORMAT: 'OFF'
CXX_STANDARD: 11
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: CMake ${{ matrix.config.GENERATOR }} CXX=${{matrix.config.CXX_STANDARD}} WCHAR=${{matrix.config.WCHAR_FILES}} STD_FORMAT=${{matrix.config.USE_STD_FORMAT}}
shell: pwsh
run: |
mkdir build
cd build
cmake -G "${{ matrix.config.GENERATOR }}" -A x64 `
-D CMAKE_BUILD_TYPE=${{ matrix.config.BUILD_TYPE }} `
-D BUILD_SHARED_LIBS=${{ matrix.config.BUILD_SHARED }} `
-D SPDLOG_WCHAR_SUPPORT=${{ matrix.config.WCHAR }} `
-D SPDLOG_WCHAR_FILENAMES=${{ matrix.config.WCHAR_FILES }} `
-D SPDLOG_BUILD_EXAMPLE=${{ matrix.config.BUILD_EXAMPLE }} `
-D SPDLOG_BUILD_EXAMPLE_HO=${{ matrix.config.BUILD_EXAMPLE }} `
-D SPDLOG_BUILD_TESTS=ON `
-D SPDLOG_BUILD_TESTS_HO=OFF `
-D SPDLOG_BUILD_WARNINGS=${{ matrix.config.FATAL_ERRORS }} `
-D SPDLOG_USE_STD_FORMAT=${{ matrix.config.USE_STD_FORMAT }} `
-D CMAKE_CXX_STANDARD=${{ matrix.config.CXX_STANDARD }} ..
- name: Build
shell: pwsh
run: |
cd build
cmake --build . --parallel --config ${{ matrix.config.BUILD_TYPE }}
- name: Run Tests
shell: pwsh
env:
PATH: ${{ env.PATH }};${{ github.workspace }}\build\_deps\catch2-build\src\${{ matrix.config.BUILD_TYPE }};${{ github.workspace }}\build\${{ matrix.config.BUILD_TYPE }}
run: |
build\tests\${{ matrix.config.BUILD_TYPE }}\spdlog-utests.exe

33
.gitignore vendored
View File

@ -1,4 +1,7 @@
# Auto generated files
[Dd]ebug/
[Rr]elease/
build/*
*.slo
*.lo
*.o
@ -33,6 +36,9 @@
# Codelite
.codelite
# KDevelop
*.kdev4
# .orig files
*.orig
@ -45,11 +51,13 @@ example/*
!example/example.sln
!example/example.vcxproj
!example/CMakeLists.txt
!example/meson.build
!example/multisink.cpp
!example/jni
# generated files
generated
version.rc
# Cmake
CMakeCache.txt
@ -61,7 +69,30 @@ install_manifest.txt
/tests/tests.VC.VC.opendb
/tests/tests.VC.db
/tests/tests
/tests/logs/file_helper_test.txt
/tests/logs/*
spdlogConfig.cmake
spdlogConfigVersion.cmake
compile_commands.json
# idea
.idea/
.cache/
.vscode/
cmake-build-*/
*.db
*.ipch
*.filters
*.db-wal
*.opendb
*.db-shm
*.vcxproj
*.tcl
*.user
*.sln
# macos
*.DS_store
*.xcodeproj/
/.vs
/out/build
/CMakeSettings.json

View File

@ -1,91 +0,0 @@
# Adapted from various sources, including:
# - Louis Dionne's Hana: https://github.com/ldionne/hana
# - Paul Fultz II's FIT: https://github.com/pfultz2/Fit
# - Eric Niebler's range-v3: https://github.com/ericniebler/range-v3
language: cpp
# Test matrix:
# - Build matrix per compiler: C++11/C++14 + Debug/Release
# - Optionally: AddressSanitizer (ASAN)
# - Valgrind: all release builds are also tested with valgrind
# - clang 3.4, 3.5, 3.6, trunk
# - Note: 3.4 and trunk are tested with/without ASAN,
# the rest is only tested with ASAN=On.
# - gcc 4.9, 5.0
#
matrix:
include:
# Test gcc-4.8: C++11, Build=Debug/Release, ASAN=Off
- env: GCC_VERSION=4.8 BUILD_TYPE=Debug CPP=11 ASAN=Off LIBCXX=Off
os: linux
addons: &gcc48
apt:
packages:
- g++-4.8
- valgrind
sources:
- ubuntu-toolchain-r-test
- env: GCC_VERSION=4.8 BUILD_TYPE=Release CPP=11 ASAN=Off LIBCXX=Off
os: linux
addons: *gcc48
# Test gcc-4.9: C++11, Build=Debug/Release, ASAN=Off
- env: GCC_VERSION=4.9 BUILD_TYPE=Debug CPP=11 ASAN=Off LIBCXX=Off
os: linux
addons: &gcc49
apt:
packages:
- g++-4.9
- valgrind
sources:
- ubuntu-toolchain-r-test
- env: GCC_VERSION=4.9 BUILD_TYPE=Release CPP=11 ASAN=Off LIBCXX=Off
os: linux
addons: *gcc49
# Install dependencies
before_install:
- export CHECKOUT_PATH=`pwd`;
- if [ -n "$GCC_VERSION" ]; then export CXX="g++-${GCC_VERSION}" CC="gcc-${GCC_VERSION}"; fi
- if [ -n "$CLANG_VERSION" ]; then export CXX="clang++-${CLANG_VERSION}" CC="clang-${CLANG_VERSION}"; fi
- if [ "$CLANG_VERSION" == "3.4" ]; then export CXX="/usr/local/clang-3.4/bin/clang++" CC="/usr/local/clang-3.4/bin/clang"; fi
- which $CXX
- which $CC
- which valgrind
- if [ -n "$CLANG_VERSION" ]; then sudo CXX=$CXX CC=$CC ./tests/install_libcxx.sh; fi
install:
- cd $CHECKOUT_PATH
# Workaround for valgrind bug: https://bugs.kde.org/show_bug.cgi?id=326469.
# It is fixed in valgrind 3.10 so this won't be necessary if someone
# replaces the current valgrind (3.7) with valgrind-3.10
- sed -i 's/march=native/msse4.2/' example/Makefile
- if [ ! -d build ]; then mkdir build; fi
- export CXX_FLAGS="-I${CHECKOUT_PATH}/include"
- export CXX_LINKER_FLAGS=""
- if [ -z "$BUILD_TYPE" ]; then export BUILD_TYPE=Release; fi
- if [ "$ASAN" == "On"]; then export CXX_FLAGS="${CXX_FLAGS} -fsanitize=address,undefined,integer -fno-omit-frame-pointer -fno-sanitize=unsigned-integer-overflow"; fi
- if [ -n "$CLANG_VERSION" ]; then CXX_FLAGS="${CXX_FLAGS} -D__extern_always_inline=inline"; fi
- if [ "$LIBCXX" == "On" ]; then CXX_FLAGS="${CXX_FLAGS} -stdlib=libc++ -I/usr/include/c++/v1/"; fi
- if [ "$LIBCXX" == "On" ]; then CXX_LINKER_FLAGS="${CXX_FLAGS} -L/usr/lib/ -lc++"; fi
- CXX_FLAGS="${CXX_FLAGS} -std=c++${CPP}"
# Build examples
- cd example
- if [ "$BUILD_TYPE" == "Release" ]; then make rebuild CXXFLAGS="${CXX_FLAGS} ${CXX_LINKER_FLAGS}" VERBOSE=1; export BIN=example; fi
- if [ "$BUILD_TYPE" == "Debug" ]; then make rebuild debug CXXFLAGS="${CXX_FLAGS} ${CXX_LINKER_FLAGS}" VERBOSE=1; export BIN=example-debug; fi
script:
- ./"${BIN}"
- valgrind --trace-children=yes --leak-check=full ./"${BIN}"
- cd $CHECKOUT_PATH/tests; make rebuild; ./tests
- cd $CHECKOUT_PATH/tests; STYLE=printf make rebuild; ./tests
notifications:
email: false

View File

@ -1,116 +1,404 @@
#
# Copyright(c) 2015 Ruslan Baratov.
# Distributed under the MIT License (http://opensource.org/licenses/MIT)
#
# Copyright(c) 2019 spdlog authors Distributed under the MIT License (http://opensource.org/licenses/MIT)
cmake_minimum_required(VERSION 3.10...3.21)
# ---------------------------------------------------------------------------------------
# Start spdlog project
# ---------------------------------------------------------------------------------------
include(cmake/utils.cmake)
include(cmake/ide.cmake)
spdlog_extract_version()
project(spdlog VERSION ${SPDLOG_VERSION} LANGUAGES CXX)
message(STATUS "Build spdlog: ${SPDLOG_VERSION}")
cmake_minimum_required(VERSION 3.1)
project(spdlog VERSION 0.14.0)
include(CTest)
include(CMakeDependentOption)
include(GNUInstallDirs)
# ---------------------------------------------------------------------------------------
# compiler config
# Set default build to release
# ---------------------------------------------------------------------------------------
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE)
endif ()
# ---------------------------------------------------------------------------------------
# Compiler config
# ---------------------------------------------------------------------------------------
if (SPDLOG_USE_STD_FORMAT)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
elseif (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif ()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_EXTENSIONS OFF)
if (CMAKE_SYSTEM_NAME MATCHES "CYGWIN" OR CMAKE_SYSTEM_NAME MATCHES "MSYS" OR CMAKE_SYSTEM_NAME MATCHES "MINGW")
set(CMAKE_CXX_EXTENSIONS ON)
endif ()
# ---------------------------------------------------------------------------------------
# spdlog target
# Set SPDLOG_MASTER_PROJECT to ON if we are building spdlog
# ---------------------------------------------------------------------------------------
add_library(spdlog INTERFACE)
# Check if spdlog is being used directly or via add_subdirectory, but allow overriding
if (NOT DEFINED SPDLOG_MASTER_PROJECT)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(SPDLOG_MASTER_PROJECT ON)
else ()
set(SPDLOG_MASTER_PROJECT OFF)
endif ()
endif ()
option(SPDLOG_BUILD_EXAMPLES "Build examples" OFF)
cmake_dependent_option(SPDLOG_BUILD_TESTING
"Build spdlog tests" ON
"BUILD_TESTING" OFF
)
option(SPDLOG_BUILD_ALL "Build all artifacts" OFF)
# build shared option
option(SPDLOG_BUILD_SHARED "Build shared library" OFF)
# precompiled headers option
option(SPDLOG_ENABLE_PCH "Build static or shared library using precompiled header to speed up compilation time" OFF)
# build position independent code
option(SPDLOG_BUILD_PIC "Build position independent code (-fPIC)" OFF)
# example options
option(SPDLOG_BUILD_EXAMPLE "Build example" ${SPDLOG_MASTER_PROJECT})
option(SPDLOG_BUILD_EXAMPLE_HO "Build header only example" OFF)
# testing options
option(SPDLOG_BUILD_TESTS "Build tests" OFF)
option(SPDLOG_BUILD_TESTS_HO "Build tests using the header only version" OFF)
# bench options
option(SPDLOG_BUILD_BENCH "Build benchmarks (Requires https://github.com/google/benchmark.git to be installed)" OFF)
# sanitizer options
option(SPDLOG_SANITIZE_ADDRESS "Enable address sanitizer in tests" OFF)
option(SPDLOG_SANITIZE_THREAD "Enable thread sanitizer in tests" OFF)
if (SPDLOG_SANITIZE_ADDRESS AND SPDLOG_SANITIZE_THREAD)
message(FATAL_ERROR "SPDLOG_SANITIZE_ADDRESS and SPDLOG_SANITIZE_THREAD are mutually exclusive")
endif ()
# warning options
option(SPDLOG_BUILD_WARNINGS "Enable compiler warnings" OFF)
# install options
option(SPDLOG_SYSTEM_INCLUDES "Include as system headers (skip for clang-tidy)." OFF)
option(SPDLOG_INSTALL "Generate the install target" ${SPDLOG_MASTER_PROJECT})
option(SPDLOG_USE_STD_FORMAT "Use std::format instead of fmt library." OFF)
option(SPDLOG_FMT_EXTERNAL "Use external fmt library instead of bundled" OFF)
option(SPDLOG_FMT_EXTERNAL_HO "Use external fmt header-only library instead of bundled" OFF)
option(SPDLOG_NO_EXCEPTIONS "Compile with -fno-exceptions. Call abort() on any spdlog exceptions" OFF)
if (SPDLOG_FMT_EXTERNAL AND SPDLOG_FMT_EXTERNAL_HO)
message(FATAL_ERROR "SPDLOG_FMT_EXTERNAL and SPDLOG_FMT_EXTERNAL_HO are mutually exclusive")
endif ()
if (SPDLOG_USE_STD_FORMAT AND SPDLOG_FMT_EXTERNAL_HO)
message(FATAL_ERROR "SPDLOG_USE_STD_FORMAT and SPDLOG_FMT_EXTERNAL_HO are mutually exclusive")
endif ()
if (SPDLOG_USE_STD_FORMAT AND SPDLOG_FMT_EXTERNAL)
message(FATAL_ERROR "SPDLOG_USE_STD_FORMAT and SPDLOG_FMT_EXTERNAL are mutually exclusive")
endif ()
# misc tweakme options
if (WIN32)
option(SPDLOG_WCHAR_SUPPORT "Support wchar api" OFF)
option(SPDLOG_WCHAR_FILENAMES "Support wchar filenames" OFF)
option(SPDLOG_WCHAR_CONSOLE "Support wchar output to console" OFF)
else ()
set(SPDLOG_WCHAR_SUPPORT OFF CACHE BOOL "non supported option" FORCE)
set(SPDLOG_WCHAR_FILENAMES OFF CACHE BOOL "non supported option" FORCE)
set(SPDLOG_WCHAR_CONSOLE OFF CACHE BOOL "non supported option" FORCE)
endif ()
if (MSVC)
option(SPDLOG_MSVC_UTF8 "Enable/disable msvc /utf-8 flag required by fmt lib" ON)
endif ()
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
option(SPDLOG_CLOCK_COARSE "Use CLOCK_REALTIME_COARSE instead of the regular clock," OFF)
else ()
set(SPDLOG_CLOCK_COARSE OFF CACHE BOOL "non supported option" FORCE)
endif ()
option(SPDLOG_PREVENT_CHILD_FD "Prevent from child processes to inherit log file descriptors" OFF)
option(SPDLOG_NO_THREAD_ID "prevent spdlog from querying the thread id on each log call if thread id is not needed" OFF)
option(SPDLOG_NO_TLS "prevent spdlog from using thread local storage" OFF)
option(
SPDLOG_NO_ATOMIC_LEVELS
"prevent spdlog from using of std::atomic log levels (use only if your code never modifies log levels concurrently"
OFF)
option(SPDLOG_DISABLE_DEFAULT_LOGGER "Disable default logger creation" OFF)
option(SPDLOG_FWRITE_UNLOCKED "Use the unlocked variant of fwrite. Leave this on unless your libc doesn't have it" ON)
# clang-tidy
option(SPDLOG_TIDY "run clang-tidy" OFF)
if (SPDLOG_TIDY)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
message(STATUS "Enabled clang-tidy")
endif ()
if (SPDLOG_BUILD_PIC)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif ()
find_package(Threads REQUIRED)
message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
# ---------------------------------------------------------------------------------------
# Static/Shared library
# ---------------------------------------------------------------------------------------
set(SPDLOG_SRCS src/spdlog.cpp src/stdout_sinks.cpp src/color_sinks.cpp src/file_sinks.cpp src/async.cpp src/cfg.cpp)
if (NOT SPDLOG_USE_STD_FORMAT AND NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
list(APPEND SPDLOG_SRCS src/bundled_fmtlib_format.cpp)
endif ()
if (SPDLOG_BUILD_SHARED OR BUILD_SHARED_LIBS)
if (WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
list(APPEND SPDLOG_SRCS ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
endif ()
add_library(spdlog SHARED ${SPDLOG_SRCS} ${SPDLOG_ALL_HEADERS})
target_compile_definitions(spdlog PUBLIC SPDLOG_SHARED_LIB)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(spdlog PUBLIC $<$<AND:$<CXX_COMPILER_ID:MSVC>,$<NOT:$<COMPILE_LANGUAGE:CUDA>>>:/wd4251
/wd4275>)
endif ()
if (NOT SPDLOG_USE_STD_FORMAT AND NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
target_compile_definitions(spdlog PRIVATE FMT_LIB_EXPORT PUBLIC FMT_SHARED)
endif ()
else ()
add_library(spdlog STATIC ${SPDLOG_SRCS} ${SPDLOG_ALL_HEADERS})
endif ()
add_library(spdlog::spdlog ALIAS spdlog)
set(SPDLOG_INCLUDES_LEVEL "")
if (SPDLOG_SYSTEM_INCLUDES)
set(SPDLOG_INCLUDES_LEVEL "SYSTEM")
endif ()
target_compile_definitions(spdlog PUBLIC SPDLOG_COMPILED_LIB)
target_include_directories(spdlog ${SPDLOG_INCLUDES_LEVEL} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_link_libraries(spdlog PUBLIC Threads::Threads)
spdlog_enable_warnings(spdlog)
set_target_properties(spdlog PROPERTIES VERSION ${SPDLOG_VERSION} SOVERSION
${SPDLOG_VERSION_MAJOR}.${SPDLOG_VERSION_MINOR})
set_target_properties(spdlog PROPERTIES DEBUG_POSTFIX d)
if (COMMAND target_precompile_headers AND SPDLOG_ENABLE_PCH)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/pch.h.in ${PROJECT_BINARY_DIR}/spdlog_pch.h @ONLY)
target_precompile_headers(spdlog PRIVATE ${PROJECT_BINARY_DIR}/spdlog_pch.h)
endif ()
# sanitizer support
if (SPDLOG_SANITIZE_ADDRESS)
spdlog_enable_addr_sanitizer(spdlog)
elseif (SPDLOG_SANITIZE_THREAD)
spdlog_enable_thread_sanitizer(spdlog)
endif ()
# ---------------------------------------------------------------------------------------
# Header only version
# ---------------------------------------------------------------------------------------
add_library(spdlog_header_only INTERFACE)
add_library(spdlog::spdlog_header_only ALIAS spdlog_header_only)
target_include_directories(
spdlog
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
spdlog_header_only ${SPDLOG_INCLUDES_LEVEL} INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_link_libraries(spdlog_header_only INTERFACE Threads::Threads)
set(HEADER_BASE "${CMAKE_CURRENT_SOURCE_DIR}/include")
# ---------------------------------------------------------------------------------------
# Use fmt package if using external fmt
# ---------------------------------------------------------------------------------------
if (SPDLOG_FMT_EXTERNAL OR SPDLOG_FMT_EXTERNAL_HO)
if (NOT TARGET fmt::fmt)
find_package(fmt CONFIG REQUIRED)
endif ()
target_compile_definitions(spdlog PUBLIC SPDLOG_FMT_EXTERNAL)
target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_FMT_EXTERNAL)
if(SPDLOG_BUILD_EXAMPLES)
add_subdirectory(example)
# use external fmt-header-only
if (SPDLOG_FMT_EXTERNAL_HO)
target_link_libraries(spdlog PUBLIC fmt::fmt-header-only)
target_link_libraries(spdlog_header_only INTERFACE fmt::fmt-header-only)
else () # use external compile fmt
target_link_libraries(spdlog PUBLIC fmt::fmt)
target_link_libraries(spdlog_header_only INTERFACE fmt::fmt)
endif ()
if(SPDLOG_BUILD_TESTING)
set(PKG_CONFIG_REQUIRES fmt) # add dependency to pkg-config
endif ()
# ---------------------------------------------------------------------------------------
# Check if fwrite_unlocked/_fwrite_nolock is available
# ---------------------------------------------------------------------------------------
if (SPDLOG_FWRITE_UNLOCKED)
include(CheckSymbolExists)
if (WIN32)
check_symbol_exists(_fwrite_nolock "stdio.h" HAVE_FWRITE_UNLOCKED)
else ()
check_symbol_exists(fwrite_unlocked "stdio.h" HAVE_FWRITE_UNLOCKED)
endif ()
if (HAVE_FWRITE_UNLOCKED)
target_compile_definitions(spdlog PRIVATE SPDLOG_FWRITE_UNLOCKED)
target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_FWRITE_UNLOCKED)
endif ()
endif ()
# ---------------------------------------------------------------------------------------
# Add required libraries for Android CMake build
# ---------------------------------------------------------------------------------------
if (ANDROID)
target_link_libraries(spdlog PUBLIC log)
target_link_libraries(spdlog_header_only INTERFACE log)
endif ()
# ---------------------------------------------------------------------------------------
# Misc definitions according to tweak options
# ---------------------------------------------------------------------------------------
set(SPDLOG_WCHAR_TO_UTF8_SUPPORT ${SPDLOG_WCHAR_SUPPORT})
set(SPDLOG_UTF8_TO_WCHAR_CONSOLE ${SPDLOG_WCHAR_CONSOLE})
foreach (
SPDLOG_OPTION
SPDLOG_WCHAR_TO_UTF8_SUPPORT
SPDLOG_UTF8_TO_WCHAR_CONSOLE
SPDLOG_WCHAR_FILENAMES
SPDLOG_NO_EXCEPTIONS
SPDLOG_CLOCK_COARSE
SPDLOG_PREVENT_CHILD_FD
SPDLOG_NO_THREAD_ID
SPDLOG_NO_TLS
SPDLOG_NO_ATOMIC_LEVELS
SPDLOG_DISABLE_DEFAULT_LOGGER
SPDLOG_USE_STD_FORMAT)
if (${SPDLOG_OPTION})
target_compile_definitions(spdlog PUBLIC ${SPDLOG_OPTION})
target_compile_definitions(spdlog_header_only INTERFACE ${SPDLOG_OPTION})
endif ()
endforeach ()
if (MSVC)
target_compile_options(spdlog PRIVATE "/Zc:__cplusplus")
target_compile_options(spdlog_header_only INTERFACE "/Zc:__cplusplus")
if (SPDLOG_MSVC_UTF8)
# fmtlib requires the /utf-8 flag when building with msvc.
# see https://github.com/fmtlib/fmt/pull/4159 on the purpose of the additional
# "$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>"
target_compile_options(spdlog PUBLIC $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>:/utf-8>)
target_compile_options(spdlog_header_only INTERFACE $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>:/utf-8>)
endif ()
endif ()
# ---------------------------------------------------------------------------------------
# If exceptions are disabled, disable them in the bundled fmt as well
# ---------------------------------------------------------------------------------------
if (SPDLOG_NO_EXCEPTIONS)
if (NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
target_compile_definitions(spdlog PUBLIC FMT_USE_EXCEPTIONS=0)
endif ()
if (NOT MSVC)
target_compile_options(spdlog PRIVATE -fno-exceptions)
else ()
target_compile_options(spdlog PRIVATE /EHs-c-)
target_compile_definitions(spdlog PRIVATE _HAS_EXCEPTIONS=0)
endif ()
endif ()
# ---------------------------------------------------------------------------------------
# Build binaries
# ---------------------------------------------------------------------------------------
if (SPDLOG_BUILD_EXAMPLE OR SPDLOG_BUILD_EXAMPLE_HO OR SPDLOG_BUILD_ALL)
message(STATUS "Generating example(s)")
add_subdirectory(example)
spdlog_enable_warnings(example)
if (SPDLOG_BUILD_EXAMPLE_HO)
spdlog_enable_warnings(example_header_only)
endif ()
endif ()
if (SPDLOG_BUILD_TESTS OR SPDLOG_BUILD_TESTS_HO OR SPDLOG_BUILD_ALL)
message(STATUS "Generating tests")
enable_testing()
add_subdirectory(tests)
endif ()
if (SPDLOG_BUILD_BENCH OR SPDLOG_BUILD_ALL)
message(STATUS "Generating benchmarks")
add_subdirectory(bench)
endif ()
# ---------------------------------------------------------------------------------------
# Install/export targets and files
# Install
# ---------------------------------------------------------------------------------------
# set files and directories
set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(include_install_dir "${CMAKE_INSTALL_INCLUDEDIR}")
if (SPDLOG_INSTALL)
message(STATUS "Generating install")
set(project_config_in "${CMAKE_CURRENT_LIST_DIR}/cmake/spdlogConfig.cmake.in")
set(project_config_out "${CMAKE_CURRENT_BINARY_DIR}/spdlogConfig.cmake")
set(config_targets_file "spdlogConfigTargets.cmake")
set(version_config_file "${CMAKE_CURRENT_BINARY_DIR}/spdlogConfigVersion.cmake")
set(export_dest_dir "${CMAKE_INSTALL_LIBDIR}/cmake/spdlog")
set(pkgconfig_install_dir "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
set(version_config "${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
set(project_config "${PROJECT_NAME}Config.cmake")
set(pkg_config "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc")
set(targets_export_name "${PROJECT_NAME}Targets")
set(namespace "${PROJECT_NAME}::")
# generate package version file
# ---------------------------------------------------------------------------------------
# Include files
# ---------------------------------------------------------------------------------------
install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" PATTERN "fmt/bundled" EXCLUDE)
install(
TARGETS spdlog spdlog_header_only
EXPORT spdlog
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
if (NOT SPDLOG_USE_STD_FORMAT AND NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
install(DIRECTORY include/${PROJECT_NAME}/fmt/bundled/
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/fmt/bundled/")
endif ()
# ---------------------------------------------------------------------------------------
# Install pkg-config file
# ---------------------------------------------------------------------------------------
if (IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
set(PKG_CONFIG_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
else ()
set(PKG_CONFIG_INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
endif ()
if (IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
set(PKG_CONFIG_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
else ()
set(PKG_CONFIG_LIBDIR "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
endif ()
get_target_property(PKG_CONFIG_DEFINES spdlog INTERFACE_COMPILE_DEFINITIONS)
string(REPLACE ";" " -D" PKG_CONFIG_DEFINES "${PKG_CONFIG_DEFINES}")
string(CONCAT PKG_CONFIG_DEFINES "-D" "${PKG_CONFIG_DEFINES}")
configure_file("cmake/${PROJECT_NAME}.pc.in" "${pkg_config}" @ONLY)
install(FILES "${pkg_config}" DESTINATION "${pkgconfig_install_dir}")
# ---------------------------------------------------------------------------------------
# Install CMake config files
# ---------------------------------------------------------------------------------------
export(TARGETS spdlog spdlog_header_only NAMESPACE spdlog::
FILE "${CMAKE_CURRENT_BINARY_DIR}/${config_targets_file}")
install(EXPORT spdlog DESTINATION ${export_dest_dir} NAMESPACE spdlog:: FILE ${config_targets_file})
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${version_config}" COMPATIBILITY SameMajorVersion
)
configure_package_config_file("${project_config_in}" "${project_config_out}" INSTALL_DESTINATION ${export_dest_dir})
# configure pkg config file
configure_file("cmake/spdlog.pc.in" "${pkg_config}" @ONLY)
write_basic_package_version_file("${version_config_file}" COMPATIBILITY SameMajorVersion)
install(FILES "${project_config_out}" "${version_config_file}" DESTINATION "${export_dest_dir}")
# install targets
install(
TARGETS spdlog
EXPORT "${targets_export_name}"
INCLUDES DESTINATION "${include_install_dir}"
)
# install headers
install(
DIRECTORY "${HEADER_BASE}/${PROJECT_NAME}"
DESTINATION "${include_install_dir}"
)
# install project version file
install(
FILES "${version_config}"
DESTINATION "${config_install_dir}"
)
# install pkg config file
install(
FILES "${pkg_config}"
DESTINATION "${pkgconfig_install_dir}"
)
# install project config file
install(
EXPORT "${targets_export_name}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}"
FILE ${project_config}
)
# export build directory config file
export(
EXPORT ${targets_export_name}
NAMESPACE "${namespace}"
FILE ${project_config}
)
# register project in CMake user registry
export(PACKAGE ${PROJECT_NAME})
file(GLOB_RECURSE spdlog_include_SRCS "${HEADER_BASE}/*.h")
add_custom_target(spdlog_headers_for_ide SOURCES ${spdlog_include_SRCS})
# ---------------------------------------------------------------------------------------
# Support creation of installable packages
# ---------------------------------------------------------------------------------------
include(cmake/spdlogCPack.cmake)
endif ()

30
INSTALL
View File

@ -1,13 +1,27 @@
spdlog is header only library.
Just copy the files to your build tree and use a C++11 compiler
Header Only Version
==================================================================
Just copy the files to your build tree and use a C++11 compiler.
Or use CMake:
```
add_executable(example_header_only example.cpp)
target_link_libraries(example_header_only spdlog::spdlog_header_only)
```
Compiled Library Version
==================================================================
CMake:
```
add_executable(example example.cpp)
target_link_libraries(example spdlog::spdlog)
```
Or copy files src/*.cpp to your build tree and pass the -DSPDLOG_COMPILED_LIB to the compiler.
Important Information for Compilation:
==================================================================
* If you encounter compilation errors with gcc 4.8.x, please note that gcc 4.8.x does not fully support C++11. In such cases, consider upgrading your compiler or using a different version that fully supports C++11 standards
Tested on:
gcc 4.8.1 and above
clang 3.5
Visual Studio 2013
gcc 4.8 flags: --std==c++11 -pthread -O3 -flto -Wl,--no-as-needed
gcc 4.9 flags: --std=c++11 -pthread -O3 -flto
see the makefile in the example folder

View File

@ -20,3 +20,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-- NOTE: Third party dependency used by this software --
This software depends on the fmt lib (MIT License),
and users must comply to its license: https://raw.githubusercontent.com/fmtlib/fmt/master/LICENSE

670
README.md
View File

@ -1,221 +1,529 @@
# spdlog
Very fast, header only, C++ logging library. [![Build Status](https://travis-ci.org/gabime/spdlog.svg?branch=master)](https://travis-ci.org/gabime/spdlog)&nbsp; [![Build status](https://ci.appveyor.com/api/projects/status/d2jnxclg20vd0o50?svg=true)](https://ci.appveyor.com/project/gabime/spdlog)
[![ci](https://github.com/gabime/spdlog/actions/workflows/linux.yml/badge.svg)](https://github.com/gabime/spdlog/actions/workflows/linux.yml)&nbsp;
[![ci](https://github.com/gabime/spdlog/actions/workflows/windows.yml/badge.svg)](https://github.com/gabime/spdlog/actions/workflows/windows.yml)&nbsp;
[![ci](https://github.com/gabime/spdlog/actions/workflows/macos.yml/badge.svg)](https://github.com/gabime/spdlog/actions/workflows/macos.yml)&nbsp;
[![Build status](https://ci.appveyor.com/api/projects/status/d2jnxclg20vd0o50?svg=true&branch=v1.x)](https://ci.appveyor.com/project/gabime/spdlog) [![Release](https://img.shields.io/github/release/gabime/spdlog.svg)](https://github.com/gabime/spdlog/releases/latest)
Fast C++ logging library
## Install
#### Just copy the headers:
* Copy the source [folder](https://github.com/gabime/spdlog/tree/master/include/spdlog) to your build tree and use a C++11 compiler.
#### Or use your favorite package manager:
* Ubuntu: `apt-get install libspdlog-dev`
* Homebrew: `brew install spdlog`
* FreeBSD: `cd /usr/ports/devel/spdlog/ && make install clean`
* Fedora: `yum install spdlog`
* Gentoo: `emerge dev-libs/spdlog`
* Arch Linux: `yaourt -S spdlog-git`
* vcpkg: `vcpkg install spdlog`
#### Header-only version
Copy the include [folder](include/spdlog) to your build tree and use a C++11 compiler.
#### Compiled version (recommended - much faster compile times)
```console
$ git clone https://github.com/gabime/spdlog.git
$ cd spdlog && mkdir build && cd build
$ cmake .. && cmake --build .
```
see example [CMakeLists.txt](example/CMakeLists.txt) on how to use.
## Platforms
* Linux, FreeBSD, Solaris
* Windows (vc 2013+, cygwin/mingw)
* Mac OSX (clang 3.5+)
* Linux, FreeBSD, OpenBSD, Solaris, AIX
* Windows (msvc 2013+, cygwin)
* macOS (clang 3.5+)
* Android
## Package managers:
* Debian: `sudo apt install libspdlog-dev`
* Homebrew: `brew install spdlog`
* MacPorts: `sudo port install spdlog`
* FreeBSD: `pkg install spdlog`
* Fedora: `dnf install spdlog`
* Gentoo: `emerge dev-libs/spdlog`
* Arch Linux: `pacman -S spdlog`
* openSUSE: `sudo zypper in spdlog-devel`
* ALT Linux: `apt-get install libspdlog-devel`
* vcpkg: `vcpkg install spdlog`
* conan: `conan install --requires=spdlog/[*]`
* conda: `conda install -c conda-forge spdlog`
* build2: ```depends: spdlog ^1.8.2```
## Features
* Very fast - performance is the primary goal (see [benchmarks](#benchmarks) below).
* Headers only, just copy and use.
* Feature rich [call style](#usage-example) using the excellent [fmt](https://github.com/fmtlib/fmt) library.
* Optional printf syntax support.
* Extremely fast asynchronous mode (optional) - using lockfree queues and other tricks to reach millions of calls/sec.
* [Custom](https://github.com/gabime/spdlog/wiki/3.-Custom-formatting) formatting.
* Conditional Logging
* Very fast (see [benchmarks](#benchmarks) below).
* Headers only or compiled
* Feature-rich formatting, using the excellent [fmt](https://github.com/fmtlib/fmt) library.
* Asynchronous mode (optional)
* [Custom](https://github.com/gabime/spdlog/wiki/Custom-formatting) 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](include/spdlog/sinks/sink.h) interface).
* Severity based filtering - threshold levels can be modified in runtime as well as in compile time.
* Windows event log.
* Windows debugger (```OutputDebugString(..)```).
* Log to Qt widgets ([example](#log-to-qt-with-nice-colors)).
* Easily [extendable](https://github.com/gabime/spdlog/wiki/Sinks#implementing-your-own-sink) with custom log targets.
* Log filtering - log levels can be modified at runtime as well as compile time.
* Support for loading log levels from argv or environment var.
* [Backtrace](#backtrace-support) support - store debug messages in a ring buffer and display them later on demand.
## Usage samples
## Benchmarks
Below are some [benchmarks](bench) comparing popular log libraries under Ubuntu 64 bit, Intel i7-4770 CPU @ 3.40GHz
#### Synchronous mode
Time needed to log 1,000,000 lines in synchronous mode (in seconds, the best of 3 runs):
|threads|boost log 1.54|glog |easylogging |spdlog|
|-------|:-------:|:-----:|----------:|------:|
|1| 4.169s |1.066s |0.975s |0.302s|
|10| 6.180s |3.032s |2.857s |0.968s|
|100| 5.981s |1.139s |4.512s |0.497s|
#### Asynchronous mode
Time needed to log 1,000,000 lines in asynchronous mode, i.e. the time it takes to put them in the async queue (in seconds, the best of 3 runs):
|threads|g2log <sup>async logger</sup> |spdlog <sup>async mode</sup>|
|:-------|:-----:|-------------------------:|
|1| 1.850s |0.216s |
|10| 0.943s |0.173s|
|100| 0.959s |0.202s|
## Usage Example
#### Basic usage
```c++
#include "spdlog/spdlog.h"
#include <iostream>
#include <memory>
int main()
{
spdlog::info("Welcome to spdlog!");
spdlog::error("Some error message with arg: {}", 1);
void async_example();
void syslog_example();
void user_defined_example();
void err_handler_example();
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");
namespace spd = spdlog;
int main(int, char*[])
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
// Note that this does not change the current log level, it will only
// remove (depending on SPDLOG_ACTIVE_LEVEL) the call on the release code.
SPDLOG_TRACE("Some trace message with param {}", 42);
SPDLOG_DEBUG("Some debug message");
}
```
---
#### Create stdout/stderr logger object
```c++
#include "spdlog/spdlog.h"
#include "spdlog/sinks/stdout_color_sinks.h"
void stdout_example()
{
// create a 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
```c++
#include "spdlog/sinks/basic_file_sink.h"
void basic_logfile_example()
{
try
{
// Console logger with color
auto console = spd::stdout_color_mt("console");
console->info("Welcome to spdlog!");
console->error("Some error message with arg{}..", 1);
// Formatting examples
console->warn("Easy padding in numbers like {:08d}", 12);
console->critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
console->info("Support for floats {:03.2f}", 1.23456);
console->info("Positional args are {1} {0}..", "too", "supported");
console->info("{:<30}", "left aligned");
// Use global registry to retrieve loggers
spd::get("console")->info("loggers can be retrieved from a global registry using the spdlog::get(logger_name) function");
// Create basic file logger (not rotated)
auto my_logger = spd::basic_logger_mt("basic_logger", "logs/basic.txt");
my_logger->info("Some log message");
// Create a file rotating logger with 5mb size max and 3 rotated files
auto rotating_logger = spd::rotating_logger_mt("some_logger_name", "logs/mylogfile.txt", 1048576 * 5, 3);
for (int i = 0; i < 10; ++i)
rotating_logger->info("{} * {} equals {:>10}", i, i, i*i);
// Create a daily logger - a new file is created every day on 2:30am
auto daily_logger = spd::daily_logger_mt("daily_logger", "logs/daily.txt", 2, 30);
// trigger flush if the log severity is error or higher
daily_logger->flush_on(spd::level::err);
daily_logger->info(123.44);
// Customize msg format for all messages
spd::set_pattern("*** [%H:%M:%S %z] [thread %t] %v ***");
rotating_logger->info("This is another message with custom format");
// Runtime log levels
spd::set_level(spd::level::info); //Set global log level to info
console->debug("This message should not be displayed!");
console->set_level(spd::level::debug); // Set specific logger's log level
console->debug("This message should be displayed..");
// Compile time log levels
// define SPDLOG_DEBUG_ON or SPDLOG_TRACE_ON
SPDLOG_TRACE(console, "Enabled only #ifdef SPDLOG_TRACE_ON..{} ,{}", 1, 3.23);
SPDLOG_DEBUG(console, "Enabled only #ifdef SPDLOG_DEBUG_ON.. {} ,{}", 1, 3.23);
// Asynchronous logging is very fast..
// Just call spdlog::set_async_mode(q_size) and all created loggers from now on will be asynchronous..
async_example();
// syslog example. linux/osx only
syslog_example();
// android example. compile with NDK
android_example();
// Log user-defined types example
user_defined_example();
// Change default log error handler
err_handler_example();
// Apply a function on all registered loggers
spd::apply_all([&](std::shared_ptr<spd::logger> l)
{
l->info("End of example.");
});
// Release and close all loggers
spd::drop_all();
auto logger = spdlog::basic_logger_mt("basic_logger", "logs/basic-log.txt");
}
// Exceptions will only be thrown upon failed logger or sink construction (not during logging)
catch (const spd::spdlog_ex& ex)
catch (const spdlog::spdlog_ex &ex)
{
std::cout << "Log init failed: " << ex.what() << std::endl;
return 1;
}
}
```
---
#### Rotating files
```c++
#include "spdlog/sinks/rotating_file_sink.h"
void rotating_example()
{
// Create a file rotating logger with 5 MB 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);
}
```
void async_example()
{
size_t q_size = 4096; //queue size must be power of 2
spd::set_async_mode(q_size);
auto async_file = spd::daily_logger_st("async_file_logger", "logs/async_log.txt");
for (int i = 0; i < 100; ++i)
async_file->info("Async message #{}", i);
}
---
#### Daily files
```c++
//syslog example
void syslog_example()
#include "spdlog/sinks/daily_file_sink.h"
void daily_example()
{
#ifdef SPDLOG_ENABLE_SYSLOG
std::string ident = "spdlog-example";
auto syslog_logger = spd::syslog_logger("syslog", ident, LOG_PID);
syslog_logger->warn("This is warning that will end up in syslog..");
#endif
}
// user defined types logging by implementing operator<<
struct my_type
{
int i;
template<typename OStream>
friend OStream& operator<<(OStream& os, const my_type &c)
{
return os << "[my_type i="<<c.i << "]";
}
};
#include <spdlog/fmt/ostr.h> // must be included
void user_defined_example()
{
spd::get("console")->info("user defined type: {}", my_type { 14 });
}
//
//custom error handler
//
void err_handler_example()
{
spd::set_error_handler([](const std::string& msg) {
std::cerr << "my err handler: " << msg << std::endl;
});
// (or logger->set_error_handler(..) to set for specific logger)
// Create a daily logger - a new file is created every day at 2:30 am
auto logger = spdlog::daily_logger_mt("daily_logger", "logs/daily.txt", 2, 30);
}
```
---
#### Backtrace support
```c++
// Debug messages can be stored in a ring buffer instead of being logged immediately.
// This is useful to display debug logs only when needed (e.g. when an error happens).
// When needed, call dump_backtrace() to dump them to your log.
spdlog::enable_backtrace(32); // Store the latest 32 messages in a buffer.
// 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
```c++
// 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
```c++
// 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
```c++
// 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 into 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 a different format and log level
```c++
// create a 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");
}
```
---
#### User-defined callbacks about log events
```c++
// create a logger with a lambda function callback, the callback will be called
// each time something is logged to the logger
void callback_example()
{
auto callback_sink = std::make_shared<spdlog::sinks::callback_sink_mt>([](const spdlog::details::log_msg &msg) {
// for example you can be notified by sending an email to yourself
});
callback_sink->set_level(spdlog::level::err);
auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
spdlog::logger logger("custom_callback_logger", {console_sink, callback_sink});
logger.info("some info log");
logger.error("critical issue"); // will notify you
}
```
---
#### Asynchronous logging
```c++
#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
```c++
#include "spdlog/async.h"
#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
```c++
template<>
struct fmt::formatter<my_type> : fmt::formatter<std::string>
{
auto format(my_type my, format_context &ctx) const -> decltype(ctx.out())
{
return fmt::format_to(ctx.out(), "[my_type i={}]", my.i);
}
};
void user_defined_example()
{
spdlog::info("user defined type: {}", my_type(14));
}
```
---
#### User-defined flags in the log pattern
```c++
// 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
```c++
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
```c++
#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
```c++
#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 the env variable or argv
```c++
#include "spdlog/cfg/env.h"
int main (int argc, char *argv[])
{
spdlog::cfg::load_env_levels();
// or specify the env variable name:
// MYAPP_LEVEL=info,mylogger=trace && ./example
// spdlog::cfg::load_env_levels("MYAPP_LEVEL");
// or from the 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:
```console
$ export SPDLOG_LEVEL=info,mylogger=trace
$ ./example
```
---
#### Log file open/close event handlers
```c++
// You can get callbacks from spdlog before/after a log file has been opened or closed.
// This is useful for cleanup procedures or for adding something to the start/end of the log file.
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);
}
```
---
#### Replace the Default Logger
```c++
void replace_default_logger_example()
{
auto new_logger = spdlog::basic_logger_mt("new_default_logger", "logs/new-default-log.txt", true);
spdlog::set_default_logger(new_logger);
spdlog::info("new logger log message");
}
```
---
#### Log to Qt with nice colors
```c++
#include "spdlog/spdlog.h"
#include "spdlog/sinks/qt_sinks.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
setMinimumSize(640, 480);
auto log_widget = new QTextEdit(this);
setCentralWidget(log_widget);
int max_lines = 500; // keep the text widget to max 500 lines. remove old lines if needed.
auto logger = spdlog::qt_color_logger_mt("qt_logger", log_widget, max_lines);
logger->info("Some info message");
}
```
---
#### Mapped Diagnostic Context
```c++
// Mapped Diagnostic Context (MDC) is a map that stores key-value pairs (string values) in thread local storage.
// Each thread maintains its own MDC, which loggers use to append diagnostic information to log outputs.
// Note: it is not supported in asynchronous mode due to its reliance on thread-local storage.
#include "spdlog/mdc.h"
void mdc_example()
{
spdlog::mdc::put("key1", "value1");
spdlog::mdc::put("key2", "value2");
// if not using the default format, use the %& formatter to print mdc data
// spdlog::set_pattern("[%H:%M:%S %z] [%^%L%$] [%&] %v");
}
```
---
## Benchmarks
Below are some [benchmarks](bench/bench.cpp) 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](https://github.com/gabime/spdlog/wiki/1.-QuickStart) pages.
Documentation can be found in the [wiki](https://github.com/gabime/spdlog/wiki) pages.
---
Thanks to [JetBrains](https://www.jetbrains.com/?from=spdlog) for donating product licenses to help develop **spdlog** <a href="https://www.jetbrains.com/?from=spdlog"><img src="logos/jetbrains-variant-4.svg" width="94" align="center" /></a>

View File

@ -1,19 +1,73 @@
version: 1.0.{build}
image: Visual Studio 2015
image: Visual Studio 2017
environment:
matrix:
- GENERATOR: '"MinGW Makefiles"'
- GENERATOR: '"Visual Studio 15 2017 Win64"'
BUILD_TYPE: Debug
- GENERATOR: '"MinGW Makefiles"'
BUILD_SHARED: 'OFF'
FATAL_ERRORS: 'OFF'
WCHAR: 'ON'
WCHAR_FILES: 'OFF'
BUILD_EXAMPLE: 'ON'
USE_STD_FORMAT: 'OFF'
CXX_STANDARD: 11
- GENERATOR: '"Visual Studio 15 2017 Win64"'
BUILD_TYPE: Release
- GENERATOR: '"Visual Studio 14 2015"'
BUILD_TYPE: Debug
- GENERATOR: '"Visual Studio 14 2015"'
BUILD_SHARED: 'OFF'
FATAL_ERRORS: 'OFF'
WCHAR: 'OFF'
WCHAR_FILES: 'OFF'
BUILD_EXAMPLE: 'ON'
USE_STD_FORMAT: 'OFF'
CXX_STANDARD: 11
- GENERATOR: '"Visual Studio 15 2017 Win64"'
BUILD_TYPE: Release
- GENERATOR: '"Visual Studio 14 2015 Win64"'
BUILD_TYPE: Debug
- GENERATOR: '"Visual Studio 14 2015 Win64"'
BUILD_SHARED: 'ON'
FATAL_ERRORS: 'OFF'
WCHAR: 'OFF'
WCHAR_FILES: 'OFF'
BUILD_EXAMPLE: 'ON'
USE_STD_FORMAT: 'OFF'
CXX_STANDARD: 11
- GENERATOR: '"Visual Studio 15 2017 Win64"'
BUILD_TYPE: Release
BUILD_SHARED: 'ON'
FATAL_ERRORS: 'OFF'
WCHAR: 'ON'
WCHAR_FILES: 'ON'
BUILD_EXAMPLE: 'OFF'
USE_STD_FORMAT: 'OFF'
CXX_STANDARD: 11
- GENERATOR: '"Visual Studio 16 2019" -A x64'
BUILD_TYPE: Release
BUILD_SHARED: 'ON'
FATAL_ERRORS: 'ON'
WCHAR: 'OFF'
WCHAR_FILES: 'OFF'
BUILD_EXAMPLE: 'OFF'
USE_STD_FORMAT: 'OFF'
CXX_STANDARD: 17
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- GENERATOR: '"Visual Studio 17 2022" -A x64'
BUILD_TYPE: Release
BUILD_SHARED: 'ON'
FATAL_ERRORS: 'ON'
WCHAR: 'OFF'
WCHAR_FILES: 'OFF'
BUILD_EXAMPLE: 'OFF'
USE_STD_FORMAT: 'ON'
CXX_STANDARD: 20
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
- GENERATOR: '"Visual Studio 17 2022" -A x64'
BUILD_TYPE: Release
BUILD_SHARED: 'ON'
FATAL_ERRORS: 'ON'
WCHAR: 'ON'
WCHAR_FILES: 'ON'
BUILD_EXAMPLE: 'OFF'
USE_STD_FORMAT: 'ON'
CXX_STANDARD: 20
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
build_script:
- cmd: >-
set
@ -22,11 +76,14 @@ build_script:
cd build
set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
set PATH=%PATH%;C:\Program Files\Git\usr\bin
set PATH=C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin;%PATH%
cmake .. -G %GENERATOR% -DCMAKE_BUILD_TYPE=%BUILD_TYPE%
cmake -G %GENERATOR% -D CMAKE_BUILD_TYPE=%BUILD_TYPE% -D BUILD_SHARED_LIBS=%BUILD_SHARED% -D SPDLOG_WCHAR_SUPPORT=%WCHAR% -D SPDLOG_WCHAR_FILENAMES=%WCHAR_FILES% -D SPDLOG_BUILD_EXAMPLE=%BUILD_EXAMPLE% -D SPDLOG_BUILD_EXAMPLE_HO=%BUILD_EXAMPLE% -D SPDLOG_BUILD_TESTS=ON -D SPDLOG_BUILD_TESTS_HO=OFF -D SPDLOG_BUILD_WARNINGS=%FATAL_ERRORS% -D SPDLOG_USE_STD_FORMAT=%USE_STD_FORMAT% -D CMAKE_CXX_STANDARD=%CXX_STANDARD% ..
cmake --build . --config %BUILD_TYPE%
test: off
before_test:
- set PATH=%PATH%;C:\projects\spdlog\build\_deps\catch2-build\src\%BUILD_TYPE%;C:\projects\spdlog\build\%BUILD_TYPE%
test_script:
- C:\projects\spdlog\build\tests\%BUILD_TYPE%\spdlog-utests.exe

View File

@ -1,5 +0,0 @@
#!/bin/bash
find . -name "*\.h" -o -name "*\.cpp"|xargs dos2unix
find . -name "*\.h" -o -name "*\.cpp"|xargs astyle -n -c -A1

37
bench/CMakeLists.txt Normal file
View File

@ -0,0 +1,37 @@
# Copyright(c) 2019 spdlog authors Distributed under the MIT License (http://opensource.org/licenses/MIT)
cmake_minimum_required(VERSION 3.11)
project(spdlog_bench CXX)
if(NOT TARGET spdlog)
# Stand-alone build
find_package(spdlog CONFIG REQUIRED)
endif()
find_package(Threads REQUIRED)
find_package(benchmark CONFIG)
if(NOT benchmark_FOUND)
message(STATUS "Using CMake Version ${CMAKE_VERSION}")
# User can fetch googlebenchmark
message(STATUS "Downloading GoogleBenchmark")
include(FetchContent)
# disable tests
set(BENCHMARK_ENABLE_TESTING OFF CACHE INTERNAL "")
# Do not build and run googlebenchmark tests
FetchContent_Declare(googlebenchmark GIT_REPOSITORY https://github.com/google/benchmark.git GIT_TAG v1.6.0)
FetchContent_MakeAvailable(googlebenchmark)
endif()
add_executable(bench bench.cpp)
spdlog_enable_warnings(bench)
target_link_libraries(bench PRIVATE spdlog::spdlog)
add_executable(async_bench async_bench.cpp)
target_link_libraries(async_bench PRIVATE spdlog::spdlog)
add_executable(latency latency.cpp)
target_link_libraries(latency PRIVATE benchmark::benchmark spdlog::spdlog)
add_executable(formatter-bench formatter-bench.cpp)
target_link_libraries(formatter-bench PRIVATE benchmark::benchmark spdlog::spdlog)

View File

@ -1,62 +0,0 @@
CXX ?= g++
CXXFLAGS = -march=native -Wall -Wextra -pedantic -std=c++11 -pthread -I../include
CXX_RELEASE_FLAGS = -O3 -flto -DNDEBUG
binaries=spdlog-bench spdlog-bench-mt spdlog-async spdlog-null-async boost-bench boost-bench-mt glog-bench glog-bench-mt g2log-async easylogging-bench easylogging-bench-mt
all: $(binaries)
spdlog-bench: spdlog-bench.cpp
$(CXX) spdlog-bench.cpp -o spdlog-bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
spdlog-bench-mt: spdlog-bench-mt.cpp
$(CXX) spdlog-bench-mt.cpp -o spdlog-bench-mt $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
spdlog-async: spdlog-async.cpp
$(CXX) spdlog-async.cpp -o spdlog-async $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
spdlog-null-async: spdlog-null-async.cpp
$(CXX) spdlog-null-async.cpp -o spdlog-null-async $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
BOOST_FLAGS = -DBOOST_LOG_DYN_LINK -I/usr/include -lboost_log -lboost_log_setup -lboost_filesystem -lboost_system -lboost_thread -lboost_regex -lboost_date_time -lboost_chrono
boost-bench: boost-bench.cpp
$(CXX) boost-bench.cpp -o boost-bench $(CXXFLAGS) $(BOOST_FLAGS) $(CXX_RELEASE_FLAGS)
boost-bench-mt: boost-bench-mt.cpp
$(CXX) boost-bench-mt.cpp -o boost-bench-mt $(CXXFLAGS) $(BOOST_FLAGS) $(CXX_RELEASE_FLAGS)
GLOG_FLAGS = -lglog
glog-bench: glog-bench.cpp
$(CXX) glog-bench.cpp -o glog-bench $(CXXFLAGS) $(GLOG_FLAGS) $(CXX_RELEASE_FLAGS)
glog-bench-mt: glog-bench-mt.cpp
$(CXX) glog-bench-mt.cpp -o glog-bench-mt $(CXXFLAGS) $(GLOG_FLAGS) $(CXX_RELEASE_FLAGS)
G2LOG_FLAGS = -I/home/gabi/devel/g2log/g2log/src -L/home/gabi/devel/g2log/g2log -llib_g2logger
g2log-async: g2log-async.cpp
$(CXX) g2log-async.cpp -o g2log-async $(CXXFLAGS) $(G2LOG_FLAGS) $(CXX_RELEASE_FLAGS)
EASYL_FLAGS = -I../../easylogging/src/
easylogging-bench: easylogging-bench.cpp
$(CXX) easylogging-bench.cpp -o easylogging-bench $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS)
easylogging-bench-mt: easylogging-bench-mt.cpp
$(CXX) easylogging-bench-mt.cpp -o easylogging-bench-mt $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS)
.PHONY: clean
clean:
rm -f *.o logs/* $(binaries)
rebuild: clean all

View File

@ -1,57 +0,0 @@
CXX ?= g++
CXXFLAGS = -D_WIN32_WINNT=0x600 -march=native -Wall -Wextra -pedantic -std=c++11 -pthread -Wl,--no-as-needed -I../include
CXX_RELEASE_FLAGS = -O3 -flto
binaries=spdlog-bench spdlog-bench-mt spdlog-async boost-bench boost-bench-mt glog-bench glog-bench-mt g2log-async easylogging-bench easylogging-bench-mt
all: $(binaries)
spdlog-bench: spdlog-bench.cpp
$(CXX) spdlog-bench.cpp -o spdlog-bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
spdlog-bench-mt: spdlog-bench-mt.cpp
$(CXX) spdlog-bench-mt.cpp -o spdlog-bench-mt $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
spdlog-async: spdlog-async.cpp
$(CXX) spdlog-async.cpp -o spdlog-async $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
BOOST_FLAGS = -DBOOST_LOG_DYN_LINK -I/home/gabi/devel/boost_1_56_0/ -L/home/gabi/devel/boost_1_56_0/stage/lib -lboost_log -lboost_log_setup -lboost_filesystem -lboost_system -lboost_thread -lboost_regex -lboost_date_time -lboost_chrono
boost-bench: boost-bench.cpp
$(CXX) boost-bench.cpp -o boost-bench $(CXXFLAGS) $(BOOST_FLAGS) $(CXX_RELEASE_FLAGS)
boost-bench-mt: boost-bench-mt.cpp
$(CXX) boost-bench-mt.cpp -o boost-bench-mt $(CXXFLAGS) $(BOOST_FLAGS) $(CXX_RELEASE_FLAGS)
GLOG_FLAGS = -lglog
glog-bench: glog-bench.cpp
$(CXX) glog-bench.cpp -o glog-bench $(CXXFLAGS) $(GLOG_FLAGS) $(CXX_RELEASE_FLAGS)
glog-bench-mt: glog-bench-mt.cpp
$(CXX) glog-bench-mt.cpp -o glog-bench-mt $(CXXFLAGS) $(GLOG_FLAGS) $(CXX_RELEASE_FLAGS)
G2LOG_FLAGS = -I/home/gabi/devel/g2log/g2log/src -L/home/gabi/devel/g2log/g2log -llib_g2logger
g2log-async: g2log-async.cpp
$(CXX) g2log-async.cpp -o g2log-async $(CXXFLAGS) $(G2LOG_FLAGS) $(CXX_RELEASE_FLAGS)
EASYL_FLAGS = -I../../easylogging/src/
easylogging-bench: easylogging-bench.cpp
$(CXX) easylogging-bench.cpp -o easylogging-bench $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS)
easylogging-bench-mt: easylogging-bench-mt.cpp
$(CXX) easylogging-bench-mt.cpp -o easylogging-bench-mt $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS)
.PHONY: clean
clean:
rm -f *.o logs/* $(binaries)
rebuild: clean all

168
bench/async_bench.cpp Normal file
View File

@ -0,0 +1,168 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
//
// bench.cpp : spdlog benchmarks
//
#include "spdlog/spdlog.h"
#include "spdlog/async.h"
#include "spdlog/sinks/basic_file_sink.h"
#if defined(SPDLOG_USE_STD_FORMAT)
#include <format>
#elif defined(SPDLOG_FMT_EXTERNAL)
#include <fmt/format.h>
#else
#include "spdlog/fmt/bundled/format.h"
#endif
#include "utils.h"
#include <atomic>
#include <iostream>
#include <memory>
#include <string>
#include <thread>
using namespace std;
using namespace std::chrono;
using namespace spdlog;
using namespace spdlog::sinks;
using namespace utils;
void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count);
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4996) // disable fopen warning under msvc
#endif // _MSC_VER
int count_lines(const char *filename) {
int counter = 0;
auto *infile = fopen(filename, "r");
int ch;
while (EOF != (ch = getc(infile))) {
if ('\n' == ch) counter++;
}
fclose(infile);
return counter;
}
void verify_file(const char *filename, int expected_count) {
spdlog::info("Verifying {} to contain {} line..", filename, expected_count);
auto count = count_lines(filename);
if (count != expected_count) {
spdlog::error("Test failed. {} has {} lines instead of {}", filename, count,
expected_count);
exit(1);
}
spdlog::info("Line count OK ({})\n", count);
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif
int main(int argc, char *argv[]) {
int howmany = 1000000;
int queue_size = std::min(howmany + 2, 8192);
int threads = 10;
int iters = 3;
try {
spdlog::set_pattern("[%^%l%$] %v");
if (argc == 1) {
spdlog::info("Usage: {} <message_count> <threads> <q_size> <iterations>", argv[0]);
return 0;
}
if (argc > 1) howmany = atoi(argv[1]);
if (argc > 2) threads = atoi(argv[2]);
if (argc > 3) {
queue_size = atoi(argv[3]);
if (queue_size > 500000) {
spdlog::error("Max queue size allowed: 500,000");
exit(1);
}
}
if (argc > 4) iters = atoi(argv[4]);
auto slot_size = sizeof(spdlog::details::async_msg);
spdlog::info("-------------------------------------------------");
spdlog::info("Messages : {:L}", howmany);
spdlog::info("Threads : {:L}", threads);
spdlog::info("Queue : {:L} slots", queue_size);
spdlog::info("Queue memory : {:L} x {:L} = {:L} KB ", queue_size, slot_size,
(queue_size * slot_size) / 1024);
spdlog::info("Total iters : {:L}", iters);
spdlog::info("-------------------------------------------------");
const char *filename = "logs/basic_async.log";
spdlog::info("");
spdlog::info("*********************************");
spdlog::info("Queue Overflow Policy: block");
spdlog::info("*********************************");
for (int i = 0; i < iters; i++) {
auto tp = std::make_shared<details::thread_pool>(queue_size, 1);
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(filename, true);
auto logger = std::make_shared<async_logger>(
"async_logger", std::move(file_sink), std::move(tp), async_overflow_policy::block);
bench_mt(howmany, std::move(logger), threads);
// verify_file(filename, howmany);
}
spdlog::info("");
spdlog::info("*********************************");
spdlog::info("Queue Overflow Policy: overrun");
spdlog::info("*********************************");
// do same test but discard oldest if queue is full instead of blocking
filename = "logs/basic_async-overrun.log";
for (int i = 0; i < iters; i++) {
auto tp = std::make_shared<details::thread_pool>(queue_size, 1);
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(filename, true);
auto logger =
std::make_shared<async_logger>("async_logger", std::move(file_sink), std::move(tp),
async_overflow_policy::overrun_oldest);
bench_mt(howmany, std::move(logger), threads);
}
spdlog::shutdown();
} catch (std::exception &ex) {
std::cerr << "Error: " << ex.what() << std::endl;
perror("Last error");
return 1;
}
return 0;
}
void thread_fun(std::shared_ptr<spdlog::logger> logger, int howmany) {
for (int i = 0; i < howmany; i++) {
logger->info("Hello logger: msg number {}", i);
}
}
void bench_mt(int howmany, std::shared_ptr<spdlog::logger> logger, int thread_count) {
using std::chrono::high_resolution_clock;
vector<std::thread> threads;
auto start = high_resolution_clock::now();
int msgs_per_thread = howmany / thread_count;
int msgs_per_thread_mod = howmany % thread_count;
for (int t = 0; t < thread_count; ++t) {
if (t == 0 && msgs_per_thread_mod)
threads.push_back(
std::thread(thread_fun, logger, msgs_per_thread + msgs_per_thread_mod));
else
threads.push_back(std::thread(thread_fun, logger, msgs_per_thread));
}
for (auto &t : threads) {
t.join();
}
auto delta = high_resolution_clock::now() - start;
auto delta_d = duration_cast<duration<double>>(delta).count();
spdlog::info("Elapsed: {} secs\t {:L}/sec", delta_d, int(howmany / delta_d));
}

246
bench/bench.cpp Normal file
View File

@ -0,0 +1,246 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
//
// bench.cpp : spdlog benchmarks
//
#include "spdlog/spdlog.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/daily_file_sink.h"
#include "spdlog/sinks/null_sink.h"
#include "spdlog/sinks/rotating_file_sink.h"
#if defined(SPDLOG_USE_STD_FORMAT)
#include <format>
#elif defined(SPDLOG_FMT_EXTERNAL)
#include <fmt/format.h>
#else
#include "spdlog/fmt/bundled/format.h"
#endif
#include "utils.h"
#include <atomic>
#include <cstdlib> // EXIT_FAILURE
#include <memory>
#include <string>
#include <thread>
void bench(int howmany, std::shared_ptr<spdlog::logger> log);
void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, size_t thread_count);
// void bench_default_api(int howmany, std::shared_ptr<spdlog::logger> log);
// void bench_c_string(int howmany, std::shared_ptr<spdlog::logger> log);
static const size_t file_size = 30 * 1024 * 1024;
static const size_t rotating_files = 5;
static const int max_threads = 1000;
void bench_threaded_logging(size_t threads, int iters) {
spdlog::info("**************************************************************");
spdlog::info(spdlog::fmt_lib::format(
std::locale("en_US.UTF-8"), "Multi threaded: {:L} threads, {:L} messages", threads, iters));
spdlog::info("**************************************************************");
auto basic_mt = spdlog::basic_logger_mt("basic_mt", "logs/basic_mt.log", true);
bench_mt(iters, std::move(basic_mt), threads);
auto basic_mt_tracing =
spdlog::basic_logger_mt("basic_mt/backtrace-on", "logs/basic_mt.log", true);
basic_mt_tracing->enable_backtrace(32);
bench_mt(iters, std::move(basic_mt_tracing), threads);
spdlog::info("");
auto rotating_mt = spdlog::rotating_logger_mt("rotating_mt", "logs/rotating_mt.log", file_size,
rotating_files);
bench_mt(iters, std::move(rotating_mt), threads);
auto rotating_mt_tracing = spdlog::rotating_logger_mt(
"rotating_mt/backtrace-on", "logs/rotating_mt.log", file_size, rotating_files);
rotating_mt_tracing->enable_backtrace(32);
bench_mt(iters, std::move(rotating_mt_tracing), threads);
spdlog::info("");
auto daily_mt = spdlog::daily_logger_mt("daily_mt", "logs/daily_mt.log");
bench_mt(iters, std::move(daily_mt), threads);
auto daily_mt_tracing = spdlog::daily_logger_mt("daily_mt/backtrace-on", "logs/daily_mt.log");
daily_mt_tracing->enable_backtrace(32);
bench_mt(iters, std::move(daily_mt_tracing), threads);
spdlog::info("");
auto empty_logger = std::make_shared<spdlog::logger>("level-off");
empty_logger->set_level(spdlog::level::off);
bench(iters, empty_logger);
auto empty_logger_tracing = std::make_shared<spdlog::logger>("level-off/backtrace-on");
empty_logger_tracing->set_level(spdlog::level::off);
empty_logger_tracing->enable_backtrace(32);
bench(iters, empty_logger_tracing);
}
void bench_single_threaded(int iters) {
spdlog::info("**************************************************************");
spdlog::info(
spdlog::fmt_lib::format(std::locale("en_US.UTF-8"), "Single threaded: {} messages", iters));
spdlog::info("**************************************************************");
auto basic_st = spdlog::basic_logger_st("basic_st", "logs/basic_st.log", true);
bench(iters, std::move(basic_st));
auto basic_st_tracing =
spdlog::basic_logger_st("basic_st/backtrace-on", "logs/basic_st.log", true);
bench(iters, std::move(basic_st_tracing));
spdlog::info("");
auto rotating_st = spdlog::rotating_logger_st("rotating_st", "logs/rotating_st.log", file_size,
rotating_files);
bench(iters, std::move(rotating_st));
auto rotating_st_tracing = spdlog::rotating_logger_st(
"rotating_st/backtrace-on", "logs/rotating_st.log", file_size, rotating_files);
rotating_st_tracing->enable_backtrace(32);
bench(iters, std::move(rotating_st_tracing));
spdlog::info("");
auto daily_st = spdlog::daily_logger_st("daily_st", "logs/daily_st.log");
bench(iters, std::move(daily_st));
auto daily_st_tracing = spdlog::daily_logger_st("daily_st/backtrace-on", "logs/daily_st.log");
daily_st_tracing->enable_backtrace(32);
bench(iters, std::move(daily_st_tracing));
spdlog::info("");
auto empty_logger = std::make_shared<spdlog::logger>("level-off");
empty_logger->set_level(spdlog::level::off);
bench(iters, empty_logger);
auto empty_logger_tracing = std::make_shared<spdlog::logger>("level-off/backtrace-on");
empty_logger_tracing->set_level(spdlog::level::off);
empty_logger_tracing->enable_backtrace(32);
bench(iters, empty_logger_tracing);
}
int main(int argc, char *argv[]) {
spdlog::set_automatic_registration(false);
spdlog::default_logger()->set_pattern("[%^%l%$] %v");
int iters = 250000;
size_t threads = 4;
try {
if (argc > 1) {
iters = std::stoi(argv[1]);
}
if (argc > 2) {
threads = std::stoul(argv[2]);
}
if (threads > max_threads) {
throw std::runtime_error(
spdlog::fmt_lib::format("Number of threads exceeds maximum({})", max_threads));
}
bench_single_threaded(iters);
bench_threaded_logging(1, iters);
bench_threaded_logging(threads, iters);
} catch (std::exception &ex) {
spdlog::error(ex.what());
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
void bench(int howmany, std::shared_ptr<spdlog::logger> log) {
using std::chrono::duration;
using std::chrono::duration_cast;
using std::chrono::high_resolution_clock;
auto start = high_resolution_clock::now();
for (auto i = 0; i < howmany; ++i) {
log->info("Hello logger: msg number {}", i);
}
auto delta = high_resolution_clock::now() - start;
auto delta_d = duration_cast<duration<double>>(delta).count();
spdlog::info(spdlog::fmt_lib::format(std::locale("en_US.UTF-8"),
"{:<30} Elapsed: {:0.2f} secs {:>16L}/sec", log->name(),
delta_d, size_t(howmany / delta_d)));
spdlog::drop(log->name());
}
void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, size_t thread_count) {
using std::chrono::duration;
using std::chrono::duration_cast;
using std::chrono::high_resolution_clock;
std::vector<std::thread> threads;
threads.reserve(thread_count);
auto start = high_resolution_clock::now();
for (size_t t = 0; t < thread_count; ++t) {
threads.emplace_back([&]() {
for (int j = 0; j < howmany / static_cast<int>(thread_count); j++) {
log->info("Hello logger: msg number {}", j);
}
});
}
for (auto &t : threads) {
t.join();
}
auto delta = high_resolution_clock::now() - start;
auto delta_d = duration_cast<duration<double>>(delta).count();
spdlog::info(spdlog::fmt_lib::format(std::locale("en_US.UTF-8"),
"{:<30} Elapsed: {:0.2f} secs {:>16L}/sec", log->name(),
delta_d, size_t(howmany / delta_d)));
spdlog::drop(log->name());
}
/*
void bench_default_api(int howmany, std::shared_ptr<spdlog::logger> log)
{
using std::chrono::high_resolution_clock;
using std::chrono::duration;
using std::chrono::duration_cast;
auto orig_default = spdlog::default_logger();
spdlog::set_default_logger(log);
auto start = high_resolution_clock::now();
for (auto i = 0; i < howmany; ++i)
{
spdlog::info("Hello logger: msg number {}", i);
}
auto delta = high_resolution_clock::now() - start;
auto delta_d = duration_cast<duration<double>>(delta).count();
spdlog::drop(log->name());
spdlog::set_default_logger(std::move(orig_default));
spdlog::info("{:<30} Elapsed: {:0.2f} secs {:>16}/sec", log->name(), delta_d, int(howmany /
delta_d));
}
void bench_c_string(int howmany, std::shared_ptr<spdlog::logger> log)
{
using std::chrono::high_resolution_clock;
using std::chrono::duration;
using std::chrono::duration_cast;
const char *msg = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pharetra
metus cursus " "lacus placerat congue. Nulla egestas, mauris a tincidunt tempus, enim lectus
volutpat mi, eu consequat sem " "libero nec massa. In dapibus ipsum a diam rhoncus gravida. Etiam
non dapibus eros. Donec fringilla dui sed " "augue pretium, nec scelerisque est maximus. Nullam
convallis, sem nec blandit maximus, nisi turpis ornare " "nisl, sit amet volutpat neque massa eu
odio. Maecenas malesuada quam ex, posuere congue nibh turpis duis.";
auto orig_default = spdlog::default_logger();
spdlog::set_default_logger(log);
auto start = high_resolution_clock::now();
for (auto i = 0; i < howmany; ++i)
{
spdlog::log(spdlog::level::info, msg);
}
auto delta = high_resolution_clock::now() - start;
auto delta_d = duration_cast<duration<double>>(delta).count();
spdlog::drop(log->name());
spdlog::set_default_logger(std::move(orig_default));
spdlog::info("{:<30} Elapsed: {:0.2f} secs {:>16}/sec", log->name(), delta_d, int(howmany /
delta_d));
}
*/

View File

@ -1,84 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include <thread>
#include <vector>
#include <atomic>
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sinks/text_file_backend.hpp>
#include <boost/log/utility/setup/file.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/sources/record_ostream.hpp>
namespace logging = boost::log;
namespace src = boost::log::sources;
namespace sinks = boost::log::sinks;
namespace keywords = boost::log::keywords;
void init()
{
logging::add_file_log
(
keywords::file_name = "logs/boost-sample_%N.log", /*< file name pattern >*/
keywords::auto_flush = false,
keywords::format = "[%TimeStamp%]: %Message%"
);
logging::core::get()->set_filter
(
logging::trivial::severity >= logging::trivial::info
);
}
using namespace std;
int main(int argc, char* argv[])
{
int thread_count = 10;
if(argc > 1)
thread_count = atoi(argv[1]);
int howmany = 1000000;
init();
logging::add_common_attributes();
using namespace logging::trivial;
src::severity_logger_mt< severity_level > lg;
std::atomic<int > msg_counter {0};
vector<thread> threads;
for (int t = 0; t < thread_count; ++t)
{
threads.push_back(std::thread([&]()
{
while (true)
{
int counter = ++msg_counter;
if (counter > howmany) break;
BOOST_LOG_SEV(lg, info) << "boost message #" << counter << ": This is some text for your pleasure";
}
}));
}
for(auto &t:threads)
{
t.join();
};
return 0;
}

View File

@ -1,47 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sinks/text_file_backend.hpp>
#include <boost/log/utility/setup/file.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/sources/record_ostream.hpp>
namespace logging = boost::log;
namespace src = boost::log::sources;
namespace sinks = boost::log::sinks;
namespace keywords = boost::log::keywords;
void init()
{
logging::add_file_log
(
keywords::file_name = "logs/boost-sample_%N.log", /*< file name pattern >*/
keywords::auto_flush = false,
keywords::format = "[%TimeStamp%]: %Message%"
);
logging::core::get()->set_filter
(
logging::trivial::severity >= logging::trivial::info
);
}
int main(int argc, char* [])
{
int howmany = 1000000;
init();
logging::add_common_attributes();
using namespace logging::trivial;
src::severity_logger_mt< severity_level > lg;
for(int i = 0 ; i < howmany; ++i)
BOOST_LOG_SEV(lg, info) << "boost message #" << i << ": This is some text for your pleasure";
return 0;
}

View File

@ -1,10 +0,0 @@
* GLOBAL:
FORMAT = "[%datetime]: %msg"
FILENAME = ./logs/easylogging.log
ENABLED = true
TO_FILE = true
TO_STANDARD_OUTPUT = false
MILLISECONDS_WIDTH = 3
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 10485760
Log_Flush_Threshold = 10485760

View File

@ -1,52 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include <thread>
#include <vector>
#include <atomic>
#define _ELPP_THREAD_SAFE
#include "easylogging++.h"
_INITIALIZE_EASYLOGGINGPP
using namespace std;
int main(int argc, char* argv[])
{
int thread_count = 10;
if(argc > 1)
thread_count = atoi(argv[1]);
int howmany = 1000000;
// Load configuration from file
el::Configurations conf("easyl.conf");
el::Loggers::reconfigureLogger("default", conf);
std::atomic<int > msg_counter {0};
vector<thread> threads;
for (int t = 0; t < thread_count; ++t)
{
threads.push_back(std::thread([&]()
{
while (true)
{
int counter = ++msg_counter;
if (counter > howmany) break;
LOG(INFO) << "easylog message #" << counter << ": This is some text for your pleasure";
}
}));
}
for(auto &t:threads)
{
t.join();
};
return 0;
}

View File

@ -1,22 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include "easylogging++.h"
_INITIALIZE_EASYLOGGINGPP
int main(int, char* [])
{
int howmany = 1000000;
// Load configuration from file
el::Configurations conf("easyl.conf");
el::Loggers::reconfigureLogger("default", conf);
for(int i = 0 ; i < howmany; ++i)
LOG(INFO) << "easylog message #" << i << ": This is some text for your pleasure";
return 0;
}

71
bench/formatter-bench.cpp Normal file
View File

@ -0,0 +1,71 @@
//
// Copyright(c) 2018 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include "benchmark/benchmark.h"
#include "spdlog/spdlog.h"
#include "spdlog/pattern_formatter.h"
void bench_formatter(benchmark::State &state, std::string pattern) {
auto formatter = spdlog::details::make_unique<spdlog::pattern_formatter>(pattern);
spdlog::memory_buf_t dest;
std::string logger_name = "logger-name";
const char *text =
"Hello. This is some message with length of 80 ";
spdlog::source_loc source_loc{"a/b/c/d/myfile.cpp", 123, "some_func()"};
spdlog::details::log_msg msg(source_loc, logger_name, spdlog::level::info, text);
for (auto _ : state) {
dest.clear();
formatter->format(msg, dest);
benchmark::DoNotOptimize(dest);
}
}
void bench_formatters() {
// basic patterns(single flag)
std::string all_flags = "+vtPnlLaAbBcCYDmdHIMSefFprRTXzEisg@luioO%";
std::vector<std::string> basic_patterns;
for (auto &flag : all_flags) {
auto pattern = std::string("%") + flag;
benchmark::RegisterBenchmark(pattern.c_str(), &bench_formatter, pattern);
// pattern = std::string("%16") + flag;
// benchmark::RegisterBenchmark(pattern.c_str(), &bench_formatter, pattern);
//
// // bench center padding
// pattern = std::string("%=16") + flag;
// benchmark::RegisterBenchmark(pattern.c_str(), &bench_formatter, pattern);
}
// complex patterns
std::vector<std::string> patterns = {
"[%D %X] [%l] [%n] %v",
"[%Y-%m-%d %H:%M:%S.%e] [%l] [%n] %v",
"[%Y-%m-%d %H:%M:%S.%e] [%l] [%n] [%t] %v",
};
for (auto &pattern : patterns) {
benchmark::RegisterBenchmark(pattern.c_str(), &bench_formatter, pattern)
->Iterations(2500000);
}
}
int main(int argc, char *argv[]) {
spdlog::set_pattern("[%^%l%$] %v");
if (argc != 2) {
spdlog::error("Usage: {} <pattern> (or \"all\" to bench all)", argv[0]);
exit(1);
}
std::string pattern = argv[1];
if (pattern == "all") {
bench_formatters();
} else {
benchmark::RegisterBenchmark(pattern.c_str(), &bench_formatter, pattern);
}
benchmark::Initialize(&argc, argv);
benchmark::RunSpecifiedBenchmarks();
}

View File

@ -1,62 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include <thread>
#include <vector>
#include <atomic>
#include <iostream>
#include <chrono>
#include "g2logworker.h"
#include "g2log.h"
using namespace std;
template<typename T> std::string format(const T& value);
int main(int argc, char* argv[])
{
using namespace std::chrono;
using clock=steady_clock;
int thread_count = 10;
if(argc > 1)
thread_count = atoi(argv[1]);
int howmany = 1000000;
g2LogWorker g2log(argv[0], "logs");
g2::initializeLogging(&g2log);
std::atomic<int > msg_counter {0};
vector<thread> threads;
auto start = clock::now();
for (int t = 0; t < thread_count; ++t)
{
threads.push_back(std::thread([&]()
{
while (true)
{
int counter = ++msg_counter;
if (counter > howmany) break;
LOG(INFO) << "g2log message #" << counter << ": This is some text for your pleasure";
}
}));
}
for(auto &t:threads)
{
t.join();
};
duration<float> delta = clock::now() - start;
float deltaf = delta.count();
auto rate = howmany/deltaf;
cout << "Total: " << howmany << std::endl;
cout << "Threads: " << thread_count << std::endl;
std::cout << "Delta = " << deltaf << " seconds" << std::endl;
std::cout << "Rate = " << rate << "/sec" << std::endl;
}

View File

@ -1,50 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include <thread>
#include <vector>
#include <atomic>
#include "glog/logging.h"
using namespace std;
int main(int argc, char* argv[])
{
int thread_count = 10;
if(argc > 1)
thread_count = atoi(argv[1]);
int howmany = 1000000;
FLAGS_logtostderr = 0;
FLAGS_log_dir = "logs";
google::InitGoogleLogging(argv[0]);
std::atomic<int > msg_counter {0};
vector<thread> threads;
for (int t = 0; t < thread_count; ++t)
{
threads.push_back(std::thread([&]()
{
while (true)
{
int counter = ++msg_counter;
if (counter > howmany) break;
LOG(INFO) << "glog message #" << counter << ": This is some text for your pleasure";
}
}));
}
for(auto &t:threads)
{
t.join();
};
return 0;
}

View File

@ -1,21 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include "glog/logging.h"
int main(int, char* argv[])
{
int howmany = 1000000;
FLAGS_logtostderr = 0;
FLAGS_log_dir = "logs";
google::InitGoogleLogging(argv[0]);
for(int i = 0 ; i < howmany; ++i)
LOG(INFO) << "glog message # " << i << ": This is some text for your pleasure";
return 0;
}

220
bench/latency.cpp Normal file
View File

@ -0,0 +1,220 @@
//
// Copyright(c) 2018 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
//
// latency.cpp : spdlog latency benchmarks
//
#include "benchmark/benchmark.h"
#include "spdlog/spdlog.h"
#include "spdlog/async.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/daily_file_sink.h"
#include "spdlog/sinks/null_sink.h"
#include "spdlog/sinks/rotating_file_sink.h"
void bench_c_string(benchmark::State &state, std::shared_ptr<spdlog::logger> logger) {
const char *msg =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pharetra metus cursus "
"lacus placerat congue. Nulla egestas, mauris a tincidunt tempus, enim lectus volutpat mi, "
"eu consequat sem "
"libero nec massa. In dapibus ipsum a diam rhoncus gravida. Etiam non dapibus eros. Donec "
"fringilla dui sed "
"augue pretium, nec scelerisque est maximus. Nullam convallis, sem nec blandit maximus, "
"nisi turpis ornare "
"nisl, sit amet volutpat neque massa eu odio. Maecenas malesuada quam ex, posuere congue "
"nibh turpis duis.";
for (auto _ : state) {
logger->info(msg);
}
}
void bench_logger(benchmark::State &state, std::shared_ptr<spdlog::logger> logger) {
int i = 0;
for (auto _ : state) {
logger->info("Hello logger: msg number {}...............", ++i);
}
}
void bench_global_logger(benchmark::State &state, std::shared_ptr<spdlog::logger> logger) {
spdlog::set_default_logger(std::move(logger));
int i = 0;
for (auto _ : state) {
spdlog::info("Hello logger: msg number {}...............", ++i);
}
}
void bench_disabled_macro(benchmark::State &state, std::shared_ptr<spdlog::logger> logger) {
int i = 0;
benchmark::DoNotOptimize(i); // prevent unused warnings
benchmark::DoNotOptimize(logger); // prevent unused warnings
for (auto _ : state) {
SPDLOG_LOGGER_DEBUG(logger, "Hello logger: msg number {}...............", i++);
}
}
void bench_disabled_macro_global_logger(benchmark::State &state,
std::shared_ptr<spdlog::logger> logger) {
spdlog::set_default_logger(std::move(logger));
int i = 0;
benchmark::DoNotOptimize(i); // prevent unused warnings
benchmark::DoNotOptimize(logger); // prevent unused warnings
for (auto _ : state) {
SPDLOG_DEBUG("Hello logger: msg number {}...............", i++);
}
}
#ifdef __linux__
void bench_dev_null() {
auto dev_null_st = spdlog::basic_logger_st("/dev/null_st", "/dev/null");
benchmark::RegisterBenchmark("/dev/null_st", bench_logger, std::move(dev_null_st))
->UseRealTime();
spdlog::drop("/dev/null_st");
auto dev_null_mt = spdlog::basic_logger_mt("/dev/null_mt", "/dev/null");
benchmark::RegisterBenchmark("/dev/null_mt", bench_logger, std::move(dev_null_mt))
->UseRealTime();
spdlog::drop("/dev/null_mt");
}
#endif // __linux__
int main(int argc, char *argv[]) {
using spdlog::sinks::null_sink_mt;
using spdlog::sinks::null_sink_st;
size_t file_size = 30 * 1024 * 1024;
size_t rotating_files = 5;
int n_threads = benchmark::CPUInfo::Get().num_cpus;
auto full_bench = argc > 1 && std::string(argv[1]) == "full";
// disabled loggers
auto disabled_logger =
std::make_shared<spdlog::logger>("bench", std::make_shared<null_sink_mt>());
disabled_logger->set_level(spdlog::level::off);
benchmark::RegisterBenchmark("disabled-at-compile-time", bench_disabled_macro, disabled_logger);
benchmark::RegisterBenchmark("disabled-at-compile-time (global logger)",
bench_disabled_macro_global_logger, disabled_logger);
benchmark::RegisterBenchmark("disabled-at-runtime", bench_logger, disabled_logger);
benchmark::RegisterBenchmark("disabled-at-runtime (global logger)", bench_global_logger,
disabled_logger);
// with backtrace of 64
auto tracing_disabled_logger =
std::make_shared<spdlog::logger>("bench", std::make_shared<null_sink_mt>());
tracing_disabled_logger->enable_backtrace(64);
benchmark::RegisterBenchmark("disabled-at-runtime/backtrace", bench_logger,
tracing_disabled_logger);
auto null_logger_st =
std::make_shared<spdlog::logger>("bench", std::make_shared<null_sink_st>());
benchmark::RegisterBenchmark("null_sink_st (500_bytes c_str)", bench_c_string,
std::move(null_logger_st));
benchmark::RegisterBenchmark("null_sink_st", bench_logger, null_logger_st);
benchmark::RegisterBenchmark("null_sink_st (global logger)", bench_global_logger,
null_logger_st);
// with backtrace of 64
auto tracing_null_logger_st =
std::make_shared<spdlog::logger>("bench", std::make_shared<null_sink_st>());
tracing_null_logger_st->enable_backtrace(64);
benchmark::RegisterBenchmark("null_sink_st/backtrace", bench_logger, tracing_null_logger_st);
#ifdef __linux__
bench_dev_null();
#endif // __linux__
if (full_bench) {
// basic_st
auto basic_st = spdlog::basic_logger_st("basic_st", "latency_logs/basic_st.log", true);
benchmark::RegisterBenchmark("basic_st", bench_logger, std::move(basic_st))->UseRealTime();
spdlog::drop("basic_st");
// with backtrace of 64
auto tracing_basic_st =
spdlog::basic_logger_st("tracing_basic_st", "latency_logs/tracing_basic_st.log", true);
tracing_basic_st->enable_backtrace(64);
benchmark::RegisterBenchmark("basic_st/backtrace", bench_logger,
std::move(tracing_basic_st))
->UseRealTime();
spdlog::drop("tracing_basic_st");
// rotating st
auto rotating_st = spdlog::rotating_logger_st("rotating_st", "latency_logs/rotating_st.log",
file_size, rotating_files);
benchmark::RegisterBenchmark("rotating_st", bench_logger, std::move(rotating_st))
->UseRealTime();
spdlog::drop("rotating_st");
// with backtrace of 64
auto tracing_rotating_st = spdlog::rotating_logger_st(
"tracing_rotating_st", "latency_logs/tracing_rotating_st.log", file_size,
rotating_files);
benchmark::RegisterBenchmark("rotating_st/backtrace", bench_logger,
std::move(tracing_rotating_st))
->UseRealTime();
spdlog::drop("tracing_rotating_st");
// daily st
auto daily_st = spdlog::daily_logger_mt("daily_st", "latency_logs/daily_st.log");
benchmark::RegisterBenchmark("daily_st", bench_logger, std::move(daily_st))->UseRealTime();
spdlog::drop("daily_st");
auto tracing_daily_st =
spdlog::daily_logger_mt("tracing_daily_st", "latency_logs/daily_st.log");
benchmark::RegisterBenchmark("daily_st/backtrace", bench_logger,
std::move(tracing_daily_st))
->UseRealTime();
spdlog::drop("tracing_daily_st");
//
// Multi threaded bench, 10 loggers using same logger concurrently
//
auto null_logger_mt =
std::make_shared<spdlog::logger>("bench", std::make_shared<null_sink_mt>());
benchmark::RegisterBenchmark("null_sink_mt", bench_logger, null_logger_mt)
->Threads(n_threads)
->UseRealTime();
// basic_mt
auto basic_mt = spdlog::basic_logger_mt("basic_mt", "latency_logs/basic_mt.log", true);
benchmark::RegisterBenchmark("basic_mt", bench_logger, std::move(basic_mt))
->Threads(n_threads)
->UseRealTime();
spdlog::drop("basic_mt");
// rotating mt
auto rotating_mt = spdlog::rotating_logger_mt("rotating_mt", "latency_logs/rotating_mt.log",
file_size, rotating_files);
benchmark::RegisterBenchmark("rotating_mt", bench_logger, std::move(rotating_mt))
->Threads(n_threads)
->UseRealTime();
spdlog::drop("rotating_mt");
// daily mt
auto daily_mt = spdlog::daily_logger_mt("daily_mt", "latency_logs/daily_mt.log");
benchmark::RegisterBenchmark("daily_mt", bench_logger, std::move(daily_mt))
->Threads(n_threads)
->UseRealTime();
spdlog::drop("daily_mt");
}
// async
auto queue_size = 1024 * 1024 * 3;
auto tp = std::make_shared<spdlog::details::thread_pool>(queue_size, 1);
auto async_logger = std::make_shared<spdlog::async_logger>(
"async_logger", std::make_shared<null_sink_mt>(), std::move(tp),
spdlog::async_overflow_policy::overrun_oldest);
benchmark::RegisterBenchmark("async_logger", bench_logger, async_logger)
->Threads(n_threads)
->UseRealTime();
auto async_logger_tracing = std::make_shared<spdlog::async_logger>(
"async_logger_tracing", std::make_shared<null_sink_mt>(), std::move(tp),
spdlog::async_overflow_policy::overrun_oldest);
async_logger_tracing->enable_backtrace(32);
benchmark::RegisterBenchmark("async_logger/tracing", bench_logger, async_logger_tracing)
->Threads(n_threads)
->UseRealTime();
benchmark::Initialize(&argc, argv);
benchmark::RunSpecifiedBenchmarks();
}

View File

@ -1,32 +0,0 @@
CXX ?= g++
CXXFLAGS = -march=native -Wall -std=c++11 -pthread
CXX_RELEASE_FLAGS = -O2 -DNDEBUG
binaries=spdlog-latency g3log-latency g3log-crush
all: $(binaries)
spdlog-latency: spdlog-latency.cpp
$(CXX) spdlog-latency.cpp -o spdlog-latency $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -I../../include
g3log-latency: g3log-latency.cpp
$(CXX) g3log-latency.cpp -o g3log-latency $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -I../../../g3log/src -L. -lg3logger
g3log-crush: g3log-crush.cpp
$(CXX) g3log-crush.cpp -o g3log-crush $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -I../../../g3log/src -L. -lg3logger
.PHONY: clean
clean:
rm -f *.o *.log $(binaries)
rebuild: clean all

View File

@ -1,13 +0,0 @@
#!/bin/bash
echo "running spdlog and g3log tests 10 time with ${1:-10} threads each (total 1,000,000 entries).."
rm -f *.log
for i in {1..10}
do
echo
sleep 0.5
./spdlog-latency ${1:-10} 2>/dev/null || exit
sleep 0.5
./g3log-latency ${1:-10} 2>/dev/null || exit
done

View File

@ -1,37 +0,0 @@
#include <iostream>
#include <g3log/g3log.hpp>
#include <g3log/logworker.hpp>
void CrusherLoop()
{
size_t counter = 0;
while (true)
{
LOGF(INFO, "Some text to crush you machine. thread:");
if(++counter % 1000000 == 0)
{
std::cout << "Wrote " << counter << " entries" << std::endl;
}
}
}
int main(int argc, char** argv)
{
std::cout << "WARNING: This test will exaust all your machine memory and will crush it!" << std::endl;
std::cout << "Are you sure you want to continue ? " << std::endl;
char c;
std::cin >> c;
if (toupper( c ) != 'Y')
return 0;
auto worker = g3::LogWorker::createLogWorker();
auto handle= worker->addDefaultLogger(argv[0], "g3log.txt");
g3::initializeLogging(worker.get());
CrusherLoop();
return 0;
}

View File

@ -1,129 +0,0 @@
#include <thread>
#include <vector>
#include <atomic>
#include <iostream>
#include <chrono>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstdio>
#include <map>
#include <numeric>
#include <functional>
#include <thread>
#include "utils.h"
#include <g3log/g3log.hpp>
#include <g3log/logworker.hpp>
namespace
{
const uint64_t g_iterations = 1000000;
std::atomic<size_t> g_counter = {0};
void MeasurePeakDuringLogWrites(const size_t id, std::vector<uint64_t>& result)
{
while (true)
{
const size_t value_now = ++g_counter;
if (value_now > g_iterations)
{
return;
}
auto start_time = std::chrono::high_resolution_clock::now();
LOGF(INFO, "Some text to log for thread: %ld", id);
auto stop_time = std::chrono::high_resolution_clock::now();
uint64_t time_us = std::chrono::duration_cast<std::chrono::microseconds>(stop_time - start_time).count();
result.push_back(time_us);
}
}
void PrintResults(const std::map<size_t, std::vector<uint64_t>>& threads_result, size_t total_us)
{
std::vector<uint64_t> all_measurements;
all_measurements.reserve(g_iterations);
for (auto& t_result : threads_result)
{
all_measurements.insert(all_measurements.end(), t_result.second.begin(), t_result.second.end());
}
// calc worst latenct
auto worst = *std::max_element(all_measurements.begin(), all_measurements.end());
// calc avg
auto total = accumulate(begin(all_measurements), end(all_measurements), 0, std::plus<uint64_t>());
auto avg = double(total)/all_measurements.size();
std::cout << "[g3log] worst: " << std::setw(10) << std::right << worst << "\tAvg: " << avg << "\tTotal: " << utils::format(total_us) << " us" << std::endl;
}
}// anonymous
// The purpose of this test is NOT to see how fast
// each thread can possibly write. It is to see what
// the worst latency is for writing a log entry
//
// In the test 1 million log entries will be written
// an atomic counter is used to give each thread what
// it is to write next. The overhead of atomic
// synchronization between the threads are not counted in the worst case latency
int main(int argc, char** argv)
{
size_t number_of_threads {0};
if (argc == 2)
{
number_of_threads = atoi(argv[1]);
}
if (argc != 2 || number_of_threads == 0)
{
std::cerr << "USAGE is: " << argv[0] << " number_threads" << std::endl;
return 1;
}
std::vector<std::thread> threads(number_of_threads);
std::map<size_t, std::vector<uint64_t>> threads_result;
for (size_t idx = 0; idx < number_of_threads; ++idx)
{
// reserve to 1 million for all the result
// it's a test so let's not care about the wasted space
threads_result[idx].reserve(g_iterations);
}
const std::string g_path = "./" ;
const std::string g_prefix_log_name = "g3log-performance-";
const std::string g_measurement_dump = g_path + g_prefix_log_name + "_RESULT.txt";
auto worker = g3::LogWorker::createLogWorker();
auto handle= worker->addDefaultLogger(argv[0], "g3log.txt");
g3::initializeLogging(worker.get());
auto start_time_application_total = std::chrono::high_resolution_clock::now();
for (uint64_t idx = 0; idx < number_of_threads; ++idx)
{
threads[idx] = std::thread(MeasurePeakDuringLogWrites, idx, std::ref(threads_result[idx]));
}
for (size_t idx = 0; idx < number_of_threads; ++idx)
{
threads[idx].join();
}
auto stop_time_application_total = std::chrono::high_resolution_clock::now();
uint64_t total_time_in_us = std::chrono::duration_cast<std::chrono::microseconds>(stop_time_application_total - start_time_application_total).count();
PrintResults(threads_result, total_time_in_us);
return 0;
}

View File

@ -1,128 +0,0 @@
#include <thread>
#include <vector>
#include <atomic>
#include <iostream>
#include <chrono>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <functional>
#include "utils.h"
#include <thread>
#include "spdlog/spdlog.h"
namespace spd = spdlog;
namespace
{
const uint64_t g_iterations = 1000000;
std::atomic<size_t> g_counter = {0};
void MeasurePeakDuringLogWrites(const size_t id, std::vector<uint64_t>& result)
{
auto logger = spd::get("file_logger");
while (true)
{
const size_t value_now = ++g_counter;
if (value_now > g_iterations)
{
return;
}
auto start_time = std::chrono::high_resolution_clock::now();
logger->info("Some text to log for thread: [somemore text...............................] {}", id);
auto stop_time = std::chrono::high_resolution_clock::now();
uint64_t time_us = std::chrono::duration_cast<std::chrono::microseconds>(stop_time - start_time).count();
result.push_back(time_us);
}
}
void PrintResults(const std::map<size_t, std::vector<uint64_t>>& threads_result, size_t total_us)
{
std::vector<uint64_t> all_measurements;
all_measurements.reserve(g_iterations);
for (auto& t_result : threads_result)
{
all_measurements.insert(all_measurements.end(), t_result.second.begin(), t_result.second.end());
}
// calc worst latenct
auto worst = *std::max_element(all_measurements.begin(), all_measurements.end());
// calc avg
auto total = accumulate(begin(all_measurements), end(all_measurements), 0, std::plus<uint64_t>());
auto avg = double(total)/all_measurements.size();
std::cout << "[spdlog] worst: " << std::setw(10) << std::right << worst << "\tAvg: " << avg << "\tTotal: " << utils::format(total_us) << " us" << std::endl;
}
}// anonymous
// The purpose of this test is NOT to see how fast
// each thread can possibly write. It is to see what
// the worst latency is for writing a log entry
//
// In the test 1 million log entries will be written
// an atomic counter is used to give each thread what
// it is to write next. The overhead of atomic
// synchronization between the threads are not counted in the worst case latency
int main(int argc, char** argv)
{
size_t number_of_threads {0};
if (argc == 2)
{
number_of_threads = atoi(argv[1]);
}
if (argc != 2 || number_of_threads == 0)
{
std::cerr << "usage: " << argv[0] << " number_threads" << std::endl;
return 1;
}
std::vector<std::thread> threads(number_of_threads);
std::map<size_t, std::vector<uint64_t>> threads_result;
for (size_t idx = 0; idx < number_of_threads; ++idx)
{
// reserve to 1 million for all the result
// it's a test so let's not care about the wasted space
threads_result[idx].reserve(g_iterations);
}
int queue_size = 1048576; // 2 ^ 20
spdlog::set_async_mode(queue_size);
auto logger = spdlog::create<spd::sinks::simple_file_sink_mt>("file_logger", "spdlog.log", true);
//force flush on every call to compare with g3log
auto s = (spd::sinks::simple_file_sink_mt*)logger->sinks()[0].get();
s->set_force_flush(true);
auto start_time_application_total = std::chrono::high_resolution_clock::now();
for (uint64_t idx = 0; idx < number_of_threads; ++idx)
{
threads[idx] = std::thread(MeasurePeakDuringLogWrites, idx, std::ref(threads_result[idx]));
}
for (size_t idx = 0; idx < number_of_threads; ++idx)
{
threads[idx].join();
}
auto stop_time_application_total = std::chrono::high_resolution_clock::now();
uint64_t total_time_in_us = std::chrono::duration_cast<std::chrono::microseconds>(stop_time_application_total - start_time_application_total).count();
PrintResults(threads_result, total_time_in_us);
return 0;
}

View File

@ -1,35 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
#include <sstream>
#include <iomanip>
#include <locale>
namespace utils
{
template<typename T>
inline std::string format(const T& value)
{
static std::locale loc("");
std::stringstream ss;
ss.imbue(loc);
ss << value;
return ss.str();
}
template<>
inline std::string format(const double & value)
{
static std::locale loc("");
std::stringstream ss;
ss.imbue(loc);
ss << std::fixed << std::setprecision(1) << value;
return ss.str();
}
}

View File

@ -1,4 +0,0 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@ -1,62 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include <thread>
#include <vector>
#include <atomic>
#include <iostream>
#include <chrono>
#include <cstdlib>
#include "spdlog/spdlog.h"
using namespace std;
int main(int argc, char* argv[])
{
using namespace std::chrono;
using clock=steady_clock;
namespace spd = spdlog;
int thread_count = 10;
if(argc > 1)
thread_count = ::atoi(argv[1]);
int howmany = 1000000;
spd::set_async_mode(1048576);
auto logger = spdlog::create<spd::sinks::simple_file_sink_mt>("file_logger", "logs/spd-bench-async.txt", false);
logger->set_pattern("[%Y-%b-%d %T.%e]: %v");
std::atomic<int > msg_counter {0};
vector<thread> threads;
auto start = clock::now();
for (int t = 0; t < thread_count; ++t)
{
threads.push_back(std::thread([&]()
{
while (true)
{
int counter = ++msg_counter;
if (counter > howmany) break;
logger->info("spdlog message #{}: This is some text for your pleasure", counter);
}
}));
}
for(auto &t:threads)
{
t.join();
};
duration<float> delta = clock::now() - start;
float deltaf = delta.count();
auto rate = howmany/deltaf;
cout << "Total: " << howmany << std::endl;
cout << "Threads: " << thread_count << std::endl;
std::cout << "Delta = " << deltaf << " seconds" << std::endl;
std::cout << "Rate = " << rate << "/sec" << std::endl;
}

View File

@ -1,55 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include <thread>
#include <vector>
#include <atomic>
#include <cstdlib>
#include "spdlog/spdlog.h"
using namespace std;
int main(int argc, char* argv[])
{
int thread_count = 10;
if(argc > 1)
thread_count = std::atoi(argv[1]);
int howmany = 1000000;
namespace spd = spdlog;
auto logger = spdlog::create<spd::sinks::simple_file_sink_mt>("file_logger", "logs/spd-bench-mt.txt", false);
logger->set_pattern("[%Y-%b-%d %T.%e]: %v");
std::atomic<int > msg_counter {0};
std::vector<thread> threads;
for (int t = 0; t < thread_count; ++t)
{
threads.push_back(std::thread([&]()
{
while (true)
{
int counter = ++msg_counter;
if (counter > howmany) break;
logger->info("spdlog message #{}: This is some text for your pleasure", counter);
}
}));
}
for(auto &t:threads)
{
t.join();
};
return 0;
}

View File

@ -1,20 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include "spdlog/spdlog.h"
int main(int, char* [])
{
int howmany = 1000000;
namespace spd = spdlog;
///Create a file rotating logger with 5mb size max and 3 rotated files
auto logger = spdlog::create<spd::sinks::simple_file_sink_st>("file_logger", "logs/spd-bench-st.txt", false);
logger->set_pattern("[%Y-%b-%d %T.%e]: %v");
for(int i = 0 ; i < howmany; ++i)
logger->info("spdlog message #{} : This is some text for your pleasure", i);
return 0;
}

View File

@ -1,112 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
//
// bench.cpp : spdlog benchmarks
//
#include <atomic>
#include <cstdlib> // EXIT_FAILURE
#include <iostream>
#include <memory>
#include <string>
#include <thread>
#include "spdlog/spdlog.h"
#include "spdlog/async_logger.h"
#include "spdlog/sinks/null_sink.h"
#include "utils.h"
using namespace std;
using namespace std::chrono;
using namespace spdlog;
using namespace spdlog::sinks;
using namespace utils;
size_t bench_as(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count);
int main(int argc, char* argv[])
{
int queue_size = 1048576;
int howmany = 1000000;
int threads = 10;
int iters = 10;
try
{
if(argc > 1)
howmany = atoi(argv[1]);
if (argc > 2)
threads = atoi(argv[2]);
if (argc > 3)
queue_size = atoi(argv[3]);
cout << "\n*******************************************************************************\n";
cout << "async logging.. " << threads << " threads sharing same logger, " << format(howmany) << " messages " << endl;
cout << "*******************************************************************************\n";
spdlog::set_async_mode(queue_size);
size_t total_rate = 0;
for(int i = 0; i < iters; ++i)
{
//auto as = spdlog::daily_logger_st("as", "logs/daily_async");
auto as = spdlog::create<null_sink_st>("async(null-sink)");
total_rate+= bench_as(howmany, as, threads);
spdlog::drop("async(null-sink)");
}
std::cout << endl;
std::cout << "Avg rate: " << format(total_rate/iters) << "/sec" <<std::endl;
}
catch (std::exception &ex)
{
std::cerr << "Error: " << ex.what() << std::endl;
perror("Last error");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
//return rate/sec
size_t bench_as(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count)
{
cout << log->name() << "...\t\t" << flush;
std::atomic<int > msg_counter {0};
vector<thread> threads;
auto start = system_clock::now();
for (int t = 0; t < thread_count; ++t)
{
threads.push_back(std::thread([&]()
{
for(;;)
{
int counter = ++msg_counter;
if (counter > howmany) break;
log->info("Hello logger: msg number {}", counter);
}
}));
}
for(auto &t:threads)
{
t.join();
};
auto delta = system_clock::now() - start;
auto delta_d = duration_cast<duration<double>> (delta).count();
auto per_sec = size_t(howmany / delta_d);
cout << format(per_sec) << "/sec" << endl;
return per_sec;
}

View File

@ -5,16 +5,14 @@
#pragma once
#include <sstream>
#include <iomanip>
#include <locale>
#include <sstream>
namespace utils
{
namespace utils {
template <typename T>
inline std::string format(const T& value)
{
inline std::string format(const T &value) {
static std::locale loc("");
std::stringstream ss;
ss.imbue(loc);
@ -23,8 +21,7 @@ inline std::string format(const T& value)
}
template <>
inline std::string format(const double & value)
{
inline std::string format(const double &value) {
static std::locale loc("");
std::stringstream ss;
ss.imbue(loc);
@ -32,4 +29,4 @@ inline std::string format(const double & value)
return ss.str();
}
}
} // namespace utils

View File

@ -1,24 +0,0 @@
# *************************************************************************/
# * Copyright (c) 2015 Ruslan Baratov. */
# * */
# * Permission is hereby granted, free of charge, to any person obtaining */
# * a copy of this software and associated documentation files (the */
# * "Software"), to deal in the Software without restriction, including */
# * without limitation the rights to use, copy, modify, merge, publish, */
# * distribute, sublicense, and/or sell copies of the Software, and to */
# * permit persons to whom the Software is furnished to do so, subject to */
# * the following conditions: */
# * */
# * The above copyright notice and this permission notice shall be */
# * included in all copies or substantial portions of the Software. */
# * */
# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
# * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
# * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
# * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
# * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
# * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
# *************************************************************************/
include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")

18
cmake/ide.cmake Normal file
View File

@ -0,0 +1,18 @@
# ---------------------------------------------------------------------------------------
# IDE support for headers
# ---------------------------------------------------------------------------------------
set(SPDLOG_HEADERS_DIR "${CMAKE_CURRENT_LIST_DIR}/../include")
file(GLOB SPDLOG_TOP_HEADERS "${SPDLOG_HEADERS_DIR}/spdlog/*.h")
file(GLOB SPDLOG_DETAILS_HEADERS "${SPDLOG_HEADERS_DIR}/spdlog/details/*.h")
file(GLOB SPDLOG_SINKS_HEADERS "${SPDLOG_HEADERS_DIR}/spdlog/sinks/*.h")
file(GLOB SPDLOG_FMT_HEADERS "${SPDLOG_HEADERS_DIR}/spdlog/fmt/*.h")
file(GLOB SPDLOG_FMT_BUNDELED_HEADERS "${SPDLOG_HEADERS_DIR}/spdlog/fmt/bundled/*.h")
set(SPDLOG_ALL_HEADERS ${SPDLOG_TOP_HEADERS} ${SPDLOG_DETAILS_HEADERS} ${SPDLOG_SINKS_HEADERS} ${SPDLOG_FMT_HEADERS}
${SPDLOG_FMT_BUNDELED_HEADERS})
source_group("Header Files\\spdlog" FILES ${SPDLOG_TOP_HEADERS})
source_group("Header Files\\spdlog\\details" FILES ${SPDLOG_DETAILS_HEADERS})
source_group("Header Files\\spdlog\\sinks" FILES ${SPDLOG_SINKS_HEADERS})
source_group("Header Files\\spdlog\\fmt" FILES ${SPDLOG_FMT_HEADERS})
source_group("Header Files\\spdlog\\fmt\\bundled\\" FILES ${SPDLOG_FMT_BUNDELED_HEADERS})

258
cmake/pch.h.in Normal file
View File

@ -0,0 +1,258 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
// details/pattern_formatter-inl.h
// fmt/bin_to_hex.h
// fmt/bundled/format-inl.h
#include <cctype>
// details/file_helper-inl.h
// details/os-inl.h
// fmt/bundled/core.h
// fmt/bundled/posix.h
// logger-inl.h
// sinks/daily_file_sink.h
// sinks/stdout_sinks.h
#include <cstdio>
// details/os-inl.h
// fmt/bundled/posix.h
#include <cstdlib>
// details/os-inl.h
// details/pattern_formatter-inl.h
// fmt/bundled/core.h
// fmt/bundled/format-inl.h
#include <cstring>
// details/os-inl.h
// details/os.h
// details/pattern_formatter-inl.h
// details/pattern_formatter.h
// fmt/bundled/chrono.h
// sinks/daily_file_sink.h
// sinks/rotating_file_sink-inl.h
#include <ctime>
// fmt/bundled/format-inl.h
#include <climits>
// fmt/bundled/format-inl.h
#include <cwchar>
// fmt/bundled/format-inl.h
// fmt/bundled/format.h
#include <cmath>
// fmt/bundled/format-inl.h
#include <cstdarg>
// details/file_helper-inl.h
// fmt/bundled/format.h
// fmt/bundled/posix.h
// sinks/rotating_file_sink-inl.h
#include <cerrno>
// details/circular_q.h
// details/thread_pool-inl.h
// fmt/bundled/format-inl.h
#include <cassert>
// async_logger-inl.h
// cfg/helpers-inl.h
// log_levels.h
// common.h
// details/file_helper-inl.h
// details/log_msg.h
// details/os-inl.h
// details/pattern_formatter-inl.h
// details/pattern_formatter.h
// details/registry-inl.h
// details/registry.h
// details/tcp_client-windows.h
// details/tcp_client.h
// fmt/bundled/core.h
// sinks/android_sink.h
// sinks/ansicolor_sink.h
// sinks/basic_file_sink.h
// sinks/daily_file_sink.h
// sinks/dup_filter_sink.h
// sinks/msvc_sink.h
// sinks/ringbuffer_sink.h
// sinks/rotating_file_sink-inl.h
// sinks/rotating_file_sink.h
// sinks/syslog_sink.h
// sinks/tcp_sink.h
// sinks/win_eventlog_sink.h
// sinks/wincolor_sink.h
// spdlog.h:
#include <string>
// cfg/helpers-inl.h
// fmt/bundled/chrono.h
#include <sstream>
// fmt/bundled/ostream.h
// sinks/ostream_sink.h
#include <ostream>
// cfg/log_levels.h
// details/registry-inl.h
// details/registry.h
#include <unordered_map>
// details/circular_q.h
// details/pattern_formatter-inl.h
// details/pattern_formatter.h
// details/thread_pool.h
// fmt/bundled/compile.h
// logger.h
// sinks/dist_sink.h
// sinks/ringbuffer_sink.h
// sinks/win_eventlog_sink.h
#include <vector>
// details/os-inl.h
// details/pattern_formatter-inl.h
// sinks/ansicolor_sink.h
// sinks/syslog_sink.h
// sinks/systemd_sink.h
// sinks/wincolor_sink.h
#include <array>
// details/file_helper-inl.h
// details/file_helper.h
// sinks/rotating_file_sink-inl.h
#include <tuple>
// details/os-inl.h
// fmt/bundled/format.h
// fmt/bundled/printf.h
#include <limits>
// common.h
// details/backtracer.h
// details/null_mutex.h
#include <atomic>
// common.h
// details/backtracer.h
// details/null_mutex.h
#include <locale>
// common.h
#include <initializer_list>
// common.h
#include <exception>
// common.h
// details/fmt_helper.h
// fmt/bundled/core.h
// fmt/bundled/ranges.h
#include <type_traits>
// cfg/helpers-inl.h
// details/null_mutex.h
// details/pattern_formatter-inl.h
#include <utility>
// async.h
// async_logger-inl.h
// common.h
// details/pattern_formatter-inl.h
// details/pattern_formatter.h
// details/registry-inl.h
// details/registry.h
// details/thread_pool.h
// fmt/bundled/format.h
// sinks/ansicolor_sink.h
// sinks/base_sink-inl.h
// sinks/dist_sink.h
// sinks/stdout_sinks-inl.h
// sinks/wincolor_sink.h
// spdlog.h
#include <memory>
// async.h
// common.h
// details/backtracer.h
// details/periodic_worker.h
// details/registry-inl.h
// details/registry.h
// details/thread_pool.h
// sinks/tcp_sink.h
// spdlog.h
#include <functional>
// details/mpmc_blocking_q.h
// details/periodic_worker.h
#include <condition_variable>
// details/os-inl.h
// fmt/bundled/format.h
// fmt/bundled/printf.h
// sinks/dist_sink.h
#include <algorithm>
// common.h
// details/file_helper-inl.h
// details/fmt_helper.h
// details/os-inl.h
// details/pattern_formatter-inl.h
// details/pattern_formatter.h
// details/periodic_worker.h
// details/registry-inl.h
// details/registry.h
// details/thread_pool.h
// fmt/bundled/chrono.h
// sinks/android_sink.h
// sinks/daily_file_sink.h
// sinks/dup_filter_sink.h
// sinks/rotating_file_sink-inl.h
// sinks/rotating_file_sink.h
// sinks/tcp_sink.h
// spdlog.h
#include <chrono>
// details/file_helper-inl.h
// details/os-inl.h
// details/pattern_formatter-inl.h
// details/periodic_worker.h
// details/thread_pool.h
// sinks/android_sink.h
#include <thread>
// async.h
// details/backtracer.h
// details/console_globals.h
// details/mpmc_blocking_q.h
// details/pattern_formatter-inl.h
// details/periodic_worker.h
// details/registry.h
// sinks/android_sink.h
// sinks/ansicolor_sink.h
// sinks/basic_file_sink.h
// sinks/daily_file_sink.h
// sinks/dist_sink.h
// sinks/dup_filter_sink.h
// sinks/msvc_sink.h
// sinks/null_sink.h
// sinks/ostream_sink.h
// sinks/ringbuffer_sink.h
// sinks/rotating_file_sink-inl.h
// sinks/rotating_file_sink.h
// sinks/tcp_sink.h
// sinks/win_eventlog_sink.h
// sinks/wincolor_sink.h
//
// color_sinks.cpp
// file_sinks.cpp
// spdlog.cpp
// stdout_sinks.cpp
#include <mutex>
// spdlog
#include <spdlog/common.h>

View File

@ -1,6 +1,13 @@
prefix=@CMAKE_INSTALL_PREFIX@
includedir=${prefix}/include
exec_prefix=${prefix}
includedir=@PKG_CONFIG_INCLUDEDIR@
libdir=@PKG_CONFIG_LIBDIR@
Name: lib@PROJECT_NAME@
Description: Fast C++ logging library.
URL: https://github.com/gabime/@PROJECT_NAME@
Version: @SPDLOG_VERSION@
CFlags: -I${includedir} @PKG_CONFIG_DEFINES@
Libs: -L${libdir} -lspdlog -pthread
Requires: @PKG_CONFIG_REQUIRES@
Name: @PROJECT_NAME@
Description: Super fast C++ logging library.
Version: @PROJECT_VERSION@

60
cmake/spdlogCPack.cmake Normal file
View File

@ -0,0 +1,60 @@
set(CPACK_GENERATOR "TGZ;ZIP" CACHE STRING "Semicolon separated list of generators")
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
set(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_BINARY_DIR}" "${PROJECT_NAME}" ALL .)
set(CPACK_PROJECT_URL "https://github.com/gabime/spdlog")
set(CPACK_PACKAGE_VENDOR "Gabi Melman")
set(CPACK_PACKAGE_CONTACT "Gabi Melman <gmelman1@gmail.com>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Fast C++ logging library")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
if(PROJECT_VERSION_TWEAK)
set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}.${PROJECT_VERSION_TWEAK})
endif()
set(CPACK_PACKAGE_RELOCATABLE ON CACHE BOOL "Build relocatable package")
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
set(CPACK_RPM_PACKAGE_URL ${CPACK_PROJECT_URL})
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CPACK_PROJECT_URL})
set(CPACK_RPM_PACKAGE_DESCRIPTION "Very fast, header-only/compiled, C++ logging library.")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Very fast, header-only/compiled, C++ logging library.")
if(CPACK_PACKAGE_NAME)
set(CPACK_RPM_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
set(CPACK_DEBIAN_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
else()
set(CPACK_RPM_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
set(CPACK_DEBIAN_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
set(CPACK_RPM_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_DEBIAN_PACKAGE_NAME "${PROJECT_NAME}")
endif()
if(CPACK_RPM_PACKAGE_RELEASE)
set(CPACK_RPM_FILE_NAME "${CPACK_RPM_FILE_NAME}-${CPACK_RPM_PACKAGE_RELEASE}")
endif()
if(CPACK_DEBIAN_PACKAGE_RELEASE)
set(CPACK_DEBIAN_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}-${CPACK_DEBIAN_PACKAGE_RELEASE}")
endif()
if(CPACK_RPM_PACKAGE_ARCHITECTURE)
set(CPACK_RPM_FILE_NAME "${CPACK_RPM_FILE_NAME}.${CPACK_RPM_PACKAGE_ARCHITECTURE}")
endif()
if(CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
set(CPACK_DEBIAN_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}.${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
endif()
set(CPACK_RPM_FILE_NAME "${CPACK_RPM_FILE_NAME}.rpm")
set(CPACK_DEBIAN_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}.deb")
if(NOT CPACK_PACKAGE_RELOCATABLE)
# Depend on pkgconfig rpm to create the system pkgconfig folder
set(CPACK_RPM_PACKAGE_REQUIRES pkgconfig)
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
"${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endif()
include(CPack)

View File

@ -0,0 +1,20 @@
# Copyright(c) 2019 spdlog authors
# Distributed under the MIT License (http://opensource.org/licenses/MIT)
@PACKAGE_INIT@
find_package(Threads REQUIRED)
set(SPDLOG_FMT_EXTERNAL @SPDLOG_FMT_EXTERNAL@)
set(SPDLOG_FMT_EXTERNAL_HO @SPDLOG_FMT_EXTERNAL_HO@)
set(config_targets_file @config_targets_file@)
if(SPDLOG_FMT_EXTERNAL OR SPDLOG_FMT_EXTERNAL_HO)
include(CMakeFindDependencyMacro)
find_dependency(fmt CONFIG)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/${config_targets_file}")
check_required_components(spdlog)

73
cmake/utils.cmake Normal file
View File

@ -0,0 +1,73 @@
# Get spdlog version from include/spdlog/version.h and put it in SPDLOG_VERSION
function(spdlog_extract_version)
file(READ "${CMAKE_CURRENT_LIST_DIR}/include/spdlog/version.h" file_contents)
string(REGEX MATCH "SPDLOG_VER_MAJOR ([0-9]+)" _ "${file_contents}")
if(NOT CMAKE_MATCH_COUNT EQUAL 1)
message(FATAL_ERROR "Could not extract major version number from spdlog/version.h")
endif()
set(ver_major ${CMAKE_MATCH_1})
string(REGEX MATCH "SPDLOG_VER_MINOR ([0-9]+)" _ "${file_contents}")
if(NOT CMAKE_MATCH_COUNT EQUAL 1)
message(FATAL_ERROR "Could not extract minor version number from spdlog/version.h")
endif()
set(ver_minor ${CMAKE_MATCH_1})
string(REGEX MATCH "SPDLOG_VER_PATCH ([0-9]+)" _ "${file_contents}")
if(NOT CMAKE_MATCH_COUNT EQUAL 1)
message(FATAL_ERROR "Could not extract patch version number from spdlog/version.h")
endif()
set(ver_patch ${CMAKE_MATCH_1})
set(SPDLOG_VERSION_MAJOR ${ver_major} PARENT_SCOPE)
set(SPDLOG_VERSION_MINOR ${ver_minor} PARENT_SCOPE)
set(SPDLOG_VERSION_PATCH ${ver_patch} PARENT_SCOPE)
set(SPDLOG_VERSION "${ver_major}.${ver_minor}.${ver_patch}" PARENT_SCOPE)
endfunction()
# Turn on warnings on the given target
function(spdlog_enable_warnings target_name)
if(SPDLOG_BUILD_WARNINGS)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
list(APPEND MSVC_OPTIONS "/W3")
if(MSVC_VERSION GREATER 1900) # Allow non fatal security warnings for msvc 2015
list(APPEND MSVC_OPTIONS "/WX")
endif()
endif()
target_compile_options(
${target_name}
PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall
-Wextra
-Wconversion
-pedantic
-Werror
-Wfatal-errors>
$<$<CXX_COMPILER_ID:MSVC>:${MSVC_OPTIONS}>)
endif()
endfunction()
# Enable address sanitizer (gcc/clang only)
function(spdlog_enable_addr_sanitizer target_name)
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
message(FATAL_ERROR "Sanitizer supported only for gcc/clang")
endif()
message(STATUS "Address sanitizer enabled")
target_compile_options(${target_name} PRIVATE -fsanitize=address,undefined)
target_compile_options(${target_name} PRIVATE -fno-sanitize=signed-integer-overflow)
target_compile_options(${target_name} PRIVATE -fno-sanitize-recover=all)
target_compile_options(${target_name} PRIVATE -fno-omit-frame-pointer)
target_link_libraries(${target_name} PRIVATE -fsanitize=address,undefined)
endfunction()
# Enable thread sanitizer (gcc/clang only)
function(spdlog_enable_thread_sanitizer target_name)
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
message(FATAL_ERROR "Sanitizer supported only for gcc/clang")
endif()
message(STATUS "Thread sanitizer enabled")
target_compile_options(${target_name} PRIVATE -fsanitize=thread)
target_compile_options(${target_name} PRIVATE -fno-omit-frame-pointer)
target_link_libraries(${target_name} PRIVATE -fsanitize=thread)
endfunction()

42
cmake/version.rc.in Normal file
View File

@ -0,0 +1,42 @@
#define APSTUDIO_READONLY_SYMBOLS
#include <windows.h>
#undef APSTUDIO_READONLY_SYMBOLS
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
VS_VERSION_INFO VERSIONINFO
FILEVERSION @SPDLOG_VERSION_MAJOR@,@SPDLOG_VERSION_MINOR@,@SPDLOG_VERSION_PATCH@,0
PRODUCTVERSION @SPDLOG_VERSION_MAJOR@,@SPDLOG_VERSION_MINOR@,@SPDLOG_VERSION_PATCH@,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "spdlog dll\0"
VALUE "FileVersion", "@SPDLOG_VERSION@.0\0"
VALUE "InternalName", "spdlog.dll\0"
VALUE "LegalCopyright", "Copyright (C) spdlog\0"
VALUE "ProductName", "spdlog\0"
VALUE "ProductVersion", "@SPDLOG_VERSION@.0\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

View File

@ -1,49 +1,23 @@
# *************************************************************************/
# * Copyright (c) 2015 Ruslan Baratov. */
# * */
# * Permission is hereby granted, free of charge, to any person obtaining */
# * a copy of this software and associated documentation files (the */
# * "Software"), to deal in the Software without restriction, including */
# * without limitation the rights to use, copy, modify, merge, publish, */
# * distribute, sublicense, and/or sell copies of the Software, and to */
# * permit persons to whom the Software is furnished to do so, subject to */
# * the following conditions: */
# * */
# * The above copyright notice and this permission notice shall be */
# * included in all copies or substantial portions of the Software. */
# * */
# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
# * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
# * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
# * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
# * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
# * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
# *************************************************************************/
# Copyright(c) 2019 spdlog authors Distributed under the MIT License (http://opensource.org/licenses/MIT)
cmake_minimum_required(VERSION 3.0)
project(SpdlogExamples)
cmake_minimum_required(VERSION 3.11)
project(spdlog_examples CXX)
if(TARGET spdlog)
# Part of the main project
add_library(spdlog::spdlog ALIAS spdlog)
else()
if(NOT TARGET spdlog)
# Stand-alone build
find_package(spdlog CONFIG REQUIRED)
find_package(spdlog REQUIRED)
endif()
find_package(Threads)
# ---------------------------------------------------------------------------------------
# Example of using pre-compiled library
# ---------------------------------------------------------------------------------------
add_executable(example example.cpp)
target_link_libraries(example spdlog::spdlog ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(example PRIVATE spdlog::spdlog $<$<BOOL:${MINGW}>:ws2_32>)
add_executable(benchmark bench.cpp)
target_link_libraries(benchmark spdlog::spdlog ${CMAKE_THREAD_LIBS_INIT})
add_executable(multisink multisink.cpp)
target_link_libraries(multisink spdlog::spdlog ${CMAKE_THREAD_LIBS_INIT})
enable_testing()
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")
add_test(NAME RunExample COMMAND example)
add_test(NAME RunBenchmark COMMAND benchmark)
# ---------------------------------------------------------------------------------------
# Example of using header-only library
# ---------------------------------------------------------------------------------------
if(SPDLOG_BUILD_EXAMPLE_HO)
add_executable(example_header_only example.cpp)
target_link_libraries(example_header_only PRIVATE spdlog::spdlog_header_only)
endif()

View File

@ -1,29 +0,0 @@
CXX ?= g++
CXXFLAGS =
CXX_FLAGS = -Wall -Wshadow -Wextra -pedantic -std=c++11 -pthread -I../include
CXX_RELEASE_FLAGS = -O3 -march=native
CXX_DEBUG_FLAGS= -g
all: example bench
debug: example-debug bench-debug
example: example.cpp
$(CXX) example.cpp -o example $(CXX_FLAGS) $(CXX_RELEASE_FLAGS) $(CXXFLAGS)
bench: bench.cpp
$(CXX) bench.cpp -o bench $(CXX_FLAGS) $(CXX_RELEASE_FLAGS) $(CXXFLAGS)
example-debug: example.cpp
$(CXX) example.cpp -o example-debug $(CXX_FLAGS) $(CXX_DEBUG_FLAGS) $(CXXFLAGS)
bench-debug: bench.cpp
$(CXX) bench.cpp -o bench-debug $(CXX_FLAGS) $(CXX_DEBUG_FLAGS) $(CXXFLAGS)
clean:
rm -f *.o logs/*.txt example example-debug bench bench-debug
rebuild: clean all
rebuild-debug: clean debug

View File

@ -1,32 +0,0 @@
CXX ?= clang++
CXXFLAGS = -march=native -Wall -Wextra -Wshadow -pedantic -std=c++11 -pthread -I../include
CXX_RELEASE_FLAGS = -O2
CXX_DEBUG_FLAGS= -g
all: example bench
debug: example-debug bench-debug
example: example.cpp
$(CXX) example.cpp -o example-clang $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
bench: bench.cpp
$(CXX) bench.cpp -o bench-clang $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
example-debug: example.cpp
$(CXX) example.cpp -o example-clang-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
bench-debug: bench.cpp
$(CXX) bench.cpp -o bench-clang-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
clean:
rm -f *.o logs/*.txt example-clang example-clang-debug bench-clang bench-clang-debug
rebuild: clean all
rebuild-debug: clean debug

View File

@ -1,32 +0,0 @@
CXX ?= g++
CXXFLAGS = -D_WIN32_WINNT=0x600 -march=native -Wall -Wextra -Wshadow -pedantic -std=gnu++0x -pthread -Wl,--no-as-needed -I../include
CXX_RELEASE_FLAGS = -O3
CXX_DEBUG_FLAGS= -g
all: example bench
debug: example-debug bench-debug
example: example.cpp
$(CXX) example.cpp -o example $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
bench: bench.cpp
$(CXX) bench.cpp -o bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
example-debug: example.cpp
$(CXX) example.cpp -o example-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
bench-debug: bench.cpp
$(CXX) bench.cpp -o bench-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
clean:
rm -f *.o logs/*.txt example example-debug bench bench-debug
rebuild: clean all
rebuild-debug: clean debug

View File

@ -1,144 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
//
// bench.cpp : spdlog benchmarks
//
#include <atomic>
#include <cstdlib> // EXIT_FAILURE
#include <iostream>
#include <memory>
#include <string>
#include <thread>
#include "spdlog/spdlog.h"
#include "spdlog/async_logger.h"
#include "spdlog/sinks/file_sinks.h"
#include "spdlog/sinks/null_sink.h"
#include "utils.h"
using namespace std;
using namespace std::chrono;
using namespace spdlog;
using namespace spdlog::sinks;
using namespace utils;
void bench(int howmany, std::shared_ptr<spdlog::logger> log);
void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count);
int main(int argc, char* argv[])
{
int queue_size = 1048576;
int howmany = 1000000;
int threads = 10;
int file_size = 30 * 1024 * 1024;
int rotating_files = 5;
try
{
if(argc > 1)
howmany = atoi(argv[1]);
if (argc > 2)
threads = atoi(argv[2]);
if (argc > 3)
queue_size = atoi(argv[3]);
cout << "*******************************************************************************\n";
cout << "Single thread, " << format(howmany) << " iterations" << endl;
cout << "*******************************************************************************\n";
auto rotating_st = spdlog::rotating_logger_st("rotating_st", "logs/rotating_st", file_size, rotating_files);
bench(howmany, rotating_st);
auto daily_st = spdlog::daily_logger_st("daily_st", "logs/daily_st");
bench(howmany, daily_st);
bench(howmany, spdlog::create<null_sink_st>("null_st"));
cout << "\n*******************************************************************************\n";
cout << threads << " threads sharing same logger, " << format(howmany) << " iterations" << endl;
cout << "*******************************************************************************\n";
auto rotating_mt = spdlog::rotating_logger_mt("rotating_mt", "logs/rotating_mt", file_size, rotating_files);
bench_mt(howmany, rotating_mt, threads);
auto daily_mt = spdlog::daily_logger_mt("daily_mt", "logs/daily_mt");
bench_mt(howmany, daily_mt, threads);
bench(howmany, spdlog::create<null_sink_st>("null_mt"));
cout << "\n*******************************************************************************\n";
cout << "async logging.. " << threads << " threads sharing same logger, " << format(howmany) << " iterations " << endl;
cout << "*******************************************************************************\n";
spdlog::set_async_mode(queue_size);
for(int i = 0; i < 3; ++i)
{
auto as = spdlog::daily_logger_st("as", "logs/daily_async");
bench_mt(howmany, as, threads);
spdlog::drop("as");
}
}
catch (std::exception &ex)
{
std::cerr << "Error: " << ex.what() << std::endl;
perror("Last error");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
void bench(int howmany, std::shared_ptr<spdlog::logger> log)
{
cout << log->name() << "...\t\t" << flush;
auto start = system_clock::now();
for (auto i = 0; i < howmany; ++i)
{
log->info("Hello logger: msg number {}", i);
}
auto delta = system_clock::now() - start;
auto delta_d = duration_cast<duration<double>> (delta).count();
cout << format(int(howmany / delta_d)) << "/sec" << endl;
}
void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count)
{
cout << log->name() << "...\t\t" << flush;
std::atomic<int > msg_counter {0};
vector<thread> threads;
auto start = system_clock::now();
for (int t = 0; t < thread_count; ++t)
{
threads.push_back(std::thread([&]()
{
for(;;)
{
int counter = ++msg_counter;
if (counter > howmany) break;
log->info("Hello logger: msg number {}", counter);
}
}));
}
for(auto &t:threads)
{
t.join();
};
auto delta = system_clock::now() - start;
auto delta_d = duration_cast<duration<double>> (delta).count();
cout << format(int(howmany / delta_d)) << "/sec" << endl;
}

View File

@ -1,167 +1,403 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
//
// spdlog usage example
//
//
#define SPDLOG_TRACE_ON
#define SPDLOG_DEBUG_ON
#include "spdlog/spdlog.h"
#include <iostream>
#include <memory>
#include <cstdio>
#include <chrono>
void load_levels_example();
void stdout_logger_example();
void basic_example();
void rotating_example();
void daily_example();
void callback_example();
void async_example();
void syslog_example();
void android_example();
void binary_example();
void vector_example();
void stopwatch_example();
void trace_example();
void multi_sink_example();
void user_defined_example();
void err_handler_example();
void syslog_example();
void udp_example();
void custom_flags_example();
void file_events_example();
void replace_default_logger_example();
void mdc_example();
namespace spd = spdlog;
int main(int, char*[])
{
try
{
// Console logger with color
auto console = spd::stdout_color_mt("console");
console->info("Welcome to spdlog!");
console->error("Some error message with arg{}..", 1);
#include "spdlog/spdlog.h"
#include "spdlog/cfg/env.h" // support for loading levels from the environment variable
#include "spdlog/fmt/ostr.h" // support for user defined types
int main(int, char *[]) {
// Log levels can be loaded from argv/env using "SPDLOG_LEVEL"
load_levels_example();
// Formatting examples
console->warn("Easy padding in numbers like {:08d}", 12);
console->critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
console->info("Support for floats {:03.2f}", 1.23456);
console->info("Positional args are {1} {0}..", "too", "supported");
console->info("{:<30}", "left aligned");
spd::get("console")->info("loggers can be retrieved from a global registry using the spdlog::get(logger_name) function");
// Create basic file logger (not rotated)
auto my_logger = spd::basic_logger_mt("basic_logger", "logs/basic-log.txt");
my_logger->info("Some log message");
// Create a file rotating logger with 5mb size max and 3 rotated files
auto rotating_logger = spd::rotating_logger_mt("some_logger_name", "logs/rotating.txt", 1048576 * 5, 3);
for (int i = 0; i < 10; ++i)
rotating_logger->info("{} * {} equals {:>10}", i, i, i*i);
// Create a daily logger - a new file is created every day on 2:30am
auto daily_logger = spd::daily_logger_mt("daily_logger", "logs/daily.txt", 2, 30);
// trigger flush if the log severity is error or higher
daily_logger->flush_on(spd::level::err);
daily_logger->info(123.44);
// Customize msg format for all messages
spd::set_pattern("*** [%H:%M:%S %z] [thread %t] %v ***");
rotating_logger->info("This is another message with custom format");
spdlog::info("Welcome to spdlog version {}.{}.{} !", SPDLOG_VER_MAJOR, SPDLOG_VER_MINOR,
SPDLOG_VER_PATCH);
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("{:>8} aligned, {:<8} aligned", "right", "left");
// Runtime log levels
spd::set_level(spd::level::info); //Set global log level to info
console->debug("This message shold not be displayed!");
console->set_level(spd::level::debug); // Set specific logger's log level
console->debug("This message shold be displayed..");
spdlog::set_level(spdlog::level::info); // Set global log level to info
spdlog::debug("This message should not be displayed!");
spdlog::set_level(spdlog::level::trace); // Set specific logger's log level
spdlog::debug("This message should be displayed..");
// Compile time log levels
// define SPDLOG_DEBUG_ON or SPDLOG_TRACE_ON
SPDLOG_TRACE(console, "Enabled only #ifdef SPDLOG_TRACE_ON..{} ,{}", 1, 3.23);
SPDLOG_DEBUG(console, "Enabled only #ifdef SPDLOG_DEBUG_ON.. {} ,{}", 1, 3.23);
// Customize msg format for all loggers
spdlog::set_pattern("[%H:%M:%S %z] [%^%L%$] [thread %t] %v");
spdlog::info("This an info message with custom format");
spdlog::set_pattern("%+"); // back to default format
spdlog::set_level(spdlog::level::info);
// Asynchronous logging is very fast..
// Just call spdlog::set_async_mode(q_size) and all created loggers from now on will be asynchronous..
async_example();
// syslog example. linux/osx only
syslog_example();
// android example. compile with NDK
android_example();
// Log user-defined types example
user_defined_example();
// Change default log error handler
err_handler_example();
// Apply a function on all registered loggers
spd::apply_all([&](std::shared_ptr<spdlog::logger> l)
{
l->info("End of example.");
});
// Release and close all loggers
spdlog::drop_all();
// Backtrace support
// Loggers can store in a ring buffer all messages (including debug/trace) for later inspection.
// When needed, call dump_backtrace() to see what happened:
spdlog::enable_backtrace(10); // create ring buffer with capacity of 10 messages
for (int i = 0; i < 100; i++) {
spdlog::debug("Backtrace message {}", i); // not logged..
}
// Exceptions will only be thrown upon failed logger or sink construction (not during logging)
catch (const spd::spdlog_ex& ex)
{
std::cout << "Log init failed: " << ex.what() << std::endl;
// e.g. if some error happened:
spdlog::dump_backtrace(); // log them now!
try {
stdout_logger_example();
basic_example();
rotating_example();
daily_example();
callback_example();
async_example();
binary_example();
vector_example();
multi_sink_example();
user_defined_example();
err_handler_example();
trace_example();
stopwatch_example();
udp_example();
custom_flags_example();
file_events_example();
replace_default_logger_example();
mdc_example();
// Flush all *registered* loggers using a worker thread every 3 seconds.
// note: registered loggers *must* be thread safe for this to work correctly!
spdlog::flush_every(std::chrono::seconds(3));
// Apply some function on all registered loggers
spdlog::apply_all([&](std::shared_ptr<spdlog::logger> l) { l->info("End of example."); });
// Release all spdlog resources, and drop all loggers in the registry.
// This is optional (only mandatory if using windows + async log).
spdlog::shutdown();
}
// Exceptions will only be thrown upon failed logger or sink construction (not during logging).
catch (const spdlog::spdlog_ex &ex) {
std::printf("Log initialization failed: %s\n", ex.what());
return 1;
}
}
void async_example()
{
size_t q_size = 4096; //queue size must be power of 2
spdlog::set_async_mode(q_size);
auto async_file = spd::daily_logger_st("async_file_logger", "logs/async_log.txt");
for (int i = 0; i < 100; ++i)
#include "spdlog/sinks/stdout_color_sinks.h"
// or #include "spdlog/sinks/stdout_sinks.h" if no colors needed.
void stdout_logger_example() {
// Create color multi threaded logger.
auto console = spdlog::stdout_color_mt("console");
// or for stderr:
// auto console = spdlog::stderr_color_mt("error-logger");
}
#include "spdlog/sinks/basic_file_sink.h"
void basic_example() {
// Create basic file logger (not rotated).
auto my_logger = spdlog::basic_logger_mt("file_logger", "logs/basic-log.txt", true);
}
#include "spdlog/sinks/rotating_file_sink.h"
void rotating_example() {
// Create a file rotating logger with 5mb size max and 3 rotated files.
auto rotating_logger =
spdlog::rotating_logger_mt("some_logger_name", "logs/rotating.txt", 1048576 * 5, 3);
}
#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 daily_logger = spdlog::daily_logger_mt("daily_logger", "logs/daily.txt", 2, 30);
}
#include "spdlog/sinks/callback_sink.h"
void callback_example() {
// Create the logger
auto logger = spdlog::callback_logger_mt("custom_callback_logger",
[](const spdlog::details::log_msg & /*msg*/) {
// do what you need to do with msg
});
}
#include "spdlog/cfg/env.h"
void load_levels_example() {
// Set the log level to "info" and mylogger to "trace":
// SPDLOG_LEVEL=info,mylogger=trace && ./example
spdlog::cfg::load_env_levels();
// or specify the env variable name:
// MYAPP_LEVEL=info,mylogger=trace && ./example
// spdlog::cfg::load_env_levels("MYAPP_LEVEL");
// 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(args, argv);
}
#include "spdlog/async.h"
void async_example() {
// Default thread pool settings can be modified *before* creating the async logger:
// spdlog::init_thread_pool(32768, 1); // queue with max 32k items 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");
for (int i = 1; i < 101; ++i) {
async_file->info("Async message #{}", i);
}
//syslog example (linux/osx/freebsd)
void syslog_example()
{
#ifdef SPDLOG_ENABLE_SYSLOG
std::string ident = "spdlog-example";
auto syslog_logger = spd::syslog_logger("syslog", ident, LOG_PID);
syslog_logger->warn("This is warning that will end up in syslog.");
#endif
}
// Android example
void android_example()
{
#if defined(__ANDROID__)
std::string tag = "spdlog-android";
auto android_logger = spd::android_logger("android", tag);
android_logger->critical("Use \"adb shell logcat\" to view this message.");
// Log binary data as hex.
// Many types of std::container<char> types can be used.
// Iterator 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.
#if !defined SPDLOG_USE_STD_FORMAT || defined(_MSC_VER)
#include "spdlog/fmt/bin_to_hex.h"
void binary_example() {
std::vector<char> buf;
for (int i = 0; i < 80; i++) {
buf.push_back(static_cast<char>(i & 0xff));
}
spdlog::info("Binary example: {}", spdlog::to_hex(buf));
spdlog::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->info("hexdump style: {:a}", spdlog::to_hex(buf));
// logger->info("hexdump style, 20 chars per line {:a}", spdlog::to_hex(buf, 20));
}
#else
void binary_example() {
// not supported with std::format yet
}
#endif
// Log a vector of numbers
#ifndef SPDLOG_USE_STD_FORMAT
#include "spdlog/fmt/ranges.h"
void vector_example() {
std::vector<int> vec = {1, 2, 3};
spdlog::info("Vector example: {}", vec);
}
// user defined types logging by implementing operator<<
struct my_type
{
int i;
template<typename OStream>
friend OStream& operator<<(OStream& os, const my_type &c)
{
return os << "[my_type i="<<c.i << "]";
#else
void vector_example() {}
#endif
// ! DSPDLOG_USE_STD_FORMAT
// Compile time log levels.
// define SPDLOG_ACTIVE_LEVEL to required level (e.g. SPDLOG_LEVEL_TRACE)
void trace_example() {
// trace from default logger
SPDLOG_TRACE("Some trace message.. {} ,{}", 1, 3.23);
// debug from default logger
SPDLOG_DEBUG("Some debug message.. {} ,{}", 1, 3.23);
// trace from logger object
auto logger = spdlog::get("file_logger");
SPDLOG_LOGGER_TRACE(logger, "another trace message");
}
// stopwatch example
#include "spdlog/stopwatch.h"
#include <thread>
void stopwatch_example() {
spdlog::stopwatch sw;
std::this_thread::sleep_for(std::chrono::milliseconds(123));
spdlog::info("Stopwatch: {} seconds", sw);
}
#include "spdlog/sinks/udp_sink.h"
void udp_example() {
spdlog::sinks::udp_sink_config cfg("127.0.0.1", 11091);
auto my_logger = spdlog::udp_logger_mt("udplog", cfg);
my_logger->set_level(spdlog::level::debug);
my_logger->info("hello world");
}
// A logger with multiple sinks (stdout and file) - each with a different format and log level.
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");
}
// User defined types logging
struct my_type {
int i = 0;
explicit my_type(int i)
: i(i){}
};
#ifndef SPDLOG_USE_STD_FORMAT // when using fmtlib
template <>
struct fmt::formatter<my_type> : fmt::formatter<std::string> {
auto format(my_type my, format_context &ctx) const -> decltype(ctx.out()) {
return fmt::format_to(ctx.out(), "[my_type i={}]", my.i);
}
};
#include "spdlog/fmt/ostr.h" // must be included
void user_defined_example()
{
spd::get("console")->info("user defined type: {}", my_type { 14 });
#else // when using std::format
template <>
struct std::formatter<my_type> : std::formatter<std::string> {
auto format(my_type my, format_context &ctx) const -> decltype(ctx.out()) {
return std::format_to(ctx.out(), "[my_type i={}]", my.i);
}
};
#endif
void user_defined_example() { spdlog::info("user defined type: {}", my_type(14)); }
// Custom error handler. Will be triggered on log failure.
void err_handler_example() {
// can be set globally or per logger(logger->set_error_handler(..))
spdlog::set_error_handler([](const std::string &msg) {
printf("*** Custom log error handler: %s ***\n", msg.c_str());
});
}
//
//custom error handler
//
void err_handler_example()
{
//can be set globaly or per logger(logger->set_error_handler(..))
spdlog::set_error_handler([](const std::string& msg)
{
std::cerr << "my err handler: " << msg << std::endl;
});
spd::get("console")->info("some invalid message to trigger an error {}{}{}{}", 3);
// syslog example (linux/osx/freebsd)
#ifndef _WIN32
#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.");
}
#endif
// Android example.
#if defined(__ANDROID__)
#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.");
}
#endif
// Log patterns can contain custom flags.
// this will add custom 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() {
using spdlog::details::make_unique; // for pre c++14
auto formatter = make_unique<spdlog::pattern_formatter>();
formatter->add_flag<my_formatter_flag>('*').set_pattern("[%n] [%*] [%^%l%$] %v");
// set the new formatter using spdlog::set_formatter(formatter) or
// logger->set_formatter(formatter) spdlog::set_formatter(std::move(formatter));
}
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) {
spdlog::info("After opening {}", filename);
fputs("After opening\n", fstream);
};
handlers.before_close = [](spdlog::filename_t filename, std::FILE *fstream) {
spdlog::info("Before closing {}", filename);
fputs("Before closing\n", fstream);
};
handlers.after_close = [](spdlog::filename_t filename) {
spdlog::info("After closing {}", filename);
};
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>("logs/events-sample.txt",
true, handlers);
spdlog::logger my_logger("some_logger", file_sink);
my_logger.info("Some log line");
}
void replace_default_logger_example() {
// store the old logger so we don't break other examples.
auto old_logger = spdlog::default_logger();
auto new_logger =
spdlog::basic_logger_mt("new_default_logger", "logs/new-default-log.txt", true);
spdlog::set_default_logger(new_logger);
spdlog::set_level(spdlog::level::info);
spdlog::debug("This message should not be displayed!");
spdlog::set_level(spdlog::level::trace);
spdlog::debug("This message should be displayed..");
spdlog::set_default_logger(old_logger);
}
// Mapped Diagnostic Context (MDC) is a map that stores key-value pairs (string values) in thread local storage.
// Each thread maintains its own MDC, which loggers use to append diagnostic information to log outputs.
// Note: it is not supported in asynchronous mode due to its reliance on thread-local storage.
#ifndef SPDLOG_NO_TLS
#include "spdlog/mdc.h"
void mdc_example()
{
spdlog::mdc::put("key1", "value1");
spdlog::mdc::put("key2", "value2");
// if not using the default format, you can use the %& formatter to print mdc data as well
spdlog::set_pattern("[%H:%M:%S %z] [%^%L%$] [%&] %v");
spdlog::info("Some log message with context");
}
#else
void mdc_example() {
// if TLS feature is disabled
}
#endif

View File

@ -1,26 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "example.vcxproj", "{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Debug|Win32.ActiveCfg = Debug|Win32
{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Debug|Win32.Build.0 = Debug|Win32
{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Debug|x64.ActiveCfg = Debug|Win32
{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Release|Win32.ActiveCfg = Release|Win32
{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Release|Win32.Build.0 = Release|Win32
{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -1,126 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="example.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\spdlog\async_logger.h" />
<ClInclude Include="..\include\spdlog\common.h" />
<ClInclude Include="..\include\spdlog\details\async_logger_impl.h" />
<ClInclude Include="..\include\spdlog\details\async_log_helper.h" />
<ClInclude Include="..\include\spdlog\details\file_helper.h" />
<ClInclude Include="..\include\spdlog\details\logger_impl.h" />
<ClInclude Include="..\include\spdlog\details\log_msg.h" />
<ClInclude Include="..\include\spdlog\details\mpmc_bounded_q.h" />
<ClInclude Include="..\include\spdlog\details\null_mutex.h" />
<ClInclude Include="..\include\spdlog\details\os.h" />
<ClInclude Include="..\include\spdlog\details\pattern_formatter_impl.h" />
<ClInclude Include="..\include\spdlog\details\registry.h" />
<ClInclude Include="..\include\spdlog\details\spdlog_impl.h" />
<ClInclude Include="..\include\spdlog\fmt\fmt.h" />
<ClInclude Include="..\include\spdlog\fmt\ostr.h" />
<ClInclude Include="..\include\spdlog\formatter.h" />
<ClInclude Include="..\include\spdlog\logger.h" />
<ClInclude Include="..\include\spdlog\sinks\android_sink.h" />
<ClInclude Include="..\include\spdlog\sinks\ansicolor_sink.h" />
<ClInclude Include="..\include\spdlog\sinks\base_sink.h" />
<ClInclude Include="..\include\spdlog\sinks\dist_sink.h" />
<ClInclude Include="..\include\spdlog\sinks\file_sinks.h" />
<ClInclude Include="..\include\spdlog\sinks\msvc_sink.h" />
<ClInclude Include="..\include\spdlog\sinks\null_sink.h" />
<ClInclude Include="..\include\spdlog\sinks\ostream_sink.h" />
<ClInclude Include="..\include\spdlog\sinks\sink.h" />
<ClInclude Include="..\include\spdlog\sinks\stdout_sinks.h" />
<ClInclude Include="..\include\spdlog\sinks\syslog_sink.h" />
<ClInclude Include="..\include\spdlog\sinks\wincolor_sink.h" />
<ClInclude Include="..\include\spdlog\spdlog.h" />
<ClInclude Include="..\include\spdlog\tweakme.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>.</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeaderFile />
<PrecompiledHeaderOutputFile />
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeaderFile />
<PrecompiledHeaderOutputFile />
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,15 +0,0 @@
# Setup a project
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := example
LOCAL_SRC_FILES := example.cpp
LOCAL_CPPFLAGS += -Wall -Wshadow -Wextra -pedantic -std=c++11 -fPIE -pie
LOCAL_LDFLAGS += -fPIE -pie
# Add exception support and set path for spdlog's headers
LOCAL_CPPFLAGS += -fexceptions -I../include
# Use android's log library
LOCAL_LDFLAGS += -llog
include $(BUILD_EXECUTABLE)

View File

@ -1,2 +0,0 @@
# Exceptions are used in spdlog. Link to an exception-ready C++ runtime.
APP_STL = gnustl_static

View File

@ -1 +0,0 @@
../example.cpp

View File

@ -1 +0,0 @@
*.txt

View File

@ -1,47 +0,0 @@
#include "spdlog/spdlog.h"
#include <iostream>
#include <memory>
namespace spd = spdlog;
int main(int, char*[])
{
bool enable_debug = true;
try
{
// This other example use a single logger with multiple sinks.
// This means that the same log_msg is forwarded to multiple sinks;
// Each sink can have it's own log level and a message will be logged.
std::vector<spdlog::sink_ptr> sinks;
sinks.push_back( std::make_shared<spdlog::sinks::stdout_sink_mt>() );
sinks.push_back( std::make_shared<spdlog::sinks::simple_file_sink_mt>("./log_regular_file.txt") );
sinks.push_back( std::make_shared<spdlog::sinks::simple_file_sink_mt>("./log_debug_file.txt") );
spdlog::logger console_multisink("multisink", sinks.begin(), sinks.end() );
console_multisink.set_level( spdlog::level::warn);
sinks[0]->set_level( spdlog::level::trace); // console. Allow everything. Default value
sinks[1]->set_level( spdlog::level::trace); // regular file. Allow everything. Default value
sinks[2]->set_level( spdlog::level::off); // regular file. Ignore everything.
console_multisink.warn("warn: will print only on console and regular file");
if( enable_debug )
{
console_multisink.set_level( spdlog::level::debug); // level of the logger
sinks[1]->set_level( spdlog::level::debug); // regular file
sinks[2]->set_level( spdlog::level::debug); // debug file
}
console_multisink.debug("Debug: you should see this on console and both files");
// Release and close all loggers
spdlog::drop_all();
}
// Exceptions will only be thrown upon failed logger or sink construction (not during logging)
catch (const spd::spdlog_ex& ex)
{
std::cout << "Log init failed: " << ex.what() << std::endl;
return 1;
}
}

View File

@ -1,35 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
#include <sstream>
#include <iomanip>
#include <locale>
namespace utils
{
template<typename T>
inline std::string format(const T& value)
{
static std::locale loc("");
std::stringstream ss;
ss.imbue(loc);
ss << value;
return ss.str();
}
template<>
inline std::string format(const double & value)
{
static std::locale loc("");
std::stringstream ss;
ss.imbue(loc);
ss << std::fixed << std::setprecision(1) << value;
return ss.str();
}
}

100
include/spdlog/async.h Normal file
View File

@ -0,0 +1,100 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
//
// Async logging using global thread pool
// All loggers created here share same global thread pool.
// Each log message is pushed to a queue along with a shared pointer to the
// logger.
// If a logger deleted while having pending messages in the queue, it's actual
// destruction will defer
// until all its messages are processed by the thread pool.
// This is because each message in the queue holds a shared_ptr to the
// originating logger.
#include <spdlog/async_logger.h>
#include <spdlog/details/registry.h>
#include <spdlog/details/thread_pool.h>
#include <functional>
#include <memory>
#include <mutex>
namespace spdlog {
namespace details {
static const size_t default_async_q_size = 8192;
}
// async logger factory - creates async loggers backed with thread pool.
// if a global thread pool doesn't already exist, create it with default queue
// size of 8192 items and single thread.
template <async_overflow_policy OverflowPolicy = async_overflow_policy::block>
struct async_factory_impl {
template <typename Sink, typename... SinkArgs>
static std::shared_ptr<async_logger> create(std::string logger_name, SinkArgs &&...args) {
auto &registry_inst = details::registry::instance();
// create global thread pool if not already exists..
auto &mutex = registry_inst.tp_mutex();
std::lock_guard<std::recursive_mutex> tp_lock(mutex);
auto tp = registry_inst.get_tp();
if (tp == nullptr) {
tp = std::make_shared<details::thread_pool>(details::default_async_q_size, 1U);
registry_inst.set_tp(tp);
}
auto sink = std::make_shared<Sink>(std::forward<SinkArgs>(args)...);
auto new_logger = std::make_shared<async_logger>(std::move(logger_name), std::move(sink),
std::move(tp), OverflowPolicy);
registry_inst.initialize_logger(new_logger);
return new_logger;
}
};
using async_factory = async_factory_impl<async_overflow_policy::block>;
using async_factory_nonblock = async_factory_impl<async_overflow_policy::overrun_oldest>;
template <typename Sink, typename... SinkArgs>
inline std::shared_ptr<spdlog::logger> create_async(std::string logger_name,
SinkArgs &&...sink_args) {
return async_factory::create<Sink>(std::move(logger_name),
std::forward<SinkArgs>(sink_args)...);
}
template <typename Sink, typename... SinkArgs>
inline std::shared_ptr<spdlog::logger> create_async_nb(std::string logger_name,
SinkArgs &&...sink_args) {
return async_factory_nonblock::create<Sink>(std::move(logger_name),
std::forward<SinkArgs>(sink_args)...);
}
// set global thread pool.
inline void init_thread_pool(size_t q_size,
size_t thread_count,
std::function<void()> on_thread_start,
std::function<void()> on_thread_stop) {
auto tp = std::make_shared<details::thread_pool>(q_size, thread_count, on_thread_start,
on_thread_stop);
details::registry::instance().set_tp(std::move(tp));
}
inline void init_thread_pool(size_t q_size,
size_t thread_count,
std::function<void()> on_thread_start) {
init_thread_pool(q_size, thread_count, on_thread_start, [] {});
}
inline void init_thread_pool(size_t q_size, size_t thread_count) {
init_thread_pool(
q_size, thread_count, [] {}, [] {});
}
// get the global thread pool.
inline std::shared_ptr<spdlog::details::thread_pool> thread_pool() {
return details::registry::instance().get_tp();
}
} // namespace spdlog

View File

@ -0,0 +1,84 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/async_logger.h>
#endif
#include <spdlog/details/thread_pool.h>
#include <spdlog/sinks/sink.h>
#include <memory>
#include <string>
SPDLOG_INLINE spdlog::async_logger::async_logger(std::string logger_name,
sinks_init_list sinks_list,
std::weak_ptr<details::thread_pool> tp,
async_overflow_policy overflow_policy)
: async_logger(std::move(logger_name),
sinks_list.begin(),
sinks_list.end(),
std::move(tp),
overflow_policy) {}
SPDLOG_INLINE spdlog::async_logger::async_logger(std::string logger_name,
sink_ptr single_sink,
std::weak_ptr<details::thread_pool> tp,
async_overflow_policy overflow_policy)
: async_logger(
std::move(logger_name), {std::move(single_sink)}, std::move(tp), overflow_policy) {}
// send the log message to the thread pool
SPDLOG_INLINE void spdlog::async_logger::sink_it_(const details::log_msg &msg){
SPDLOG_TRY{if (auto pool_ptr = thread_pool_.lock()){
pool_ptr->post_log(shared_from_this(), msg, overflow_policy_);
}
else {
throw_spdlog_ex("async log: thread pool doesn't exist anymore");
}
}
SPDLOG_LOGGER_CATCH(msg.source)
}
// send flush request to the thread pool
SPDLOG_INLINE void spdlog::async_logger::flush_(){
SPDLOG_TRY{if (auto pool_ptr = thread_pool_.lock()){
pool_ptr->post_flush(shared_from_this(), overflow_policy_);
}
else {
throw_spdlog_ex("async flush: thread pool doesn't exist anymore");
}
}
SPDLOG_LOGGER_CATCH(source_loc())
}
//
// backend functions - called from the thread pool to do the actual job
//
SPDLOG_INLINE void spdlog::async_logger::backend_sink_it_(const details::log_msg &msg) {
for (auto &sink : sinks_) {
if (sink->should_log(msg.level)) {
SPDLOG_TRY { sink->log(msg); }
SPDLOG_LOGGER_CATCH(msg.source)
}
}
if (should_flush_(msg)) {
backend_flush_();
}
}
SPDLOG_INLINE void spdlog::async_logger::backend_flush_() {
for (auto &sink : sinks_) {
SPDLOG_TRY { sink->flush(); }
SPDLOG_LOGGER_CATCH(source_loc())
}
}
SPDLOG_INLINE std::shared_ptr<spdlog::logger> spdlog::async_logger::clone(std::string new_name) {
auto cloned = std::make_shared<spdlog::async_logger>(*this);
cloned->name_ = std::move(new_name);
return cloned;
}

View File

@ -1,82 +1,74 @@
//
// Copyright(c) 2015 Gabi Melman.
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
// Very fast asynchronous logger (millions of logs per second on an average desktop)
// Uses pre allocated lockfree queue for maximum throughput even under large number of threads.
// Fast asynchronous logger.
// Uses pre allocated queue.
// Creates a single back thread to pop messages from the queue and log them.
//
// Upon each log write the logger:
// 1. Checks if its log level is enough to log the message
// 2. Push a new copy of the message to a queue (or block the caller until space is available in the queue)
// 3. will throw spdlog_ex upon log exceptions
// Upon destruction, logs all remaining messages in the queue before destructing..
// 2. Push a new copy of the message to a queue (or block the caller until
// space is available in the queue)
// Upon destruction, logs all remaining messages in the queue before
// destructing..
#include "common.h"
#include "logger.h"
#include <spdlog/logger.h>
#include <chrono>
#include <functional>
#include <string>
#include <memory>
namespace spdlog {
namespace spdlog
{
// Async overflow policy - block by default.
enum class async_overflow_policy {
block, // Block until message can be enqueued
overrun_oldest, // Discard oldest message in the queue if full when trying to
// add new item.
discard_new // Discard new message if the queue is full when trying to add new item.
};
namespace details
{
class async_log_helper;
namespace details {
class thread_pool;
}
class async_logger SPDLOG_FINAL :public logger
{
class SPDLOG_API async_logger final : public std::enable_shared_from_this<async_logger>,
public logger {
friend class details::thread_pool;
public:
template<class It>
async_logger(const std::string& name,
const It& begin,
const It& end,
size_t queue_size,
const async_overflow_policy overflow_policy = async_overflow_policy::block_retry,
const std::function<void()>& worker_warmup_cb = nullptr,
const std::chrono::milliseconds& flush_interval_ms = std::chrono::milliseconds::zero(),
const std::function<void()>& worker_teardown_cb = nullptr);
template <typename It>
async_logger(std::string logger_name,
It begin,
It end,
std::weak_ptr<details::thread_pool> tp,
async_overflow_policy overflow_policy = async_overflow_policy::block)
: logger(std::move(logger_name), begin, end),
thread_pool_(std::move(tp)),
overflow_policy_(overflow_policy) {}
async_logger(const std::string& logger_name,
sinks_init_list sinks,
size_t queue_size,
const async_overflow_policy overflow_policy = async_overflow_policy::block_retry,
const std::function<void()>& worker_warmup_cb = nullptr,
const std::chrono::milliseconds& flush_interval_ms = std::chrono::milliseconds::zero(),
const std::function<void()>& worker_teardown_cb = nullptr);
async_logger(std::string logger_name,
sinks_init_list sinks_list,
std::weak_ptr<details::thread_pool> tp,
async_overflow_policy overflow_policy = async_overflow_policy::block);
async_logger(const std::string& logger_name,
async_logger(std::string logger_name,
sink_ptr single_sink,
size_t queue_size,
const async_overflow_policy overflow_policy = async_overflow_policy::block_retry,
const std::function<void()>& worker_warmup_cb = nullptr,
const std::chrono::milliseconds& flush_interval_ms = std::chrono::milliseconds::zero(),
const std::function<void()>& worker_teardown_cb = nullptr);
std::weak_ptr<details::thread_pool> tp,
async_overflow_policy overflow_policy = async_overflow_policy::block);
//Wait for the queue to be empty, and flush synchronously
//Warning: this can potentially last forever as we wait it to complete
void flush() override;
// Error handler
virtual void set_error_handler(log_err_handler) override;
virtual log_err_handler error_handler() override;
std::shared_ptr<logger> clone(std::string new_name) override;
protected:
void _sink_it(details::log_msg& msg) override;
void _set_formatter(spdlog::formatter_ptr msg_formatter) override;
void _set_pattern(const std::string& pattern, pattern_time_type pattern_time) override;
void sink_it_(const details::log_msg &msg) override;
void flush_() override;
void backend_sink_it_(const details::log_msg &incoming_log_msg);
void backend_flush_();
private:
std::unique_ptr<details::async_log_helper> _async_log_helper;
std::weak_ptr<details::thread_pool> thread_pool_;
async_overflow_policy overflow_policy_;
};
}
} // namespace spdlog
#include "details/async_logger_impl.h"
#ifdef SPDLOG_HEADER_ONLY
#include "async_logger-inl.h"
#endif

40
include/spdlog/cfg/argv.h Normal file
View File

@ -0,0 +1,40 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#include <spdlog/cfg/helpers.h>
#include <spdlog/details/registry.h>
//
// Init log levels using each argv entry that starts with "SPDLOG_LEVEL="
//
// set all loggers to debug level:
// example.exe "SPDLOG_LEVEL=debug"
// set logger1 to trace level
// example.exe "SPDLOG_LEVEL=logger1=trace"
// turn off all logging except for logger1 and logger2:
// example.exe "SPDLOG_LEVEL=off,logger1=debug,logger2=info"
namespace spdlog {
namespace cfg {
// search for SPDLOG_LEVEL= in the args and use it to init the levels
inline void load_argv_levels(int argc, const char **argv) {
const std::string spdlog_level_prefix = "SPDLOG_LEVEL=";
for (int i = 1; i < argc; i++) {
std::string arg = argv[i];
if (arg.find(spdlog_level_prefix) == 0) {
auto levels_string = arg.substr(spdlog_level_prefix.size());
helpers::load_levels(levels_string);
}
}
}
inline void load_argv_levels(int argc, char **argv) {
load_argv_levels(argc, const_cast<const char **>(argv));
}
} // namespace cfg
} // namespace spdlog

36
include/spdlog/cfg/env.h Normal file
View File

@ -0,0 +1,36 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#include <spdlog/cfg/helpers.h>
#include <spdlog/details/os.h>
#include <spdlog/details/registry.h>
//
// Init levels and patterns from env variables SPDLOG_LEVEL
// Inspired from Rust's "env_logger" crate (https://crates.io/crates/env_logger).
// Note - fallback to "info" level on unrecognized levels
//
// Examples:
//
// set global level to debug:
// export SPDLOG_LEVEL=debug
//
// turn off all logging except for logger1:
// export SPDLOG_LEVEL="*=off,logger1=debug"
//
// turn off all logging except for logger1 and logger2:
// export SPDLOG_LEVEL="off,logger1=debug,logger2=info"
namespace spdlog {
namespace cfg {
inline void load_env_levels(const char* var = "SPDLOG_LEVEL") {
auto env_val = details::os::getenv(var);
if (!env_val.empty()) {
helpers::load_levels(env_val);
}
}
} // namespace cfg
} // namespace spdlog

View File

@ -0,0 +1,107 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/cfg/helpers.h>
#endif
#include <spdlog/details/os.h>
#include <spdlog/details/registry.h>
#include <spdlog/spdlog.h>
#include <algorithm>
#include <sstream>
#include <string>
#include <utility>
namespace spdlog {
namespace cfg {
namespace helpers {
// inplace convert to lowercase
inline std::string &to_lower_(std::string &str) {
std::transform(str.begin(), str.end(), str.begin(), [](char ch) {
return static_cast<char>((ch >= 'A' && ch <= 'Z') ? ch + ('a' - 'A') : ch);
});
return str;
}
// inplace trim spaces
inline std::string &trim_(std::string &str) {
const char *spaces = " \n\r\t";
str.erase(str.find_last_not_of(spaces) + 1);
str.erase(0, str.find_first_not_of(spaces));
return str;
}
// return (name,value) trimmed pair from given "name=value" string.
// return empty string on missing parts
// "key=val" => ("key", "val")
// " key = val " => ("key", "val")
// "key=" => ("key", "")
// "val" => ("", "val")
inline std::pair<std::string, std::string> extract_kv_(char sep, const std::string &str) {
auto n = str.find(sep);
std::string k, v;
if (n == std::string::npos) {
v = str;
} else {
k = str.substr(0, n);
v = str.substr(n + 1);
}
return std::make_pair(trim_(k), trim_(v));
}
// return vector of key/value pairs from sequence of "K1=V1,K2=V2,.."
// "a=AAA,b=BBB,c=CCC,.." => {("a","AAA"),("b","BBB"),("c", "CCC"),...}
inline std::unordered_map<std::string, std::string> extract_key_vals_(const std::string &str) {
std::string token;
std::istringstream token_stream(str);
std::unordered_map<std::string, std::string> rv{};
while (std::getline(token_stream, token, ',')) {
if (token.empty()) {
continue;
}
auto kv = extract_kv_('=', token);
rv[kv.first] = kv.second;
}
return rv;
}
SPDLOG_INLINE void load_levels(const std::string &input) {
if (input.empty() || input.size() > 512) {
return;
}
auto key_vals = extract_key_vals_(input);
std::unordered_map<std::string, level::level_enum> levels;
level::level_enum global_level = level::info;
bool global_level_found = false;
for (auto &name_level : key_vals) {
auto &logger_name = name_level.first;
auto level_name = to_lower_(name_level.second);
auto level = level::from_str(level_name);
// ignore unrecognized level names
if (level == level::off && level_name != "off") {
continue;
}
if (logger_name.empty()) // no logger name indicate global level
{
global_level_found = true;
global_level = level;
} else {
levels[logger_name] = level;
}
}
details::registry::instance().set_levels(std::move(levels),
global_level_found ? &global_level : nullptr);
}
} // namespace helpers
} // namespace cfg
} // namespace spdlog

View File

@ -0,0 +1,29 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#include <spdlog/common.h>
#include <unordered_map>
namespace spdlog {
namespace cfg {
namespace helpers {
//
// Init levels from given string
//
// Examples:
//
// set global level to debug: "debug"
// turn off all logging except for logger1: "off,logger1=debug"
// turn off all logging except for logger1 and logger2: "off,logger1=debug,logger2=info"
//
SPDLOG_API void load_levels(const std::string &txt);
} // namespace helpers
} // namespace cfg
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "helpers-inl.h"
#endif // SPDLOG_HEADER_ONLY

View File

@ -0,0 +1,68 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/common.h>
#endif
#include <algorithm>
#include <iterator>
namespace spdlog {
namespace level {
#if __cplusplus >= 201703L
constexpr
#endif
static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES;
static const char *short_level_names[] SPDLOG_SHORT_LEVEL_NAMES;
SPDLOG_INLINE const string_view_t &to_string_view(spdlog::level::level_enum l) SPDLOG_NOEXCEPT {
return level_string_views[l];
}
SPDLOG_INLINE const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT {
return short_level_names[l];
}
SPDLOG_INLINE spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT {
auto it = std::find(std::begin(level_string_views), std::end(level_string_views), name);
if (it != std::end(level_string_views))
return static_cast<level::level_enum>(std::distance(std::begin(level_string_views), it));
// check also for "warn" and "err" before giving up..
if (name == "warn") {
return level::warn;
}
if (name == "err") {
return level::err;
}
return level::off;
}
} // namespace level
SPDLOG_INLINE spdlog_ex::spdlog_ex(std::string msg)
: msg_(std::move(msg)) {}
SPDLOG_INLINE spdlog_ex::spdlog_ex(const std::string &msg, int last_errno) {
#ifdef SPDLOG_USE_STD_FORMAT
msg_ = std::system_error(std::error_code(last_errno, std::generic_category()), msg).what();
#else
memory_buf_t outbuf;
fmt::format_system_error(outbuf, last_errno, msg.c_str());
msg_ = fmt::to_string(outbuf);
#endif
}
SPDLOG_INLINE const char *spdlog_ex::what() const SPDLOG_NOEXCEPT { return msg_.c_str(); }
SPDLOG_INLINE void throw_spdlog_ex(const std::string &msg, int last_errno) {
SPDLOG_THROW(spdlog_ex(msg, last_errno));
}
SPDLOG_INLINE void throw_spdlog_ex(std::string msg) { SPDLOG_THROW(spdlog_ex(std::move(msg))); }
} // namespace spdlog

View File

@ -1,39 +1,88 @@
//
// Copyright(c) 2015 Gabi Melman.
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
#include <string>
#include <initializer_list>
#include <chrono>
#include <memory>
#include <spdlog/details/null_mutex.h>
#include <spdlog/tweakme.h>
#include <atomic>
#include <chrono>
#include <cstdio>
#include <exception>
#include <functional>
#include <initializer_list>
#include <memory>
#include <string>
#include <type_traits>
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
#include <codecvt>
#include <locale>
#ifdef SPDLOG_USE_STD_FORMAT
#include <version>
#if __cpp_lib_format >= 202207L
#include <format>
#else
#include <string_view>
#endif
#endif
#include "details/null_mutex.h"
#ifdef SPDLOG_COMPILED_LIB
#undef SPDLOG_HEADER_ONLY
#if defined(SPDLOG_SHARED_LIB)
#if defined(_WIN32)
#ifdef spdlog_EXPORTS
#define SPDLOG_API __declspec(dllexport)
#else // !spdlog_EXPORTS
#define SPDLOG_API __declspec(dllimport)
#endif
#else // !defined(_WIN32)
#define SPDLOG_API __attribute__((visibility("default")))
#endif
#else // !defined(SPDLOG_SHARED_LIB)
#define SPDLOG_API
#endif
#define SPDLOG_INLINE
#else // !defined(SPDLOG_COMPILED_LIB)
#define SPDLOG_API
#define SPDLOG_HEADER_ONLY
#define SPDLOG_INLINE inline
#endif // #ifdef SPDLOG_COMPILED_LIB
#include <spdlog/fmt/fmt.h>
#if !defined(SPDLOG_USE_STD_FORMAT) && \
FMT_VERSION >= 80000 // backward compatibility with fmt versions older than 8
#define SPDLOG_FMT_RUNTIME(format_string) fmt::runtime(format_string)
#define SPDLOG_FMT_STRING(format_string) FMT_STRING(format_string)
#if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
#include <spdlog/fmt/xchar.h>
#endif
#else
#define SPDLOG_FMT_RUNTIME(format_string) format_string
#define SPDLOG_FMT_STRING(format_string) format_string
#endif
// visual studio up to 2013 does not support noexcept nor constexpr
#if defined(_MSC_VER) && (_MSC_VER < 1900)
#define SPDLOG_NOEXCEPT throw()
#define SPDLOG_NOEXCEPT _NOEXCEPT
#define SPDLOG_CONSTEXPR
#else
#define SPDLOG_NOEXCEPT noexcept
#define SPDLOG_CONSTEXPR constexpr
#endif
// final keyword support. On by default. See tweakme.h
#if defined(SPDLOG_NO_FINAL)
#define SPDLOG_FINAL
// If building with std::format, can just use constexpr, otherwise if building with fmt
// SPDLOG_CONSTEXPR_FUNC needs to be set the same as FMT_CONSTEXPR to avoid situations where
// a constexpr function in spdlog could end up calling a non-constexpr function in fmt
// depending on the compiler
// If fmt determines it can't use constexpr, we should inline the function instead
#ifdef SPDLOG_USE_STD_FORMAT
#define SPDLOG_CONSTEXPR_FUNC constexpr
#else // Being built with fmt
#if FMT_USE_CONSTEXPR
#define SPDLOG_CONSTEXPR_FUNC FMT_CONSTEXPR
#else
#define SPDLOG_FINAL final
#define SPDLOG_CONSTEXPR_FUNC inline
#endif
#endif
#if defined(__GNUC__) || defined(__clang__)
@ -44,78 +93,205 @@
#define SPDLOG_DEPRECATED
#endif
#include "fmt/fmt.h"
// disable thread local on msvc 2013
#ifndef SPDLOG_NO_TLS
#if (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__cplusplus_winrt)
#define SPDLOG_NO_TLS 1
#endif
#endif
namespace spdlog
{
#ifndef SPDLOG_FUNCTION
#define SPDLOG_FUNCTION static_cast<const char *>(__FUNCTION__)
#endif
#ifdef SPDLOG_NO_EXCEPTIONS
#define SPDLOG_TRY
#define SPDLOG_THROW(ex) \
do { \
printf("spdlog fatal error: %s\n", ex.what()); \
std::abort(); \
} while (0)
#define SPDLOG_CATCH_STD
#else
#define SPDLOG_TRY try
#define SPDLOG_THROW(ex) throw(ex)
#define SPDLOG_CATCH_STD \
catch (const std::exception &) { \
}
#endif
namespace spdlog {
class formatter;
namespace sinks
{
namespace sinks {
class sink;
}
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
using filename_t = std::wstring;
// allow macro expansion to occur in SPDLOG_FILENAME_T
#define SPDLOG_FILENAME_T_INNER(s) L##s
#define SPDLOG_FILENAME_T(s) SPDLOG_FILENAME_T_INNER(s)
#else
using filename_t = std::string;
#define SPDLOG_FILENAME_T(s) s
#endif
using log_clock = std::chrono::system_clock;
using sink_ptr = std::shared_ptr<sinks::sink>;
using sinks_init_list = std::initializer_list<sink_ptr>;
using formatter_ptr = std::shared_ptr<spdlog::formatter>;
using err_handler = std::function<void(const std::string &err_msg)>;
#ifdef SPDLOG_USE_STD_FORMAT
namespace fmt_lib = std;
using string_view_t = std::string_view;
using memory_buf_t = std::string;
template <typename... Args>
#if __cpp_lib_format >= 202207L
using format_string_t = std::format_string<Args...>;
#else
using format_string_t = std::string_view;
#endif
template <class T, class Char = char>
struct is_convertible_to_basic_format_string
: std::integral_constant<bool, std::is_convertible<T, std::basic_string_view<Char>>::value> {};
#if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
using wstring_view_t = std::wstring_view;
using wmemory_buf_t = std::wstring;
template <typename... Args>
#if __cpp_lib_format >= 202207L
using wformat_string_t = std::wformat_string<Args...>;
#else
using wformat_string_t = std::wstring_view;
#endif
#endif
#define SPDLOG_BUF_TO_STRING(x) x
#else // use fmt lib instead of std::format
namespace fmt_lib = fmt;
using string_view_t = fmt::basic_string_view<char>;
using memory_buf_t = fmt::basic_memory_buffer<char, 250>;
template <typename... Args>
using format_string_t = fmt::format_string<Args...>;
template <class T>
using remove_cvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
template <typename Char>
#if FMT_VERSION >= 90101
using fmt_runtime_string = fmt::runtime_format_string<Char>;
#else
using fmt_runtime_string = fmt::basic_runtime<Char>;
#endif
// clang doesn't like SFINAE disabled constructor in std::is_convertible<> so have to repeat the
// condition from basic_format_string here, in addition, fmt::basic_runtime<Char> is only
// convertible to basic_format_string<Char> but not basic_string_view<Char>
template <class T, class Char = char>
struct is_convertible_to_basic_format_string
: std::integral_constant<bool,
std::is_convertible<T, fmt::basic_string_view<Char>>::value ||
std::is_same<remove_cvref_t<T>, fmt_runtime_string<Char>>::value> {
};
#if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
using wstring_view_t = fmt::basic_string_view<wchar_t>;
using wmemory_buf_t = fmt::basic_memory_buffer<wchar_t, 250>;
template <typename... Args>
using wformat_string_t = fmt::wformat_string<Args...>;
#endif
#define SPDLOG_BUF_TO_STRING(x) fmt::to_string(x)
#endif
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
#ifndef _WIN32
#error SPDLOG_WCHAR_TO_UTF8_SUPPORT only supported on windows
#endif // _WIN32
#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT
template <class T>
struct is_convertible_to_any_format_string
: std::integral_constant<bool,
is_convertible_to_basic_format_string<T, char>::value ||
is_convertible_to_basic_format_string<T, wchar_t>::value> {};
#if defined(SPDLOG_NO_ATOMIC_LEVELS)
using level_t = details::null_atomic_int;
#else
using level_t = std::atomic<int>;
#endif
using log_err_handler = std::function<void(const std::string &err_msg)>;
#define SPDLOG_LEVEL_TRACE 0
#define SPDLOG_LEVEL_DEBUG 1
#define SPDLOG_LEVEL_INFO 2
#define SPDLOG_LEVEL_WARN 3
#define SPDLOG_LEVEL_ERROR 4
#define SPDLOG_LEVEL_CRITICAL 5
#define SPDLOG_LEVEL_OFF 6
#if !defined(SPDLOG_ACTIVE_LEVEL)
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
#endif
// Log level enum
namespace level
{
typedef enum
{
trace = 0,
debug = 1,
info = 2,
warn = 3,
err = 4,
critical = 5,
off = 6
} level_enum;
namespace level {
enum level_enum : int {
trace = SPDLOG_LEVEL_TRACE,
debug = SPDLOG_LEVEL_DEBUG,
info = SPDLOG_LEVEL_INFO,
warn = SPDLOG_LEVEL_WARN,
err = SPDLOG_LEVEL_ERROR,
critical = SPDLOG_LEVEL_CRITICAL,
off = SPDLOG_LEVEL_OFF,
n_levels
};
#define SPDLOG_LEVEL_NAME_TRACE spdlog::string_view_t("trace", 5)
#define SPDLOG_LEVEL_NAME_DEBUG spdlog::string_view_t("debug", 5)
#define SPDLOG_LEVEL_NAME_INFO spdlog::string_view_t("info", 4)
#define SPDLOG_LEVEL_NAME_WARNING spdlog::string_view_t("warning", 7)
#define SPDLOG_LEVEL_NAME_ERROR spdlog::string_view_t("error", 5)
#define SPDLOG_LEVEL_NAME_CRITICAL spdlog::string_view_t("critical", 8)
#define SPDLOG_LEVEL_NAME_OFF spdlog::string_view_t("off", 3)
#if !defined(SPDLOG_LEVEL_NAMES)
#define SPDLOG_LEVEL_NAMES { "trace", "debug", "info", "warning", "error", "critical", "off" }
#define SPDLOG_LEVEL_NAMES \
{ \
SPDLOG_LEVEL_NAME_TRACE, SPDLOG_LEVEL_NAME_DEBUG, SPDLOG_LEVEL_NAME_INFO, \
SPDLOG_LEVEL_NAME_WARNING, SPDLOG_LEVEL_NAME_ERROR, SPDLOG_LEVEL_NAME_CRITICAL, \
SPDLOG_LEVEL_NAME_OFF \
}
#endif
static const char* level_names[] SPDLOG_LEVEL_NAMES;
static const char* short_level_names[] { "T", "D", "I", "W", "E", "C", "O" };
#if !defined(SPDLOG_SHORT_LEVEL_NAMES)
inline const char* to_str(spdlog::level::level_enum l)
{
return level_names[l];
}
#define SPDLOG_SHORT_LEVEL_NAMES \
{ "T", "D", "I", "W", "E", "C", "O" }
#endif
inline const char* to_short_str(spdlog::level::level_enum l)
{
return short_level_names[l];
}
} //level
SPDLOG_API const string_view_t &to_string_view(spdlog::level::level_enum l) SPDLOG_NOEXCEPT;
SPDLOG_API const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT;
SPDLOG_API spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT;
} // namespace level
//
// Async overflow policy - block by default.
// Color mode used by sinks with color support.
//
enum class async_overflow_policy
{
block_retry, // Block / yield / sleep until message can be enqueued
discard_log_msg // Discard the message it enqueue fails
};
enum class color_mode { always, automatic, never };
//
// Pattern time - specific time getting to use for pattern_formatter.
// local time by default
//
enum class pattern_time_type
{
enum class pattern_time_type {
local, // log localtime
utc // log utc
};
@ -123,39 +299,108 @@ enum class pattern_time_type
//
// Log exception
//
namespace details
{
namespace os
{
std::string errno_str(int err_num);
}
}
class spdlog_ex: public std::exception
{
class SPDLOG_API spdlog_ex : public std::exception {
public:
spdlog_ex(const std::string& msg):_msg(msg)
{}
spdlog_ex(const std::string& msg, int last_errno)
{
_msg = msg + ": " + details::os::errno_str(last_errno);
}
const char* what() const SPDLOG_NOEXCEPT override
{
return _msg.c_str();
}
private:
std::string _msg;
explicit spdlog_ex(std::string msg);
spdlog_ex(const std::string &msg, int last_errno);
const char *what() const SPDLOG_NOEXCEPT override;
private:
std::string msg_;
};
//
// wchar support for windows file names (SPDLOG_WCHAR_FILENAMES must be defined)
//
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
using filename_t = std::wstring;
#else
using filename_t = std::string;
[[noreturn]] SPDLOG_API void throw_spdlog_ex(const std::string &msg, int last_errno);
[[noreturn]] SPDLOG_API void throw_spdlog_ex(std::string msg);
struct source_loc {
SPDLOG_CONSTEXPR source_loc() = default;
SPDLOG_CONSTEXPR source_loc(const char *filename_in, int line_in, const char *funcname_in)
: filename{filename_in},
line{line_in},
funcname{funcname_in} {}
SPDLOG_CONSTEXPR bool empty() const SPDLOG_NOEXCEPT { return line <= 0; }
const char *filename{nullptr};
int line{0};
const char *funcname{nullptr};
};
struct file_event_handlers {
file_event_handlers()
: before_open(nullptr),
after_open(nullptr),
before_close(nullptr),
after_close(nullptr) {}
std::function<void(const filename_t &filename)> before_open;
std::function<void(const filename_t &filename, std::FILE *file_stream)> after_open;
std::function<void(const filename_t &filename, std::FILE *file_stream)> before_close;
std::function<void(const filename_t &filename)> after_close;
};
namespace details {
// to_string_view
SPDLOG_CONSTEXPR_FUNC spdlog::string_view_t to_string_view(const memory_buf_t &buf)
SPDLOG_NOEXCEPT {
return spdlog::string_view_t{buf.data(), buf.size()};
}
SPDLOG_CONSTEXPR_FUNC spdlog::string_view_t to_string_view(spdlog::string_view_t str)
SPDLOG_NOEXCEPT {
return str;
}
#if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
SPDLOG_CONSTEXPR_FUNC spdlog::wstring_view_t to_string_view(const wmemory_buf_t &buf)
SPDLOG_NOEXCEPT {
return spdlog::wstring_view_t{buf.data(), buf.size()};
}
SPDLOG_CONSTEXPR_FUNC spdlog::wstring_view_t to_string_view(spdlog::wstring_view_t str)
SPDLOG_NOEXCEPT {
return str;
}
#endif
#if defined(SPDLOG_USE_STD_FORMAT) && __cpp_lib_format >= 202207L
template <typename T, typename... Args>
SPDLOG_CONSTEXPR_FUNC std::basic_string_view<T> to_string_view(
std::basic_format_string<T, Args...> fmt) SPDLOG_NOEXCEPT {
return fmt.get();
}
#endif
} //spdlog
// make_unique support for pre c++14
#if __cplusplus >= 201402L // C++14 and beyond
using std::enable_if_t;
using std::make_unique;
#else
template <bool B, class T = void>
using enable_if_t = typename std::enable_if<B, T>::type;
template <typename T, typename... Args>
std::unique_ptr<T> make_unique(Args &&...args) {
static_assert(!std::is_array<T>::value, "arrays not supported");
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
#endif
// to avoid useless casts (see https://github.com/nlohmann/json/issues/2893#issuecomment-889152324)
template <typename T, typename U, enable_if_t<!std::is_same<T, U>::value, int> = 0>
constexpr T conditional_static_cast(U value) {
return static_cast<T>(value);
}
template <typename T, typename U, enable_if_t<std::is_same<T, U>::value, int> = 0>
constexpr T conditional_static_cast(U value) {
return value;
}
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "common-inl.h"
#endif

View File

@ -1,399 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
// async log helper :
// Process logs asynchronously using a back thread.
//
// If the internal queue of log messages reaches its max size,
// then the client call will block until there is more room.
//
#pragma once
#include "../common.h"
#include "../sinks/sink.h"
#include "../details/mpmc_bounded_q.h"
#include "../details/log_msg.h"
#include "../details/os.h"
#include "../formatter.h"
#include <chrono>
#include <exception>
#include <functional>
#include <memory>
#include <string>
#include <thread>
#include <utility>
#include <vector>
namespace spdlog
{
namespace details
{
class async_log_helper
{
// Async msg to move to/from the queue
// Movable only. should never be copied
enum class async_msg_type
{
log,
flush,
terminate
};
struct async_msg
{
std::string logger_name;
level::level_enum level;
log_clock::time_point time;
size_t thread_id;
std::string txt;
async_msg_type msg_type;
size_t msg_id;
async_msg() = default;
~async_msg() = default;
async_msg(async_msg&& other) SPDLOG_NOEXCEPT:
logger_name(std::move(other.logger_name)),
level(std::move(other.level)),
time(std::move(other.time)),
thread_id(other.thread_id),
txt(std::move(other.txt)),
msg_type(std::move(other.msg_type)),
msg_id(other.msg_id)
{}
async_msg(async_msg_type m_type):
level(level::info),
thread_id(0),
msg_type(m_type),
msg_id(0)
{}
async_msg& operator=(async_msg&& other) SPDLOG_NOEXCEPT
{
logger_name = std::move(other.logger_name);
level = other.level;
time = std::move(other.time);
thread_id = other.thread_id;
txt = std::move(other.txt);
msg_type = other.msg_type;
msg_id = other.msg_id;
return *this;
}
// never copy or assign. should only be moved..
async_msg(const async_msg&) = delete;
async_msg& operator=(const async_msg& other) = delete;
// construct from log_msg
async_msg(const details::log_msg& m):
level(m.level),
time(m.time),
thread_id(m.thread_id),
txt(m.raw.data(), m.raw.size()),
msg_type(async_msg_type::log),
msg_id(m.msg_id)
{
#ifndef SPDLOG_NO_NAME
logger_name = *m.logger_name;
#endif
}
// copy into log_msg
void fill_log_msg(log_msg &msg)
{
msg.logger_name = &logger_name;
msg.level = level;
msg.time = time;
msg.thread_id = thread_id;
msg.raw << txt;
msg.msg_id = msg_id;
}
};
public:
using item_type = async_msg;
using q_type = details::mpmc_bounded_queue<item_type>;
using clock = std::chrono::steady_clock;
async_log_helper(formatter_ptr formatter,
const std::vector<sink_ptr>& sinks,
size_t queue_size,
const log_err_handler err_handler,
const async_overflow_policy overflow_policy = async_overflow_policy::block_retry,
const std::function<void()>& worker_warmup_cb = nullptr,
const std::chrono::milliseconds& flush_interval_ms = std::chrono::milliseconds::zero(),
const std::function<void()>& worker_teardown_cb = nullptr);
void log(const details::log_msg& msg);
// stop logging and join the back thread
~async_log_helper();
void set_formatter(formatter_ptr);
void flush(bool wait_for_q);
void set_error_handler(spdlog::log_err_handler err_handler);
private:
formatter_ptr _formatter;
std::vector<std::shared_ptr<sinks::sink>> _sinks;
// queue of messages to log
q_type _q;
log_err_handler _err_handler;
bool _flush_requested;
bool _terminate_requested;
// overflow policy
const async_overflow_policy _overflow_policy;
// worker thread warmup callback - one can set thread priority, affinity, etc
const std::function<void()> _worker_warmup_cb;
// auto periodic sink flush parameter
const std::chrono::milliseconds _flush_interval_ms;
// worker thread teardown callback
const std::function<void()> _worker_teardown_cb;
// worker thread
std::thread _worker_thread;
void push_msg(async_msg&& new_msg);
// worker thread main loop
void worker_loop();
// pop next message from the queue and process it. will set the last_pop to the pop time
// return false if termination of the queue is required
bool process_next_msg(log_clock::time_point& last_pop, log_clock::time_point& last_flush);
void handle_flush_interval(log_clock::time_point& now, log_clock::time_point& last_flush);
// sleep,yield or return immediately using the time passed since last message as a hint
static void sleep_or_yield(const spdlog::log_clock::time_point& now, const log_clock::time_point& last_op_time);
// wait until the queue is empty
void wait_empty_q();
};
}
}
///////////////////////////////////////////////////////////////////////////////
// async_sink class implementation
///////////////////////////////////////////////////////////////////////////////
inline spdlog::details::async_log_helper::async_log_helper(
formatter_ptr formatter,
const std::vector<sink_ptr>& sinks,
size_t queue_size,
log_err_handler err_handler,
const async_overflow_policy overflow_policy,
const std::function<void()>& worker_warmup_cb,
const std::chrono::milliseconds& flush_interval_ms,
const std::function<void()>& worker_teardown_cb):
_formatter(formatter),
_sinks(sinks),
_q(queue_size),
_err_handler(err_handler),
_flush_requested(false),
_terminate_requested(false),
_overflow_policy(overflow_policy),
_worker_warmup_cb(worker_warmup_cb),
_flush_interval_ms(flush_interval_ms),
_worker_teardown_cb(worker_teardown_cb),
_worker_thread(&async_log_helper::worker_loop, this)
{}
// Send to the worker thread termination message(level=off)
// and wait for it to finish gracefully
inline spdlog::details::async_log_helper::~async_log_helper()
{
try
{
push_msg(async_msg(async_msg_type::terminate));
_worker_thread.join();
}
catch (...) // don't crash in destructor
{
}
}
//Try to push and block until succeeded (if the policy is not to discard when the queue is full)
inline void spdlog::details::async_log_helper::log(const details::log_msg& msg)
{
push_msg(async_msg(msg));
}
inline void spdlog::details::async_log_helper::push_msg(details::async_log_helper::async_msg&& new_msg)
{
if (!_q.enqueue(std::move(new_msg)) && _overflow_policy != async_overflow_policy::discard_log_msg)
{
auto last_op_time = details::os::now();
auto now = last_op_time;
do
{
now = details::os::now();
sleep_or_yield(now, last_op_time);
}
while (!_q.enqueue(std::move(new_msg)));
}
}
// optionally wait for the queue be empty and request flush from the sinks
inline void spdlog::details::async_log_helper::flush(bool wait_for_q)
{
push_msg(async_msg(async_msg_type::flush));
if (wait_for_q)
wait_empty_q(); //return when queue is empty
}
inline void spdlog::details::async_log_helper::worker_loop()
{
if (_worker_warmup_cb) _worker_warmup_cb();
auto last_pop = details::os::now();
auto last_flush = last_pop;
auto active = true;
while (active)
{
try
{
active = process_next_msg(last_pop, last_flush);
}
catch (const std::exception &ex)
{
_err_handler(ex.what());
}
catch(...)
{
_err_handler("Unknown exeption in async logger worker loop.");
}
}
if (_worker_teardown_cb) _worker_teardown_cb();
}
// process next message in the queue
// return true if this thread should still be active (while no terminate msg was received)
inline bool spdlog::details::async_log_helper::process_next_msg(log_clock::time_point& last_pop, log_clock::time_point& last_flush)
{
async_msg incoming_async_msg;
if (_q.dequeue(incoming_async_msg))
{
last_pop = details::os::now();
switch (incoming_async_msg.msg_type)
{
case async_msg_type::flush:
_flush_requested = true;
break;
case async_msg_type::terminate:
_flush_requested = true;
_terminate_requested = true;
break;
default:
log_msg incoming_log_msg;
incoming_async_msg.fill_log_msg(incoming_log_msg);
_formatter->format(incoming_log_msg);
for (auto &s : _sinks)
{
if (s->should_log(incoming_log_msg.level))
{
s->log(incoming_log_msg);
}
}
}
return true;
}
// Handle empty queue..
// This is the only place where the queue can terminate or flush to avoid losing messages already in the queue
else
{
auto now = details::os::now();
handle_flush_interval(now, last_flush);
sleep_or_yield(now, last_pop);
return !_terminate_requested;
}
}
// flush all sinks if _flush_interval_ms has expired
inline void spdlog::details::async_log_helper::handle_flush_interval(log_clock::time_point& now, log_clock::time_point& last_flush)
{
auto should_flush = _flush_requested || (_flush_interval_ms != std::chrono::milliseconds::zero() && now - last_flush >= _flush_interval_ms);
if (should_flush)
{
for (auto &s : _sinks)
s->flush();
now = last_flush = details::os::now();
_flush_requested = false;
}
}
inline void spdlog::details::async_log_helper::set_formatter(formatter_ptr msg_formatter)
{
_formatter = msg_formatter;
}
// spin, yield or sleep. use the time passed since last message as a hint
inline void spdlog::details::async_log_helper::sleep_or_yield(const spdlog::log_clock::time_point& now, const spdlog::log_clock::time_point& last_op_time)
{
using namespace std::this_thread;
using std::chrono::milliseconds;
using std::chrono::microseconds;
auto time_since_op = now - last_op_time;
// spin upto 50 micros
if (time_since_op <= microseconds(50))
return;
// yield upto 150 micros
if (time_since_op <= microseconds(100))
return std::this_thread::yield();
// sleep for 20 ms upto 200 ms
if (time_since_op <= milliseconds(200))
return sleep_for(milliseconds(20));
// sleep for 500 ms
return sleep_for(milliseconds(500));
}
// wait for the queue to be empty
inline void spdlog::details::async_log_helper::wait_empty_q()
{
auto last_op = details::os::now();
while (!_q.is_empty())
{
sleep_or_yield(details::os::now(), last_op);
}
}
inline void spdlog::details::async_log_helper::set_error_handler(spdlog::log_err_handler err_handler)
{
_err_handler = err_handler;
}

View File

@ -1,107 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
// Async Logger implementation
// Use an async_sink (queue per logger) to perform the logging in a worker thread
#include "../details/async_log_helper.h"
#include "../async_logger.h"
#include <string>
#include <functional>
#include <chrono>
#include <memory>
template<class It>
inline spdlog::async_logger::async_logger(const std::string& logger_name,
const It& begin,
const It& end,
size_t queue_size,
const async_overflow_policy overflow_policy,
const std::function<void()>& worker_warmup_cb,
const std::chrono::milliseconds& flush_interval_ms,
const std::function<void()>& worker_teardown_cb) :
logger(logger_name, begin, end),
_async_log_helper(new details::async_log_helper(_formatter, _sinks, queue_size, _err_handler, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb))
{
}
inline spdlog::async_logger::async_logger(const std::string& logger_name,
sinks_init_list sinks_list,
size_t queue_size,
const async_overflow_policy overflow_policy,
const std::function<void()>& worker_warmup_cb,
const std::chrono::milliseconds& flush_interval_ms,
const std::function<void()>& worker_teardown_cb) :
async_logger(logger_name, sinks_list.begin(), sinks_list.end(), queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb) {}
inline spdlog::async_logger::async_logger(const std::string& logger_name,
sink_ptr single_sink,
size_t queue_size,
const async_overflow_policy overflow_policy,
const std::function<void()>& worker_warmup_cb,
const std::chrono::milliseconds& flush_interval_ms,
const std::function<void()>& worker_teardown_cb) :
async_logger(logger_name,
{
single_sink
}, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb) {}
inline void spdlog::async_logger::flush()
{
_async_log_helper->flush(true);
}
// Error handler
inline void spdlog::async_logger::set_error_handler(spdlog::log_err_handler err_handler)
{
_err_handler = err_handler;
_async_log_helper->set_error_handler(err_handler);
}
inline spdlog::log_err_handler spdlog::async_logger::error_handler()
{
return _err_handler;
}
inline void spdlog::async_logger::_set_formatter(spdlog::formatter_ptr msg_formatter)
{
_formatter = msg_formatter;
_async_log_helper->set_formatter(_formatter);
}
inline void spdlog::async_logger::_set_pattern(const std::string& pattern, pattern_time_type pattern_time)
{
_formatter = std::make_shared<pattern_formatter>(pattern, pattern_time);
_async_log_helper->set_formatter(_formatter);
}
inline void spdlog::async_logger::_sink_it(details::log_msg& msg)
{
try
{
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
_incr_msg_counter(msg);
#endif
_async_log_helper->log(msg);
if (_should_flush_on(msg))
_async_log_helper->flush(false); // do async flush
}
catch (const std::exception &ex)
{
_err_handler(ex.what());
}
catch(...)
{
_err_handler("Unknown exception in logger " + _name);
throw;
}
}

View File

@ -0,0 +1,63 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/details/backtracer.h>
#endif
namespace spdlog {
namespace details {
SPDLOG_INLINE backtracer::backtracer(const backtracer &other) {
std::lock_guard<std::mutex> lock(other.mutex_);
enabled_ = other.enabled();
messages_ = other.messages_;
}
SPDLOG_INLINE backtracer::backtracer(backtracer &&other) SPDLOG_NOEXCEPT {
std::lock_guard<std::mutex> lock(other.mutex_);
enabled_ = other.enabled();
messages_ = std::move(other.messages_);
}
SPDLOG_INLINE backtracer &backtracer::operator=(backtracer other) {
std::lock_guard<std::mutex> lock(mutex_);
enabled_ = other.enabled();
messages_ = std::move(other.messages_);
return *this;
}
SPDLOG_INLINE void backtracer::enable(size_t size) {
std::lock_guard<std::mutex> lock{mutex_};
enabled_.store(true, std::memory_order_relaxed);
messages_ = circular_q<log_msg_buffer>{size};
}
SPDLOG_INLINE void backtracer::disable() {
std::lock_guard<std::mutex> lock{mutex_};
enabled_.store(false, std::memory_order_relaxed);
}
SPDLOG_INLINE bool backtracer::enabled() const { return enabled_.load(std::memory_order_relaxed); }
SPDLOG_INLINE void backtracer::push_back(const log_msg &msg) {
std::lock_guard<std::mutex> lock{mutex_};
messages_.push_back(log_msg_buffer{msg});
}
SPDLOG_INLINE bool backtracer::empty() const {
std::lock_guard<std::mutex> lock{mutex_};
return messages_.empty();
}
// pop all items in the q and apply the given fun on each of them.
SPDLOG_INLINE void backtracer::foreach_pop(std::function<void(const details::log_msg &)> fun) {
std::lock_guard<std::mutex> lock{mutex_};
while (!messages_.empty()) {
auto &front_msg = messages_.front();
fun(front_msg);
messages_.pop_front();
}
}
} // namespace details
} // namespace spdlog

View File

@ -0,0 +1,45 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#include <spdlog/details/circular_q.h>
#include <spdlog/details/log_msg_buffer.h>
#include <atomic>
#include <functional>
#include <mutex>
// Store log messages in circular buffer.
// Useful for storing debug data in case of error/warning happens.
namespace spdlog {
namespace details {
class SPDLOG_API backtracer {
mutable std::mutex mutex_;
std::atomic<bool> enabled_{false};
circular_q<log_msg_buffer> messages_;
public:
backtracer() = default;
backtracer(const backtracer &other);
backtracer(backtracer &&other) SPDLOG_NOEXCEPT;
backtracer &operator=(backtracer other);
void enable(size_t size);
void disable();
bool enabled() const;
void push_back(const log_msg &msg);
bool empty() const;
// pop all items in the q and apply the given fun on each of them.
void foreach_pop(std::function<void(const details::log_msg &)> fun);
};
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "backtracer-inl.h"
#endif

View File

@ -0,0 +1,115 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
// circular q view of std::vector.
#pragma once
#include <cassert>
#include <vector>
#include "spdlog/common.h"
namespace spdlog {
namespace details {
template <typename T>
class circular_q {
size_t max_items_ = 0;
typename std::vector<T>::size_type head_ = 0;
typename std::vector<T>::size_type tail_ = 0;
size_t overrun_counter_ = 0;
std::vector<T> v_;
public:
using value_type = T;
// empty ctor - create a disabled queue with no elements allocated at all
circular_q() = default;
explicit circular_q(size_t max_items)
: max_items_(max_items + 1) // one item is reserved as marker for full q
,
v_(max_items_) {}
circular_q(const circular_q &) = default;
circular_q &operator=(const circular_q &) = default;
// move cannot be default,
// since we need to reset head_, tail_, etc to zero in the moved object
circular_q(circular_q &&other) SPDLOG_NOEXCEPT { copy_moveable(std::move(other)); }
circular_q &operator=(circular_q &&other) SPDLOG_NOEXCEPT {
copy_moveable(std::move(other));
return *this;
}
// push back, overrun (oldest) item if no room left
void push_back(T &&item) {
if (max_items_ > 0) {
v_[tail_] = std::move(item);
tail_ = (tail_ + 1) % max_items_;
if (tail_ == head_) // overrun last item if full
{
head_ = (head_ + 1) % max_items_;
++overrun_counter_;
}
}
}
// Return reference to the front item.
// If there are no elements in the container, the behavior is undefined.
const T &front() const { return v_[head_]; }
T &front() { return v_[head_]; }
// Return number of elements actually stored
size_t size() const {
if (tail_ >= head_) {
return tail_ - head_;
} else {
return max_items_ - (head_ - tail_);
}
}
// Return const reference to item by index.
// If index is out of range 0…size()-1, the behavior is undefined.
const T &at(size_t i) const {
assert(i < size());
return v_[(head_ + i) % max_items_];
}
// Pop item from front.
// If there are no elements in the container, the behavior is undefined.
void pop_front() { head_ = (head_ + 1) % max_items_; }
bool empty() const { return tail_ == head_; }
bool full() const {
// head is ahead of the tail by 1
if (max_items_ > 0) {
return ((tail_ + 1) % max_items_) == head_;
}
return false;
}
size_t overrun_counter() const { return overrun_counter_; }
void reset_overrun_counter() { overrun_counter_ = 0; }
private:
// copy from other&& and reset it to disabled state
void copy_moveable(circular_q &&other) SPDLOG_NOEXCEPT {
max_items_ = other.max_items_;
head_ = other.head_;
tail_ = other.tail_;
overrun_counter_ = other.overrun_counter_;
v_ = std::move(other.v_);
// put &&other in disabled, but valid state
other.max_items_ = 0;
other.head_ = other.tail_ = 0;
other.overrun_counter_ = 0;
}
};
} // namespace details
} // namespace spdlog

View File

@ -0,0 +1,28 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#include <mutex>
#include <spdlog/details/null_mutex.h>
namespace spdlog {
namespace details {
struct console_mutex {
using mutex_t = std::mutex;
static mutex_t &mutex() {
static mutex_t s_mutex;
return s_mutex;
}
};
struct console_nullmutex {
using mutex_t = null_mutex;
static mutex_t &mutex() {
static mutex_t s_mutex;
return s_mutex;
}
};
} // namespace details
} // namespace spdlog

View File

@ -0,0 +1,153 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/details/file_helper.h>
#endif
#include <spdlog/common.h>
#include <spdlog/details/os.h>
#include <cerrno>
#include <chrono>
#include <cstdio>
#include <string>
#include <thread>
#include <tuple>
namespace spdlog {
namespace details {
SPDLOG_INLINE file_helper::file_helper(const file_event_handlers &event_handlers)
: event_handlers_(event_handlers) {}
SPDLOG_INLINE file_helper::~file_helper() { close(); }
SPDLOG_INLINE void file_helper::open(const filename_t &fname, bool truncate) {
close();
filename_ = fname;
auto *mode = SPDLOG_FILENAME_T("ab");
auto *trunc_mode = SPDLOG_FILENAME_T("wb");
if (event_handlers_.before_open) {
event_handlers_.before_open(filename_);
}
for (int tries = 0; tries < open_tries_; ++tries) {
// create containing folder if not exists already.
os::create_dir(os::dir_name(fname));
if (truncate) {
// Truncate by opening-and-closing a tmp file in "wb" mode, always
// opening the actual log-we-write-to in "ab" mode, since that
// interacts more politely with eternal processes that might
// rotate/truncate the file underneath us.
std::FILE *tmp;
if (os::fopen_s(&tmp, fname, trunc_mode)) {
continue;
}
std::fclose(tmp);
}
if (!os::fopen_s(&fd_, fname, mode)) {
if (event_handlers_.after_open) {
event_handlers_.after_open(filename_, fd_);
}
return;
}
details::os::sleep_for_millis(open_interval_);
}
throw_spdlog_ex("Failed opening file " + os::filename_to_str(filename_) + " for writing",
errno);
}
SPDLOG_INLINE void file_helper::reopen(bool truncate) {
if (filename_.empty()) {
throw_spdlog_ex("Failed re opening file - was not opened before");
}
this->open(filename_, truncate);
}
SPDLOG_INLINE void file_helper::flush() {
if (std::fflush(fd_) != 0) {
throw_spdlog_ex("Failed flush to file " + os::filename_to_str(filename_), errno);
}
}
SPDLOG_INLINE void file_helper::sync() {
if (!os::fsync(fd_)) {
throw_spdlog_ex("Failed to fsync file " + os::filename_to_str(filename_), errno);
}
}
SPDLOG_INLINE void file_helper::close() {
if (fd_ != nullptr) {
if (event_handlers_.before_close) {
event_handlers_.before_close(filename_, fd_);
}
std::fclose(fd_);
fd_ = nullptr;
if (event_handlers_.after_close) {
event_handlers_.after_close(filename_);
}
}
}
SPDLOG_INLINE void file_helper::write(const memory_buf_t &buf) {
if (fd_ == nullptr) return;
size_t msg_size = buf.size();
auto data = buf.data();
if (!details::os::fwrite_bytes(data, msg_size, fd_)) {
throw_spdlog_ex("Failed writing to file " + os::filename_to_str(filename_), errno);
}
}
SPDLOG_INLINE size_t file_helper::size() const {
if (fd_ == nullptr) {
throw_spdlog_ex("Cannot use size() on closed file " + os::filename_to_str(filename_));
}
return os::filesize(fd_);
}
SPDLOG_INLINE const filename_t &file_helper::filename() const { return filename_; }
//
// return file path and its extension:
//
// "mylog.txt" => ("mylog", ".txt")
// "mylog" => ("mylog", "")
// "mylog." => ("mylog.", "")
// "/dir1/dir2/mylog.txt" => ("/dir1/dir2/mylog", ".txt")
//
// the starting dot in filenames is ignored (hidden files):
//
// ".mylog" => (".mylog". "")
// "my_folder/.mylog" => ("my_folder/.mylog", "")
// "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt")
SPDLOG_INLINE std::tuple<filename_t, filename_t> file_helper::split_by_extension(
const filename_t &fname) {
auto ext_index = fname.rfind('.');
// no valid extension found - return whole path and empty string as
// extension
if (ext_index == filename_t::npos || ext_index == 0 || ext_index == fname.size() - 1) {
return std::make_tuple(fname, filename_t());
}
// treat cases like "/etc/rc.d/somelogfile or "/abc/.hiddenfile"
auto folder_index = fname.find_last_of(details::os::folder_seps_filename);
if (folder_index != filename_t::npos && folder_index >= ext_index - 1) {
return std::make_tuple(fname, filename_t());
}
// finally - return a valid base and extension tuple
return std::make_tuple(fname.substr(0, ext_index), fname.substr(ext_index));
}
} // namespace details
} // namespace spdlog

View File

@ -1,137 +1,61 @@
//
// Copyright(c) 2015 Gabi Melman.
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
// Helper class for file sink
// When failing to open a file, retry several times(5) with small delay between the tries(10 ms)
// Throw spdlog_ex exception on errors
#include "../details/os.h"
#include "../details/log_msg.h"
#include <chrono>
#include <cstdio>
#include <string>
#include <thread>
#include <spdlog/common.h>
#include <tuple>
#include <cerrno>
namespace spdlog
{
namespace details
{
namespace spdlog {
namespace details {
class file_helper
{
// Helper class for file sinks.
// When failing to open a file, retry several times(5) with a delay interval(10 ms).
// Throw spdlog_ex exception on errors.
class SPDLOG_API file_helper {
public:
const int open_tries = 5;
const int open_interval = 10;
explicit file_helper() :
_fd(nullptr)
{}
file_helper() = default;
explicit file_helper(const file_event_handlers &event_handlers);
file_helper(const file_helper &) = delete;
file_helper &operator=(const file_helper &) = delete;
~file_helper();
~file_helper()
{
close();
}
void open(const filename_t& fname, bool truncate = false)
{
close();
auto *mode = truncate ? SPDLOG_FILENAME_T("wb") : SPDLOG_FILENAME_T("ab");
_filename = fname;
for (int tries = 0; tries < open_tries; ++tries)
{
if (!os::fopen_s(&_fd, fname, mode))
return;
std::this_thread::sleep_for(std::chrono::milliseconds(open_interval));
}
throw spdlog_ex("Failed opening file " + os::filename_to_str(_filename) + " for writing", errno);
}
void reopen(bool truncate)
{
if (_filename.empty())
throw spdlog_ex("Failed re opening file - was not opened before");
open(_filename, truncate);
}
void flush()
{
std::fflush(_fd);
}
void close()
{
if (_fd)
{
std::fclose(_fd);
_fd = nullptr;
}
}
void write(const log_msg& msg)
{
size_t msg_size = msg.formatted.size();
auto data = msg.formatted.data();
if (std::fwrite(data, 1, msg_size, _fd) != msg_size)
throw spdlog_ex("Failed writing to file " + os::filename_to_str(_filename), errno);
}
size_t size() const
{
if (!_fd)
throw spdlog_ex("Cannot use size() on closed file " + os::filename_to_str(_filename));
return os::filesize(_fd);
}
const filename_t& filename() const
{
return _filename;
}
static bool file_exists(const filename_t& fname)
{
return os::file_exists(fname);
}
void open(const filename_t &fname, bool truncate = false);
void reopen(bool truncate);
void flush();
void sync();
void close();
void write(const memory_buf_t &buf);
size_t size() const;
const filename_t &filename() const;
//
// return basename and extension:
// return file path and its extension:
//
// "mylog.txt" => ("mylog", ".txt")
// "mylog" => ("mylog", "")
// "mylog." => ("mylog.", "")
// "/dir1/dir2/mylog.txt" => ("/dir1/dir2/mylog", ".txt")
//
// the starting dot in filenames is ignored (hidden files):
//
// "my_folder/.mylog" => ("my_folder/.mylog")
// ".mylog" => (".mylog". "")
// "my_folder/.mylog" => ("my_folder/.mylog", "")
// "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt")
static std::tuple<filename_t, filename_t> split_by_extenstion(const filename_t& fname)
{
auto index = fname.rfind('.');
bool found_ext = index != filename_t::npos && index !=0 && fname[index - 1] != details::os::folder_sep;
if (found_ext)
return std::make_tuple(fname.substr(0, index), fname.substr(index));
else
return std::make_tuple(fname, filename_t());
}
static std::tuple<filename_t, filename_t> split_by_extension(const filename_t &fname);
private:
FILE* _fd;
filename_t _filename;
const int open_tries_ = 5;
const unsigned int open_interval_ = 10;
std::FILE *fd_{nullptr};
filename_t filename_;
file_event_handlers event_handlers_;
};
}
}
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "file_helper-inl.h"
#endif

View File

@ -0,0 +1,141 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#include <chrono>
#include <iterator>
#include <spdlog/common.h>
#include <spdlog/fmt/fmt.h>
#include <type_traits>
#ifdef SPDLOG_USE_STD_FORMAT
#include <charconv>
#include <limits>
#endif
// Some fmt helpers to efficiently format and pad ints and strings
namespace spdlog {
namespace details {
namespace fmt_helper {
inline void append_string_view(spdlog::string_view_t view, memory_buf_t &dest) {
auto *buf_ptr = view.data();
dest.append(buf_ptr, buf_ptr + view.size());
}
#ifdef SPDLOG_USE_STD_FORMAT
template <typename T>
inline void append_int(T n, memory_buf_t &dest) {
// Buffer should be large enough to hold all digits (digits10 + 1) and a sign
SPDLOG_CONSTEXPR const auto BUF_SIZE = std::numeric_limits<T>::digits10 + 2;
char buf[BUF_SIZE];
auto [ptr, ec] = std::to_chars(buf, buf + BUF_SIZE, n, 10);
if (ec == std::errc()) {
dest.append(buf, ptr);
} else {
throw_spdlog_ex("Failed to format int", static_cast<int>(ec));
}
}
#else
template <typename T>
inline void append_int(T n, memory_buf_t &dest) {
fmt::format_int i(n);
dest.append(i.data(), i.data() + i.size());
}
#endif
template <typename T>
SPDLOG_CONSTEXPR_FUNC unsigned int count_digits_fallback(T n) {
// taken from fmt: https://github.com/fmtlib/fmt/blob/8.0.1/include/fmt/format.h#L899-L912
unsigned int count = 1;
for (;;) {
// Integer division is slow so do it for a group of four digits instead
// of for every digit. The idea comes from the talk by Alexandrescu
// "Three Optimization Tips for C++". See speed-test for a comparison.
if (n < 10) return count;
if (n < 100) return count + 1;
if (n < 1000) return count + 2;
if (n < 10000) return count + 3;
n /= 10000u;
count += 4;
}
}
template <typename T>
inline unsigned int count_digits(T n) {
using count_type =
typename std::conditional<(sizeof(T) > sizeof(uint32_t)), uint64_t, uint32_t>::type;
#ifdef SPDLOG_USE_STD_FORMAT
return count_digits_fallback(static_cast<count_type>(n));
#else
return static_cast<unsigned int>(fmt::
// fmt 7.0.0 renamed the internal namespace to detail.
// See: https://github.com/fmtlib/fmt/issues/1538
#if FMT_VERSION < 70000
internal
#else
detail
#endif
::count_digits(static_cast<count_type>(n)));
#endif
}
inline void pad2(int n, memory_buf_t &dest) {
if (n >= 0 && n < 100) // 0-99
{
dest.push_back(static_cast<char>('0' + n / 10));
dest.push_back(static_cast<char>('0' + n % 10));
} else // unlikely, but just in case, let fmt deal with it
{
fmt_lib::format_to(std::back_inserter(dest), SPDLOG_FMT_STRING("{:02}"), n);
}
}
template <typename T>
inline void pad_uint(T n, unsigned int width, memory_buf_t &dest) {
static_assert(std::is_unsigned<T>::value, "pad_uint must get unsigned T");
for (auto digits = count_digits(n); digits < width; digits++) {
dest.push_back('0');
}
append_int(n, dest);
}
template <typename T>
inline void pad3(T n, memory_buf_t &dest) {
static_assert(std::is_unsigned<T>::value, "pad3 must get unsigned T");
if (n < 1000) {
dest.push_back(static_cast<char>(n / 100 + '0'));
n = n % 100;
dest.push_back(static_cast<char>((n / 10) + '0'));
dest.push_back(static_cast<char>((n % 10) + '0'));
} else {
append_int(n, dest);
}
}
template <typename T>
inline void pad6(T n, memory_buf_t &dest) {
pad_uint(n, 6, dest);
}
template <typename T>
inline void pad9(T n, memory_buf_t &dest) {
pad_uint(n, 9, dest);
}
// return fraction of a second of the given time_point.
// e.g.
// fraction<std::milliseconds>(tp) -> will return the millis part of the second
template <typename ToDuration>
inline ToDuration time_fraction(log_clock::time_point tp) {
using std::chrono::duration_cast;
using std::chrono::seconds;
auto duration = tp.time_since_epoch();
auto secs = duration_cast<seconds>(duration);
return duration_cast<ToDuration>(duration) - duration_cast<ToDuration>(secs);
}
} // namespace fmt_helper
} // namespace details
} // namespace spdlog

View File

@ -0,0 +1,44 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/details/log_msg.h>
#endif
#include <spdlog/details/os.h>
namespace spdlog {
namespace details {
SPDLOG_INLINE log_msg::log_msg(spdlog::log_clock::time_point log_time,
spdlog::source_loc loc,
string_view_t a_logger_name,
spdlog::level::level_enum lvl,
spdlog::string_view_t msg)
: logger_name(a_logger_name),
level(lvl),
time(log_time)
#ifndef SPDLOG_NO_THREAD_ID
,
thread_id(os::thread_id())
#endif
,
source(loc),
payload(msg) {
}
SPDLOG_INLINE log_msg::log_msg(spdlog::source_loc loc,
string_view_t a_logger_name,
spdlog::level::level_enum lvl,
spdlog::string_view_t msg)
: log_msg(os::now(), loc, a_logger_name, lvl, msg) {}
SPDLOG_INLINE log_msg::log_msg(string_view_t a_logger_name,
spdlog::level::level_enum lvl,
spdlog::string_view_t msg)
: log_msg(os::now(), source_loc{}, a_logger_name, lvl, msg) {}
} // namespace details
} // namespace spdlog

View File

@ -1,50 +1,40 @@
//
// Copyright(c) 2015 Gabi Melman.
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
#include "../common.h"
#include "../details/os.h"
#include <spdlog/common.h>
#include <string>
#include <utility>
namespace spdlog
{
namespace details
{
struct log_msg
{
namespace spdlog {
namespace details {
struct SPDLOG_API log_msg {
log_msg() = default;
log_msg(const std::string *loggers_name, level::level_enum lvl) :
logger_name(loggers_name),
level(lvl),
msg_id(0)
{
#ifndef SPDLOG_NO_DATETIME
time = os::now();
#endif
log_msg(log_clock::time_point log_time,
source_loc loc,
string_view_t logger_name,
level::level_enum lvl,
string_view_t msg);
log_msg(source_loc loc, string_view_t logger_name, level::level_enum lvl, string_view_t msg);
log_msg(string_view_t logger_name, level::level_enum lvl, string_view_t msg);
log_msg(const log_msg &other) = default;
log_msg &operator=(const log_msg &other) = default;
#ifndef SPDLOG_NO_THREAD_ID
thread_id = os::thread_id();
#endif
}
log_msg(const log_msg& other) = delete;
log_msg& operator=(log_msg&& other) = delete;
log_msg(log_msg&& other) = delete;
const std::string *logger_name;
level::level_enum level;
string_view_t logger_name;
level::level_enum level{level::off};
log_clock::time_point time;
size_t thread_id;
fmt::MemoryWriter raw;
fmt::MemoryWriter formatted;
size_t msg_id;
size_t thread_id{0};
// wrapping the formatted text with color (updated by pattern_formatter).
mutable size_t color_range_start{0};
mutable size_t color_range_end{0};
source_loc source;
string_view_t payload;
};
}
}
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "log_msg-inl.h"
#endif

View File

@ -0,0 +1,54 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/details/log_msg_buffer.h>
#endif
namespace spdlog {
namespace details {
SPDLOG_INLINE log_msg_buffer::log_msg_buffer(const log_msg &orig_msg)
: log_msg{orig_msg} {
buffer.append(logger_name.begin(), logger_name.end());
buffer.append(payload.begin(), payload.end());
update_string_views();
}
SPDLOG_INLINE log_msg_buffer::log_msg_buffer(const log_msg_buffer &other)
: log_msg{other} {
buffer.append(logger_name.begin(), logger_name.end());
buffer.append(payload.begin(), payload.end());
update_string_views();
}
SPDLOG_INLINE log_msg_buffer::log_msg_buffer(log_msg_buffer &&other) SPDLOG_NOEXCEPT
: log_msg{other},
buffer{std::move(other.buffer)} {
update_string_views();
}
SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(const log_msg_buffer &other) {
log_msg::operator=(other);
buffer.clear();
buffer.append(other.buffer.data(), other.buffer.data() + other.buffer.size());
update_string_views();
return *this;
}
SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT {
log_msg::operator=(other);
buffer = std::move(other.buffer);
update_string_views();
return *this;
}
SPDLOG_INLINE void log_msg_buffer::update_string_views() {
logger_name = string_view_t{buffer.data(), logger_name.size()};
payload = string_view_t{buffer.data() + logger_name.size(), payload.size()};
}
} // namespace details
} // namespace spdlog

View File

@ -0,0 +1,32 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#include <spdlog/details/log_msg.h>
namespace spdlog {
namespace details {
// Extend log_msg with internal buffer to store its payload.
// This is needed since log_msg holds string_views that points to stack data.
class SPDLOG_API log_msg_buffer : public log_msg {
memory_buf_t buffer;
void update_string_views();
public:
log_msg_buffer() = default;
explicit log_msg_buffer(const log_msg &orig_msg);
log_msg_buffer(const log_msg_buffer &other);
log_msg_buffer(log_msg_buffer &&other) SPDLOG_NOEXCEPT;
log_msg_buffer &operator=(const log_msg_buffer &other);
log_msg_buffer &operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT;
};
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "log_msg_buffer-inl.h"
#endif

View File

@ -1,363 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
#include "../logger.h"
#include "../sinks/stdout_sinks.h"
#include <memory>
#include <string>
// create logger with given name, sinks and the default pattern formatter
// all other ctors will call this one
template<class It>
inline spdlog::logger::logger(const std::string& logger_name, const It& begin, const It& end):
_name(logger_name),
_sinks(begin, end),
_formatter(std::make_shared<pattern_formatter>("%+")),
_level(level::info),
_flush_level(level::off),
_last_err_time(0),
_msg_counter(1) // message counter will start from 1. 0-message id will be reserved for controll messages
{
_err_handler = [this](const std::string &msg)
{
this->_default_err_handler(msg);
};
}
// ctor with sinks as init list
inline spdlog::logger::logger(const std::string& logger_name, sinks_init_list sinks_list):
logger(logger_name, sinks_list.begin(), sinks_list.end())
{}
// ctor with single sink
inline spdlog::logger::logger(const std::string& logger_name, spdlog::sink_ptr single_sink):
logger(logger_name,
{
single_sink
})
{}
inline spdlog::logger::~logger() = default;
inline void spdlog::logger::set_formatter(spdlog::formatter_ptr msg_formatter)
{
_set_formatter(msg_formatter);
}
inline void spdlog::logger::set_pattern(const std::string& pattern, pattern_time_type pattern_time)
{
_set_pattern(pattern, pattern_time);
}
template <typename... Args>
inline void spdlog::logger::log(level::level_enum lvl, const char* fmt, const Args&... args)
{
if (!should_log(lvl)) return;
try
{
details::log_msg log_msg(&_name, lvl);
#if defined(SPDLOG_FMT_PRINTF)
fmt::printf(log_msg.raw, fmt, args...);
#else
log_msg.raw.write(fmt, args...);
#endif
_sink_it(log_msg);
}
catch (const std::exception &ex)
{
_err_handler(ex.what());
}
catch(...)
{
_err_handler("Unknown exception in logger " + _name);
throw;
}
}
template <typename... Args>
inline void spdlog::logger::log(level::level_enum lvl, const char* msg)
{
if (!should_log(lvl)) return;
try
{
details::log_msg log_msg(&_name, lvl);
log_msg.raw << msg;
_sink_it(log_msg);
}
catch (const std::exception &ex)
{
_err_handler(ex.what());
}
}
template<typename T>
inline void spdlog::logger::log(level::level_enum lvl, const T& msg)
{
if (!should_log(lvl)) return;
try
{
details::log_msg log_msg(&_name, lvl);
log_msg.raw << msg;
_sink_it(log_msg);
}
catch (const std::exception &ex)
{
_err_handler(ex.what());
}
}
template <typename Arg1, typename... Args>
inline void spdlog::logger::trace(const char* fmt, const Arg1 &arg1, const Args&... args)
{
log(level::trace, fmt, arg1, args...);
}
template <typename Arg1, typename... Args>
inline void spdlog::logger::debug(const char* fmt, const Arg1 &arg1, const Args&... args)
{
log(level::debug, fmt, arg1, args...);
}
template <typename Arg1, typename... Args>
inline void spdlog::logger::info(const char* fmt, const Arg1 &arg1, const Args&... args)
{
log(level::info, fmt, arg1, args...);
}
template <typename Arg1, typename... Args>
inline void spdlog::logger::warn(const char* fmt, const Arg1 &arg1, const Args&... args)
{
log(level::warn, fmt, arg1, args...);
}
template <typename Arg1, typename... Args>
inline void spdlog::logger::error(const char* fmt, const Arg1 &arg1, const Args&... args)
{
log(level::err, fmt, arg1, args...);
}
template <typename Arg1, typename... Args>
inline void spdlog::logger::critical(const char* fmt, const Arg1 &arg1, const Args&... args)
{
log(level::critical, fmt, arg1, args...);
}
template<typename T>
inline void spdlog::logger::trace(const T& msg)
{
log(level::trace, msg);
}
template<typename T>
inline void spdlog::logger::debug(const T& msg)
{
log(level::debug, msg);
}
template<typename T>
inline void spdlog::logger::info(const T& msg)
{
log(level::info, msg);
}
template<typename T>
inline void spdlog::logger::warn(const T& msg)
{
log(level::warn, msg);
}
template<typename T>
inline void spdlog::logger::error(const T& msg)
{
log(level::err, msg);
}
template<typename T>
inline void spdlog::logger::critical(const T& msg)
{
log(level::critical, msg);
}
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
#include <codecvt>
#include <locale>
template <typename... Args>
inline void spdlog::logger::log(level::level_enum lvl, const wchar_t* msg)
{
std::wstring_convert<std::codecvt_utf8<wchar_t> > conv;
log(lvl, conv.to_bytes(msg));
}
template <typename... Args>
inline void spdlog::logger::log(level::level_enum lvl, const wchar_t* fmt, const Args&... args)
{
fmt::WMemoryWriter wWriter;
wWriter.write(fmt, args...);
log(lvl, wWriter.c_str());
}
template <typename... Args>
inline void spdlog::logger::trace(const wchar_t* fmt, const Args&... args)
{
log(level::trace, fmt, args...);
}
template <typename... Args>
inline void spdlog::logger::debug(const wchar_t* fmt, const Args&... args)
{
log(level::debug, fmt, args...);
}
template <typename... Args>
inline void spdlog::logger::info(const wchar_t* fmt, const Args&... args)
{
log(level::info, fmt, args...);
}
template <typename... Args>
inline void spdlog::logger::warn(const wchar_t* fmt, const Args&... args)
{
log(level::warn, fmt, args...);
}
template <typename... Args>
inline void spdlog::logger::error(const wchar_t* fmt, const Args&... args)
{
log(level::err, fmt, args...);
}
template <typename... Args>
inline void spdlog::logger::critical(const wchar_t* fmt, const Args&... args)
{
log(level::critical, fmt, args...);
}
#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT
//
// name and level
//
inline const std::string& spdlog::logger::name() const
{
return _name;
}
inline void spdlog::logger::set_level(spdlog::level::level_enum log_level)
{
_level.store(log_level);
}
inline void spdlog::logger::set_error_handler(spdlog::log_err_handler err_handler)
{
_err_handler = err_handler;
}
inline spdlog::log_err_handler spdlog::logger::error_handler()
{
return _err_handler;
}
inline void spdlog::logger::flush_on(level::level_enum log_level)
{
_flush_level.store(log_level);
}
inline spdlog::level::level_enum spdlog::logger::level() const
{
return static_cast<spdlog::level::level_enum>(_level.load(std::memory_order_relaxed));
}
inline bool spdlog::logger::should_log(spdlog::level::level_enum msg_level) const
{
return msg_level >= _level.load(std::memory_order_relaxed);
}
//
// protected virtual called at end of each user log call (if enabled) by the line_logger
//
inline void spdlog::logger::_sink_it(details::log_msg& msg)
{
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
_incr_msg_counter(msg);
#endif
_formatter->format(msg);
for (auto &sink : _sinks)
{
if( sink->should_log( msg.level))
{
sink->log(msg);
}
}
if(_should_flush_on(msg))
flush();
}
inline void spdlog::logger::_set_pattern(const std::string& pattern, pattern_time_type pattern_time)
{
_formatter = std::make_shared<pattern_formatter>(pattern, pattern_time);
}
inline void spdlog::logger::_set_formatter(formatter_ptr msg_formatter)
{
_formatter = msg_formatter;
}
inline void spdlog::logger::flush()
{
for (auto& sink : _sinks)
sink->flush();
}
inline void spdlog::logger::_default_err_handler(const std::string &msg)
{
auto now = time(nullptr);
if (now - _last_err_time < 60)
return;
auto tm_time = details::os::localtime(now);
char date_buf[100];
std::strftime(date_buf, sizeof(date_buf), "%Y-%m-%d %H:%M:%S", &tm_time);
details::log_msg err_msg;
err_msg.formatted.write("[*** LOG ERROR ***] [{}] [{}] [{}]{}", name(), msg, date_buf, details::os::eol);
sinks::stderr_sink_mt::instance()->log(err_msg);
_last_err_time = now;
}
inline bool spdlog::logger::_should_flush_on(const details::log_msg &msg)
{
const auto flush_level = _flush_level.load(std::memory_order_relaxed);
return (msg.level >= flush_level) && (msg.level != level::off);
}
inline void spdlog::logger::_incr_msg_counter(details::log_msg &msg)
{
msg.msg_id = _msg_counter.fetch_add(1, std::memory_order_relaxed);
}
inline const std::vector<spdlog::sink_ptr>& spdlog::logger::sinks() const
{
return _sinks;
}

View File

@ -0,0 +1,177 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
// multi producer-multi consumer blocking queue.
// enqueue(..) - will block until room found to put the new message.
// enqueue_nowait(..) - will return immediately with false if no room left in
// the queue.
// dequeue_for(..) - will block until the queue is not empty or timeout have
// passed.
#include <spdlog/details/circular_q.h>
#include <atomic>
#include <condition_variable>
#include <mutex>
namespace spdlog {
namespace details {
template <typename T>
class mpmc_blocking_queue {
public:
using item_type = T;
explicit mpmc_blocking_queue(size_t max_items)
: q_(max_items) {}
#ifndef __MINGW32__
// try to enqueue and block if no room left
void enqueue(T &&item) {
{
std::unique_lock<std::mutex> lock(queue_mutex_);
pop_cv_.wait(lock, [this] { return !this->q_.full(); });
q_.push_back(std::move(item));
}
push_cv_.notify_one();
}
// enqueue immediately. overrun oldest message in the queue if no room left.
void enqueue_nowait(T &&item) {
{
std::unique_lock<std::mutex> lock(queue_mutex_);
q_.push_back(std::move(item));
}
push_cv_.notify_one();
}
void enqueue_if_have_room(T &&item) {
bool pushed = false;
{
std::unique_lock<std::mutex> lock(queue_mutex_);
if (!q_.full()) {
q_.push_back(std::move(item));
pushed = true;
}
}
if (pushed) {
push_cv_.notify_one();
} else {
++discard_counter_;
}
}
// dequeue with a timeout.
// Return true, if succeeded dequeue item, false otherwise
bool dequeue_for(T &popped_item, std::chrono::milliseconds wait_duration) {
{
std::unique_lock<std::mutex> lock(queue_mutex_);
if (!push_cv_.wait_for(lock, wait_duration, [this] { return !this->q_.empty(); })) {
return false;
}
popped_item = std::move(q_.front());
q_.pop_front();
}
pop_cv_.notify_one();
return true;
}
// blocking dequeue without a timeout.
void dequeue(T &popped_item) {
{
std::unique_lock<std::mutex> lock(queue_mutex_);
push_cv_.wait(lock, [this] { return !this->q_.empty(); });
popped_item = std::move(q_.front());
q_.pop_front();
}
pop_cv_.notify_one();
}
#else
// apparently mingw deadlocks if the mutex is released before cv.notify_one(),
// so release the mutex at the very end each function.
// try to enqueue and block if no room left
void enqueue(T &&item) {
std::unique_lock<std::mutex> lock(queue_mutex_);
pop_cv_.wait(lock, [this] { return !this->q_.full(); });
q_.push_back(std::move(item));
push_cv_.notify_one();
}
// enqueue immediately. overrun oldest message in the queue if no room left.
void enqueue_nowait(T &&item) {
std::unique_lock<std::mutex> lock(queue_mutex_);
q_.push_back(std::move(item));
push_cv_.notify_one();
}
void enqueue_if_have_room(T &&item) {
bool pushed = false;
std::unique_lock<std::mutex> lock(queue_mutex_);
if (!q_.full()) {
q_.push_back(std::move(item));
pushed = true;
}
if (pushed) {
push_cv_.notify_one();
} else {
++discard_counter_;
}
}
// dequeue with a timeout.
// Return true, if succeeded dequeue item, false otherwise
bool dequeue_for(T &popped_item, std::chrono::milliseconds wait_duration) {
std::unique_lock<std::mutex> lock(queue_mutex_);
if (!push_cv_.wait_for(lock, wait_duration, [this] { return !this->q_.empty(); })) {
return false;
}
popped_item = std::move(q_.front());
q_.pop_front();
pop_cv_.notify_one();
return true;
}
// blocking dequeue without a timeout.
void dequeue(T &popped_item) {
std::unique_lock<std::mutex> lock(queue_mutex_);
push_cv_.wait(lock, [this] { return !this->q_.empty(); });
popped_item = std::move(q_.front());
q_.pop_front();
pop_cv_.notify_one();
}
#endif
size_t overrun_counter() {
std::lock_guard<std::mutex> lock(queue_mutex_);
return q_.overrun_counter();
}
size_t discard_counter() { return discard_counter_.load(std::memory_order_relaxed); }
size_t size() {
std::lock_guard<std::mutex> lock(queue_mutex_);
return q_.size();
}
void reset_overrun_counter() {
std::lock_guard<std::mutex> lock(queue_mutex_);
q_.reset_overrun_counter();
}
void reset_discard_counter() { discard_counter_.store(0, std::memory_order_relaxed); }
private:
std::mutex queue_mutex_;
std::condition_variable push_cv_;
std::condition_variable pop_cv_;
spdlog::details::circular_q<T> q_;
std::atomic<size_t> discard_counter_{0};
};
} // namespace details
} // namespace spdlog

View File

@ -1,176 +0,0 @@
/*
A modified version of Bounded MPMC queue by Dmitry Vyukov.
Original code from:
http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue
licensed by Dmitry Vyukov under the terms below:
Simplified BSD license
Copyright (c) 2010-2011 Dmitry Vyukov. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
THIS SOFTWARE IS PROVIDED BY DMITRY VYUKOV "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL DMITRY VYUKOV OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those of the authors and
should not be interpreted as representing official policies, either expressed or implied, of Dmitry Vyukov.
*/
/*
The code in its current form adds the license below:
Copyright(c) 2015 Gabi Melman.
Distributed under the MIT License (http://opensource.org/licenses/MIT)
*/
#pragma once
#include "../common.h"
#include <atomic>
#include <utility>
namespace spdlog
{
namespace details
{
template<typename T>
class mpmc_bounded_queue
{
public:
using item_type = T;
mpmc_bounded_queue(size_t buffer_size)
:max_size_(buffer_size),
buffer_(new cell_t[buffer_size]),
buffer_mask_(buffer_size - 1)
{
//queue size must be power of two
if (!((buffer_size >= 2) && ((buffer_size & (buffer_size - 1)) == 0)))
throw spdlog_ex("async logger queue size must be power of two");
for (size_t i = 0; i != buffer_size; i += 1)
buffer_[i].sequence_.store(i, std::memory_order_relaxed);
enqueue_pos_.store(0, std::memory_order_relaxed);
dequeue_pos_.store(0, std::memory_order_relaxed);
}
~mpmc_bounded_queue()
{
delete[] buffer_;
}
bool enqueue(T&& data)
{
cell_t* cell;
size_t pos = enqueue_pos_.load(std::memory_order_relaxed);
for (;;)
{
cell = &buffer_[pos & buffer_mask_];
size_t seq = cell->sequence_.load(std::memory_order_acquire);
intptr_t dif = static_cast<intptr_t>(seq) - static_cast<intptr_t>(pos);
if (dif == 0)
{
if (enqueue_pos_.compare_exchange_weak(pos, pos + 1, std::memory_order_relaxed))
break;
}
else if (dif < 0)
{
return false;
}
else
{
pos = enqueue_pos_.load(std::memory_order_relaxed);
}
}
cell->data_ = std::move(data);
cell->sequence_.store(pos + 1, std::memory_order_release);
return true;
}
bool dequeue(T& data)
{
cell_t* cell;
size_t pos = dequeue_pos_.load(std::memory_order_relaxed);
for (;;)
{
cell = &buffer_[pos & buffer_mask_];
size_t seq =
cell->sequence_.load(std::memory_order_acquire);
intptr_t dif = static_cast<intptr_t>(seq) - static_cast<intptr_t>(pos + 1);
if (dif == 0)
{
if (dequeue_pos_.compare_exchange_weak(pos, pos + 1, std::memory_order_relaxed))
break;
}
else if (dif < 0)
return false;
else
pos = dequeue_pos_.load(std::memory_order_relaxed);
}
data = std::move(cell->data_);
cell->sequence_.store(pos + buffer_mask_ + 1, std::memory_order_release);
return true;
}
bool is_empty()
{
size_t front, front1, back;
// try to take a consistent snapshot of front/tail.
do
{
front = enqueue_pos_.load(std::memory_order_acquire);
back = dequeue_pos_.load(std::memory_order_acquire);
front1 = enqueue_pos_.load(std::memory_order_relaxed);
}
while (front != front1);
return back == front;
}
private:
struct cell_t
{
std::atomic<size_t> sequence_;
T data_;
};
size_t const max_size_;
static size_t const cacheline_size = 64;
typedef char cacheline_pad_t[cacheline_size];
cacheline_pad_t pad0_;
cell_t* const buffer_;
size_t const buffer_mask_;
cacheline_pad_t pad1_;
std::atomic<size_t> enqueue_pos_;
cacheline_pad_t pad2_;
std::atomic<size_t> dequeue_pos_;
cacheline_pad_t pad3_;
mpmc_bounded_queue(mpmc_bounded_queue const&) = delete;
void operator= (mpmc_bounded_queue const&) = delete;
};
} // ns details
} // ns spdlog

View File

@ -1,45 +1,35 @@
//
// Copyright(c) 2015 Gabi Melman.
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
#include <atomic>
#include <utility>
// null, no cost dummy "mutex" and dummy "atomic" int
namespace spdlog
{
namespace details
{
struct null_mutex
{
void lock() {}
void unlock() {}
bool try_lock()
{
return true;
}
namespace spdlog {
namespace details {
struct null_mutex {
void lock() const {}
void unlock() const {}
};
struct null_atomic_int
{
struct null_atomic_int {
int value;
null_atomic_int() = default;
null_atomic_int(int val):value(val)
{}
explicit null_atomic_int(int new_value)
: value(new_value) {}
int load(std::memory_order) const
{
return value;
}
int load(std::memory_order = std::memory_order_relaxed) const { return value; }
void store(int val)
{
value = val;
void store(int new_value, std::memory_order = std::memory_order_relaxed) { value = new_value; }
int exchange(int new_value, std::memory_order = std::memory_order_relaxed) {
std::swap(new_value, value);
return new_value; // return value before the call
}
};
}
}
} // namespace details
} // namespace spdlog

View File

@ -0,0 +1,607 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/details/os.h>
#endif
#include <spdlog/common.h>
#include <algorithm>
#include <array>
#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <string>
#include <sys/stat.h>
#include <sys/types.h>
#include <thread>
#ifdef _WIN32
#include <spdlog/details/windows_include.h>
#include <fileapi.h> // for FlushFileBuffers
#include <io.h> // for _get_osfhandle, _isatty, _fileno
#include <process.h> // for _get_pid
#ifdef __MINGW32__
#include <share.h>
#endif
#if defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)
#include <cassert>
#include <limits>
#endif
#include <direct.h> // for _mkdir/_wmkdir
#else // unix
#include <fcntl.h>
#include <unistd.h>
#ifdef __linux__
#include <sys/syscall.h> //Use gettid() syscall under linux to get thread id
#elif defined(_AIX)
#include <pthread.h> // for pthread_getthrds_np
#elif defined(__DragonFly__) || defined(__FreeBSD__)
#include <pthread_np.h> // for pthread_getthreadid_np
#elif defined(__NetBSD__)
#include <lwp.h> // for _lwp_self
#elif defined(__sun)
#include <thread.h> // for thr_self
#endif
#endif // unix
#if defined __APPLE__
#include <AvailabilityMacros.h>
#endif
#ifndef __has_feature // Clang - feature checking macros.
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
#endif
namespace spdlog {
namespace details {
namespace os {
SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT {
#if defined __linux__ && defined SPDLOG_CLOCK_COARSE
timespec ts;
::clock_gettime(CLOCK_REALTIME_COARSE, &ts);
return std::chrono::time_point<log_clock, typename log_clock::duration>(
std::chrono::duration_cast<typename log_clock::duration>(
std::chrono::seconds(ts.tv_sec) + std::chrono::nanoseconds(ts.tv_nsec)));
#else
return log_clock::now();
#endif
}
SPDLOG_INLINE std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT {
#ifdef _WIN32
std::tm tm;
::localtime_s(&tm, &time_tt);
#else
std::tm tm;
::localtime_r(&time_tt, &tm);
#endif
return tm;
}
SPDLOG_INLINE std::tm localtime() SPDLOG_NOEXCEPT {
std::time_t now_t = ::time(nullptr);
return localtime(now_t);
}
SPDLOG_INLINE std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT {
#ifdef _WIN32
std::tm tm;
::gmtime_s(&tm, &time_tt);
#else
std::tm tm;
::gmtime_r(&time_tt, &tm);
#endif
return tm;
}
SPDLOG_INLINE std::tm gmtime() SPDLOG_NOEXCEPT {
std::time_t now_t = ::time(nullptr);
return gmtime(now_t);
}
// fopen_s on non windows for writing
SPDLOG_INLINE bool fopen_s(FILE **fp, const filename_t &filename, const filename_t &mode) {
#ifdef _WIN32
#ifdef SPDLOG_WCHAR_FILENAMES
*fp = ::_wfsopen((filename.c_str()), mode.c_str(), _SH_DENYNO);
#else
*fp = ::_fsopen((filename.c_str()), mode.c_str(), _SH_DENYNO);
#endif
#if defined(SPDLOG_PREVENT_CHILD_FD)
if (*fp != nullptr) {
auto file_handle = reinterpret_cast<HANDLE>(_get_osfhandle(::_fileno(*fp)));
if (!::SetHandleInformation(file_handle, HANDLE_FLAG_INHERIT, 0)) {
::fclose(*fp);
*fp = nullptr;
}
}
#endif
#else // unix
#if defined(SPDLOG_PREVENT_CHILD_FD)
const int mode_flag = mode == SPDLOG_FILENAME_T("ab") ? O_APPEND : O_TRUNC;
const int fd =
::open((filename.c_str()), O_CREAT | O_WRONLY | O_CLOEXEC | mode_flag, mode_t(0644));
if (fd == -1) {
return true;
}
*fp = ::fdopen(fd, mode.c_str());
if (*fp == nullptr) {
::close(fd);
}
#else
*fp = ::fopen((filename.c_str()), mode.c_str());
#endif
#endif
return *fp == nullptr;
}
SPDLOG_INLINE int remove(const filename_t &filename) SPDLOG_NOEXCEPT {
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
return ::_wremove(filename.c_str());
#else
return std::remove(filename.c_str());
#endif
}
SPDLOG_INLINE int remove_if_exists(const filename_t &filename) SPDLOG_NOEXCEPT {
return path_exists(filename) ? remove(filename) : 0;
}
SPDLOG_INLINE int rename(const filename_t &filename1, const filename_t &filename2) SPDLOG_NOEXCEPT {
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
return ::_wrename(filename1.c_str(), filename2.c_str());
#else
return std::rename(filename1.c_str(), filename2.c_str());
#endif
}
// Return true if path exists (file or directory)
SPDLOG_INLINE bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT {
#ifdef _WIN32
struct _stat buffer;
#ifdef SPDLOG_WCHAR_FILENAMES
return (::_wstat(filename.c_str(), &buffer) == 0);
#else
return (::_stat(filename.c_str(), &buffer) == 0);
#endif
#else // common linux/unix all have the stat system call
struct stat buffer;
return (::stat(filename.c_str(), &buffer) == 0);
#endif
}
#ifdef _MSC_VER
// avoid warning about unreachable statement at the end of filesize()
#pragma warning(push)
#pragma warning(disable : 4702)
#endif
// Return file size according to open FILE* object
SPDLOG_INLINE size_t filesize(FILE *f) {
if (f == nullptr) {
throw_spdlog_ex("Failed getting file size. fd is null");
}
#if defined(_WIN32) && !defined(__CYGWIN__)
int fd = ::_fileno(f);
#if defined(_WIN64) // 64 bits
__int64 ret = ::_filelengthi64(fd);
if (ret >= 0) {
return static_cast<size_t>(ret);
}
#else // windows 32 bits
long ret = ::_filelength(fd);
if (ret >= 0) {
return static_cast<size_t>(ret);
}
#endif
#else // unix
// OpenBSD and AIX doesn't compile with :: before the fileno(..)
#if defined(__OpenBSD__) || defined(_AIX)
int fd = fileno(f);
#else
int fd = ::fileno(f);
#endif
// 64 bits(but not in osx, linux/musl or cygwin, where fstat64 is deprecated)
#if ((defined(__linux__) && defined(__GLIBC__)) || defined(__sun) || defined(_AIX)) && \
(defined(__LP64__) || defined(_LP64))
struct stat64 st;
if (::fstat64(fd, &st) == 0) {
return static_cast<size_t>(st.st_size);
}
#else // other unix or linux 32 bits or cygwin
struct stat st;
if (::fstat(fd, &st) == 0) {
return static_cast<size_t>(st.st_size);
}
#endif
#endif
throw_spdlog_ex("Failed getting file size from fd", errno);
return 0; // will not be reached.
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif
// Return utc offset in minutes or throw spdlog_ex on failure
SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) {
#ifdef _WIN32
#if _WIN32_WINNT < _WIN32_WINNT_WS08
TIME_ZONE_INFORMATION tzinfo;
auto rv = ::GetTimeZoneInformation(&tzinfo);
#else
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
auto rv = ::GetDynamicTimeZoneInformation(&tzinfo);
#endif
if (rv == TIME_ZONE_ID_INVALID) throw_spdlog_ex("Failed getting timezone info. ", errno);
int offset = -tzinfo.Bias;
if (tm.tm_isdst) {
offset -= tzinfo.DaylightBias;
} else {
offset -= tzinfo.StandardBias;
}
return offset;
#else
#if defined(sun) || defined(__sun) || defined(_AIX) || \
(defined(__NEWLIB__) && !defined(__TM_GMTOFF)) || \
(!defined(__APPLE__) && !defined(_BSD_SOURCE) && !defined(_GNU_SOURCE) && \
(!defined(_POSIX_VERSION) || (_POSIX_VERSION < 202405L)))
// 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris
struct helper {
static long int calculate_gmt_offset(const std::tm &localtm = details::os::localtime(),
const std::tm &gmtm = details::os::gmtime()) {
int local_year = localtm.tm_year + (1900 - 1);
int gmt_year = gmtm.tm_year + (1900 - 1);
long int days = (
// difference in day of year
localtm.tm_yday -
gmtm.tm_yday
// + intervening leap days
+ ((local_year >> 2) - (gmt_year >> 2)) - (local_year / 100 - gmt_year / 100) +
((local_year / 100 >> 2) - (gmt_year / 100 >> 2))
// + difference in years * 365 */
+ static_cast<long int>(local_year - gmt_year) * 365);
long int hours = (24 * days) + (localtm.tm_hour - gmtm.tm_hour);
long int mins = (60 * hours) + (localtm.tm_min - gmtm.tm_min);
long int secs = (60 * mins) + (localtm.tm_sec - gmtm.tm_sec);
return secs;
}
};
auto offset_seconds = helper::calculate_gmt_offset(tm);
#else
auto offset_seconds = tm.tm_gmtoff;
#endif
return static_cast<int>(offset_seconds / 60);
#endif
}
// Return current thread id as size_t
// It exists because the std::this_thread::get_id() is much slower(especially
// under VS 2013)
SPDLOG_INLINE size_t _thread_id() SPDLOG_NOEXCEPT {
#ifdef _WIN32
return static_cast<size_t>(::GetCurrentThreadId());
#elif defined(__linux__)
#if defined(__ANDROID__) && defined(__ANDROID_API__) && (__ANDROID_API__ < 21)
#define SYS_gettid __NR_gettid
#endif
return static_cast<size_t>(::syscall(SYS_gettid));
#elif defined(_AIX)
struct __pthrdsinfo buf;
int reg_size = 0;
pthread_t pt = pthread_self();
int retval = pthread_getthrds_np(&pt, PTHRDSINFO_QUERY_TID, &buf, sizeof(buf), NULL, &reg_size);
int tid = (!retval) ? buf.__pi_tid : 0;
return static_cast<size_t>(tid);
#elif defined(__DragonFly__) || defined(__FreeBSD__)
return static_cast<size_t>(::pthread_getthreadid_np());
#elif defined(__NetBSD__)
return static_cast<size_t>(::_lwp_self());
#elif defined(__OpenBSD__)
return static_cast<size_t>(::getthrid());
#elif defined(__sun)
return static_cast<size_t>(::thr_self());
#elif __APPLE__
uint64_t tid;
// There is no pthread_threadid_np prior to Mac OS X 10.6, and it is not supported on any PPC,
// including 10.6.8 Rosetta. __POWERPC__ is Apple-specific define encompassing ppc and ppc64.
#ifdef MAC_OS_X_VERSION_MAX_ALLOWED
{
#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) || defined(__POWERPC__)
tid = pthread_mach_thread_np(pthread_self());
#elif MAC_OS_X_VERSION_MIN_REQUIRED < 1060
if (&pthread_threadid_np) {
pthread_threadid_np(nullptr, &tid);
} else {
tid = pthread_mach_thread_np(pthread_self());
}
#else
pthread_threadid_np(nullptr, &tid);
#endif
}
#else
pthread_threadid_np(nullptr, &tid);
#endif
return static_cast<size_t>(tid);
#else // Default to standard C++11 (other Unix)
return static_cast<size_t>(std::hash<std::thread::id>()(std::this_thread::get_id()));
#endif
}
// Return current thread id as size_t (from thread local storage)
SPDLOG_INLINE size_t thread_id() SPDLOG_NOEXCEPT {
#if defined(SPDLOG_NO_TLS)
return _thread_id();
#else // cache thread id in tls
static thread_local const size_t tid = _thread_id();
return tid;
#endif
}
// This is avoid msvc issue in sleep_for that happens if the clock changes.
// See https://github.com/gabime/spdlog/issues/609
SPDLOG_INLINE void sleep_for_millis(unsigned int milliseconds) SPDLOG_NOEXCEPT {
#if defined(_WIN32)
::Sleep(milliseconds);
#else
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
#endif
}
// wchar support for windows file names (SPDLOG_WCHAR_FILENAMES must be defined)
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
SPDLOG_INLINE std::string filename_to_str(const filename_t &filename) {
memory_buf_t buf;
wstr_to_utf8buf(filename, buf);
return SPDLOG_BUF_TO_STRING(buf);
}
#else
SPDLOG_INLINE std::string filename_to_str(const filename_t &filename) { return filename; }
#endif
SPDLOG_INLINE int pid() SPDLOG_NOEXCEPT {
#ifdef _WIN32
return conditional_static_cast<int>(::GetCurrentProcessId());
#else
return conditional_static_cast<int>(::getpid());
#endif
}
// Determine if the terminal supports colors
// Based on: https://github.com/agauniyal/rang/
SPDLOG_INLINE bool is_color_terminal() SPDLOG_NOEXCEPT {
#ifdef _WIN32
return true;
#else
static const bool result = []() {
const char *env_colorterm_p = std::getenv("COLORTERM");
if (env_colorterm_p != nullptr) {
return true;
}
static constexpr std::array<const char *, 16> terms = {
{"ansi", "color", "console", "cygwin", "gnome", "konsole", "kterm", "linux", "msys",
"putty", "rxvt", "screen", "vt100", "xterm", "alacritty", "vt102"}};
const char *env_term_p = std::getenv("TERM");
if (env_term_p == nullptr) {
return false;
}
return std::any_of(terms.begin(), terms.end(), [&](const char *term) {
return std::strstr(env_term_p, term) != nullptr;
});
}();
return result;
#endif
}
// Determine if the terminal attached
// Source: https://github.com/agauniyal/rang/
SPDLOG_INLINE bool in_terminal(FILE *file) SPDLOG_NOEXCEPT {
#ifdef _WIN32
return ::_isatty(_fileno(file)) != 0;
#else
return ::isatty(fileno(file)) != 0;
#endif
}
#if (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) && defined(_WIN32)
SPDLOG_INLINE void wstr_to_utf8buf(wstring_view_t wstr, memory_buf_t &target) {
if (wstr.size() > static_cast<size_t>((std::numeric_limits<int>::max)()) / 4 - 1) {
throw_spdlog_ex("UTF-16 string is too big to be converted to UTF-8");
}
int wstr_size = static_cast<int>(wstr.size());
if (wstr_size == 0) {
target.resize(0);
return;
}
int result_size = static_cast<int>(target.capacity());
if ((wstr_size + 1) * 4 > result_size) {
result_size =
::WideCharToMultiByte(CP_UTF8, 0, wstr.data(), wstr_size, NULL, 0, NULL, NULL);
}
if (result_size > 0) {
target.resize(result_size);
result_size = ::WideCharToMultiByte(CP_UTF8, 0, wstr.data(), wstr_size, target.data(),
result_size, NULL, NULL);
if (result_size > 0) {
target.resize(result_size);
return;
}
}
throw_spdlog_ex(
fmt_lib::format("WideCharToMultiByte failed. Last error: {}", ::GetLastError()));
}
SPDLOG_INLINE void utf8_to_wstrbuf(string_view_t str, wmemory_buf_t &target) {
if (str.size() > static_cast<size_t>((std::numeric_limits<int>::max)()) - 1) {
throw_spdlog_ex("UTF-8 string is too big to be converted to UTF-16");
}
int str_size = static_cast<int>(str.size());
if (str_size == 0) {
target.resize(0);
return;
}
// find the size to allocate for the result buffer
int result_size =
::MultiByteToWideChar(CP_UTF8, 0, str.data(), str_size, NULL, 0);
if (result_size > 0) {
target.resize(result_size);
result_size = ::MultiByteToWideChar(CP_UTF8, 0, str.data(), str_size, target.data(),
result_size);
if (result_size > 0) {
assert(result_size == target.size());
return;
}
}
throw_spdlog_ex(
fmt_lib::format("MultiByteToWideChar failed. Last error: {}", ::GetLastError()));
}
#endif // (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) &&
// defined(_WIN32)
// return true on success
static SPDLOG_INLINE bool mkdir_(const filename_t &path) {
#ifdef _WIN32
#ifdef SPDLOG_WCHAR_FILENAMES
return ::_wmkdir(path.c_str()) == 0;
#else
return ::_mkdir(path.c_str()) == 0;
#endif
#else
return ::mkdir(path.c_str(), mode_t(0755)) == 0;
#endif
}
// create the given directory - and all directories leading to it
// return true on success or if the directory already exists
SPDLOG_INLINE bool create_dir(const filename_t &path) {
if (path_exists(path)) {
return true;
}
if (path.empty()) {
return false;
}
size_t search_offset = 0;
do {
auto token_pos = path.find_first_of(folder_seps_filename, search_offset);
// treat the entire path as a folder if no folder separator not found
if (token_pos == filename_t::npos) {
token_pos = path.size();
}
auto subdir = path.substr(0, token_pos);
#ifdef _WIN32
// if subdir is just a drive letter, add a slash e.g. "c:"=>"c:\",
// otherwise path_exists(subdir) returns false (issue #3079)
const bool is_drive = subdir.length() == 2 && subdir[1] == ':';
if (is_drive) {
subdir += '\\';
token_pos++;
}
#endif
if (!subdir.empty() && !path_exists(subdir) && !mkdir_(subdir)) {
return false; // return error if failed creating dir
}
search_offset = token_pos + 1;
} while (search_offset < path.size());
return true;
}
// Return directory name from given path or empty string
// "abc/file" => "abc"
// "abc/" => "abc"
// "abc" => ""
// "abc///" => "abc//"
SPDLOG_INLINE filename_t dir_name(const filename_t &path) {
auto pos = path.find_last_of(folder_seps_filename);
return pos != filename_t::npos ? path.substr(0, pos) : filename_t{};
}
std::string SPDLOG_INLINE getenv(const char *field) {
#if defined(_MSC_VER)
#if defined(__cplusplus_winrt)
return std::string{}; // not supported under uwp
#else
size_t len = 0;
char buf[128];
bool ok = ::getenv_s(&len, buf, sizeof(buf), field) == 0;
return ok ? buf : std::string{};
#endif
#else // revert to getenv
char *buf = ::getenv(field);
return buf ? buf : std::string{};
#endif
}
// Do fsync by FILE handlerpointer
// Return true on success
SPDLOG_INLINE bool fsync(FILE *fp) {
#ifdef _WIN32
return FlushFileBuffers(reinterpret_cast<HANDLE>(_get_osfhandle(_fileno(fp)))) != 0;
#else
return ::fsync(fileno(fp)) == 0;
#endif
}
// Do non-locking fwrite if possible by the os or use the regular locking fwrite
// Return true on success.
SPDLOG_INLINE bool fwrite_bytes(const void *ptr, const size_t n_bytes, FILE *fp) {
#if defined(_WIN32) && defined(SPDLOG_FWRITE_UNLOCKED)
return _fwrite_nolock(ptr, 1, n_bytes, fp) == n_bytes;
#elif defined(SPDLOG_FWRITE_UNLOCKED)
return ::fwrite_unlocked(ptr, 1, n_bytes, fp) == n_bytes;
#else
return std::fwrite(ptr, 1, n_bytes, fp) == n_bytes;
#endif
}
} // namespace os
} // namespace details
} // namespace spdlog

View File

@ -1,135 +1,24 @@
//
// Copyright(c) 2015 Gabi Melman.
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
#include "../common.h"
#include <ctime> // std::time_t
#include <spdlog/common.h>
#include <cstdio>
#include <ctime>
#include <functional>
#include <string>
#include <chrono>
#include <thread>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <sys/stat.h>
#include <sys/types.h>
namespace spdlog {
namespace details {
namespace os {
#ifdef _WIN32
SPDLOG_API spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT;
#ifndef NOMINMAX
#define NOMINMAX //prevent windows redefining min/max
#endif
SPDLOG_API std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT;
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <process.h> // _get_pid support
#include <io.h> // _get_osfhandle and _isatty support
SPDLOG_API std::tm localtime() SPDLOG_NOEXCEPT;
#ifdef __MINGW32__
#include <share.h>
#endif
SPDLOG_API std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT;
#else // unix
#include <unistd.h>
#include <fcntl.h>
#ifdef __linux__
#include <sys/syscall.h> //Use gettid() syscall under linux to get thread id
#elif __FreeBSD__
#include <sys/thr.h> //Use thr_self() syscall under FreeBSD to get thread id
#endif
#endif //unix
#ifndef __has_feature // Clang - feature checking macros.
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
#endif
namespace spdlog
{
namespace details
{
namespace os
{
inline spdlog::log_clock::time_point now()
{
#if defined __linux__ && defined SPDLOG_CLOCK_COARSE
timespec ts;
::clock_gettime(CLOCK_REALTIME_COARSE, &ts);
return std::chrono::time_point<log_clock, typename log_clock::duration>(
std::chrono::duration_cast<typename log_clock::duration>(
std::chrono::seconds(ts.tv_sec) + std::chrono::nanoseconds(ts.tv_nsec)));
#else
return log_clock::now();
#endif
}
inline std::tm localtime(const std::time_t &time_tt)
{
#ifdef _WIN32
std::tm tm;
localtime_s(&tm, &time_tt);
#else
std::tm tm;
localtime_r(&time_tt, &tm);
#endif
return tm;
}
inline std::tm localtime()
{
std::time_t now_t = time(nullptr);
return localtime(now_t);
}
inline std::tm gmtime(const std::time_t &time_tt)
{
#ifdef _WIN32
std::tm tm;
gmtime_s(&tm, &time_tt);
#else
std::tm tm;
gmtime_r(&time_tt, &tm);
#endif
return tm;
}
inline std::tm gmtime()
{
std::time_t now_t = time(nullptr);
return gmtime(now_t);
}
inline bool operator==(const std::tm& tm1, const std::tm& tm2)
{
return (tm1.tm_sec == tm2.tm_sec &&
tm1.tm_min == tm2.tm_min &&
tm1.tm_hour == tm2.tm_hour &&
tm1.tm_mday == tm2.tm_mday &&
tm1.tm_mon == tm2.tm_mon &&
tm1.tm_year == tm2.tm_year &&
tm1.tm_isdst == tm2.tm_isdst);
}
inline bool operator!=(const std::tm& tm1, const std::tm& tm2)
{
return !(tm1 == tm2);
}
SPDLOG_API std::tm gmtime() SPDLOG_NOEXCEPT;
// eol definition
#if !defined(SPDLOG_EOL)
@ -140,340 +29,99 @@ inline bool operator!=(const std::tm& tm1, const std::tm& tm2)
#endif
#endif
SPDLOG_CONSTEXPR static const char* eol = SPDLOG_EOL;
SPDLOG_CONSTEXPR static int eol_size = sizeof(SPDLOG_EOL) - 1;
SPDLOG_CONSTEXPR static const char *default_eol = SPDLOG_EOL;
// folder separator
#if !defined(SPDLOG_FOLDER_SEPS)
#ifdef _WIN32
SPDLOG_CONSTEXPR static const char folder_sep = '\\';
#define SPDLOG_FOLDER_SEPS "\\/"
#else
SPDLOG_CONSTEXPR static const char folder_sep = '/';
#define SPDLOG_FOLDER_SEPS "/"
#endif
#endif
inline void prevent_child_fd(FILE *f)
{
#ifdef _WIN32
auto file_handle = (HANDLE)_get_osfhandle(_fileno(f));
if (!::SetHandleInformation(file_handle, HANDLE_FLAG_INHERIT, 0))
throw spdlog_ex("SetHandleInformation failed", errno);
#else
auto fd = fileno(f);
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
throw spdlog_ex("fcntl with FD_CLOEXEC failed", errno);
#endif
}
SPDLOG_CONSTEXPR static const char folder_seps[] = SPDLOG_FOLDER_SEPS;
SPDLOG_CONSTEXPR static const filename_t::value_type folder_seps_filename[] =
SPDLOG_FILENAME_T(SPDLOG_FOLDER_SEPS);
// fopen_s on non windows for writing
inline int fopen_s(FILE** fp, const filename_t& filename, const filename_t& mode)
{
#ifdef _WIN32
#ifdef SPDLOG_WCHAR_FILENAMES
*fp = _wfsopen((filename.c_str()), mode.c_str(), _SH_DENYWR);
#else
*fp = _fsopen((filename.c_str()), mode.c_str(), _SH_DENYWR);
#endif
#else //unix
*fp = fopen((filename.c_str()), mode.c_str());
#endif
SPDLOG_API bool fopen_s(FILE **fp, const filename_t &filename, const filename_t &mode);
#ifdef SPDLOG_PREVENT_CHILD_FD
if (*fp != nullptr)
prevent_child_fd(*fp);
#endif
return *fp == nullptr;
}
inline int remove(const filename_t &filename)
{
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
return _wremove(filename.c_str());
#else
return std::remove(filename.c_str());
#endif
}
inline int rename(const filename_t& filename1, const filename_t& filename2)
{
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
return _wrename(filename1.c_str(), filename2.c_str());
#else
return std::rename(filename1.c_str(), filename2.c_str());
#endif
}
//Return if file exists
inline bool file_exists(const filename_t& filename)
{
#ifdef _WIN32
#ifdef SPDLOG_WCHAR_FILENAMES
auto attribs = GetFileAttributesW(filename.c_str());
#else
auto attribs = GetFileAttributesA(filename.c_str());
#endif
return (attribs != INVALID_FILE_ATTRIBUTES && !(attribs & FILE_ATTRIBUTE_DIRECTORY));
#else //common linux/unix all have the stat system call
struct stat buffer;
return (stat(filename.c_str(), &buffer) == 0);
#endif
}
// Remove filename. return 0 on success
SPDLOG_API int remove(const filename_t &filename) SPDLOG_NOEXCEPT;
// Remove file if exists. return 0 on success
// Note: Non atomic (might return failure to delete if concurrently deleted by other process/thread)
SPDLOG_API int remove_if_exists(const filename_t &filename) SPDLOG_NOEXCEPT;
SPDLOG_API int rename(const filename_t &filename1, const filename_t &filename2) SPDLOG_NOEXCEPT;
// Return if file exists.
SPDLOG_API bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT;
// Return file size according to open FILE* object
inline size_t filesize(FILE *f)
{
if (f == nullptr)
throw spdlog_ex("Failed getting file size. fd is null");
#if defined ( _WIN32) && !defined(__CYGWIN__)
int fd = _fileno(f);
#if _WIN64 //64 bits
struct _stat64 st;
if (_fstat64(fd, &st) == 0)
return st.st_size;
#else //windows 32 bits
long ret = _filelength(fd);
if (ret >= 0)
return static_cast<size_t>(ret);
#endif
#else // unix
int fd = fileno(f);
//64 bits(but not in osx or cygwin, where fstat64 is deprecated)
#if !defined(__FreeBSD__) && !defined(__APPLE__) && (defined(__x86_64__) || defined(__ppc64__)) && !defined(__CYGWIN__)
struct stat64 st;
if (fstat64(fd, &st) == 0)
return static_cast<size_t>(st.st_size);
#else // unix 32 bits or cygwin
struct stat st;
if (fstat(fd, &st) == 0)
return static_cast<size_t>(st.st_size);
#endif
#endif
throw spdlog_ex("Failed getting file size from fd", errno);
}
SPDLOG_API size_t filesize(FILE *f);
// Return utc offset in minutes or throw spdlog_ex on failure
inline int utc_minutes_offset(const std::tm& tm = details::os::localtime())
{
#ifdef _WIN32
#if _WIN32_WINNT < _WIN32_WINNT_WS08
TIME_ZONE_INFORMATION tzinfo;
auto rv = GetTimeZoneInformation(&tzinfo);
#else
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
auto rv = GetDynamicTimeZoneInformation(&tzinfo);
#endif
if (rv == TIME_ZONE_ID_INVALID)
throw spdlog::spdlog_ex("Failed getting timezone info. ", errno);
int offset = -tzinfo.Bias;
if (tm.tm_isdst)
offset -= tzinfo.DaylightBias;
else
offset -= tzinfo.StandardBias;
return offset;
#else
#if defined(sun) || defined(__sun)
// 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris
struct helper
{
static long int calculate_gmt_offset(const std::tm & localtm = details::os::localtime(), const std::tm & gmtm = details::os::gmtime())
{
int local_year = localtm.tm_year + (1900 - 1);
int gmt_year = gmtm.tm_year + (1900 - 1);
long int days = (
// difference in day of year
localtm.tm_yday - gmtm.tm_yday
// + intervening leap days
+ ((local_year >> 2) - (gmt_year >> 2))
- (local_year / 100 - gmt_year / 100)
+ ((local_year / 100 >> 2) - (gmt_year / 100 >> 2))
// + difference in years * 365 */
+ (long int)(local_year - gmt_year) * 365
);
long int hours = (24 * days) + (localtm.tm_hour - gmtm.tm_hour);
long int mins = (60 * hours) + (localtm.tm_min - gmtm.tm_min);
long int secs = (60 * mins) + (localtm.tm_sec - gmtm.tm_sec);
return secs;
}
};
long int offset_seconds = helper::calculate_gmt_offset(tm);
#else
long int offset_seconds = tm.tm_gmtoff;
#endif
return static_cast<int>(offset_seconds / 60);
#endif
}
SPDLOG_API int utc_minutes_offset(const std::tm &tm = details::os::localtime());
// Return current thread id as size_t
//It exists because the std::this_thread::get_id() is much slower(especially under VS 2013)
inline size_t _thread_id()
{
#ifdef _WIN32
return static_cast<size_t>(::GetCurrentThreadId());
#elif __linux__
# if defined(__ANDROID__) && defined(__ANDROID_API__) && (__ANDROID_API__ < 21)
# define SYS_gettid __NR_gettid
# endif
return static_cast<size_t>(syscall(SYS_gettid));
#elif __FreeBSD__
long tid;
thr_self(&tid);
return static_cast<size_t>(tid);
#elif __APPLE__
uint64_t tid;
pthread_threadid_np(nullptr, &tid);
return static_cast<size_t>(tid);
#else //Default to standard C++11 (other Unix)
return static_cast<size_t>(std::hash<std::thread::id>()(std::this_thread::get_id()));
#endif
}
// It exists because the std::this_thread::get_id() is much slower(especially
// under VS 2013)
SPDLOG_API size_t _thread_id() SPDLOG_NOEXCEPT;
// Return current thread id as size_t (from thread local storage)
inline size_t thread_id()
{
#if defined(SPDLOG_DISABLE_TID_CACHING) || (defined(_MSC_VER) && (_MSC_VER < 1900)) || (defined(__clang__) && !__has_feature(cxx_thread_local))
return _thread_id();
#else // cache thread id in tls
static thread_local const size_t tid = _thread_id();
return tid;
#endif
SPDLOG_API size_t thread_id() SPDLOG_NOEXCEPT;
// This is avoid msvc issue in sleep_for that happens if the clock changes.
// See https://github.com/gabime/spdlog/issues/609
SPDLOG_API void sleep_for_millis(unsigned int milliseconds) SPDLOG_NOEXCEPT;
}
// wchar support for windows file names (SPDLOG_WCHAR_FILENAMES must be defined)
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
#define SPDLOG_FILENAME_T(s) L ## s
inline std::string filename_to_str(const filename_t& filename)
{
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> c;
return c.to_bytes(filename);
}
#else
#define SPDLOG_FILENAME_T(s) s
inline std::string filename_to_str(const filename_t& filename)
{
return filename;
}
#endif
inline std::string errno_to_string(char[256], char* res)
{
return std::string(res);
}
inline std::string errno_to_string(char buf[256], int res)
{
if (res == 0)
{
return std::string(buf);
}
else
{
return "Unknown error";
}
}
// Return errno string (thread safe)
inline std::string errno_str(int err_num)
{
char buf[256];
SPDLOG_CONSTEXPR auto buf_size = sizeof(buf);
#ifdef _WIN32
if (strerror_s(buf, buf_size, err_num) == 0)
return std::string(buf);
else
return "Unknown error";
#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(ANDROID) || defined(__SUNPRO_CC) || \
((_POSIX_C_SOURCE >= 200112L) && ! defined(_GNU_SOURCE)) // posix version
if (strerror_r(err_num, buf, buf_size) == 0)
return std::string(buf);
else
return "Unknown error";
#else // gnu version (might not use the given buf, so its retval pointer must be used)
auto err = strerror_r(err_num, buf, buf_size); // let compiler choose type
return errno_to_string(buf, err); // use overloading to select correct stringify function
#endif
}
inline int pid()
{
#ifdef _WIN32
return ::_getpid();
#else
return static_cast<int>(::getpid());
#endif
}
SPDLOG_API std::string filename_to_str(const filename_t &filename);
SPDLOG_API int pid() SPDLOG_NOEXCEPT;
// Determine if the terminal supports colors
// Source: https://github.com/agauniyal/rang/
inline bool is_color_terminal()
{
#ifdef _WIN32
return true;
#else
static constexpr const char* Terms[] =
{
"ansi", "color", "console", "cygwin", "gnome", "konsole", "kterm",
"linux", "msys", "putty", "rxvt", "screen", "vt100", "xterm"
};
SPDLOG_API bool is_color_terminal() SPDLOG_NOEXCEPT;
const char *env_p = std::getenv("TERM");
if (env_p == nullptr)
{
return false;
}
static const bool result = std::any_of(
std::begin(Terms), std::end(Terms), [&](const char* term)
{
return std::strstr(env_p, term) != nullptr;
});
return result;
#endif
}
// Detrmine if the terminal attached
// Determine if the terminal attached
// Source: https://github.com/agauniyal/rang/
inline bool in_terminal(FILE* file)
{
SPDLOG_API bool in_terminal(FILE *file) SPDLOG_NOEXCEPT;
#ifdef _WIN32
return _isatty(_fileno(file)) ? true : false;
#else
return isatty(fileno(file)) ? true : false;
#if (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) && defined(_WIN32)
SPDLOG_API void wstr_to_utf8buf(wstring_view_t wstr, memory_buf_t &target);
SPDLOG_API void utf8_to_wstrbuf(string_view_t str, wmemory_buf_t &target);
#endif
// Return directory name from given path or empty string
// "abc/file" => "abc"
// "abc/" => "abc"
// "abc" => ""
// "abc///" => "abc//"
SPDLOG_API filename_t dir_name(const filename_t &path);
// Create a dir from the given path.
// Return true if succeeded or if this dir already exists.
SPDLOG_API bool create_dir(const filename_t &path);
// non thread safe, cross platform getenv/getenv_s
// return empty string if field not found
SPDLOG_API std::string getenv(const char *field);
// Do fsync by FILE objectpointer.
// Return true on success.
SPDLOG_API bool fsync(FILE *fp);
// Do non-locking fwrite if possible by the os or use the regular locking fwrite
// Return true on success.
SPDLOG_API bool fwrite_bytes(const void *ptr, const size_t n_bytes, FILE *fp);
} // namespace os
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "os-inl.h"
#endif
}
} //os
} //details
} //spdlog

View File

@ -1,686 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
#include "../formatter.h"
#include "../details/log_msg.h"
#include "../details/os.h"
#include "../fmt/fmt.h"
#include <chrono>
#include <ctime>
#include <memory>
#include <mutex>
#include <string>
#include <thread>
#include <utility>
#include <vector>
#include <array>
namespace spdlog
{
namespace details
{
class flag_formatter
{
public:
virtual ~flag_formatter()
{}
virtual void format(details::log_msg& msg, const std::tm& tm_time) = 0;
};
///////////////////////////////////////////////////////////////////////
// name & level pattern appenders
///////////////////////////////////////////////////////////////////////
namespace
{
class name_formatter:public flag_formatter
{
void format(details::log_msg& msg, const std::tm&) override
{
msg.formatted << *msg.logger_name;
}
};
}
// log level appender
class level_formatter:public flag_formatter
{
void format(details::log_msg& msg, const std::tm&) override
{
msg.formatted << level::to_str(msg.level);
}
};
// short log level appender
class short_level_formatter:public flag_formatter
{
void format(details::log_msg& msg, const std::tm&) override
{
msg.formatted << level::to_short_str(msg.level);
}
};
///////////////////////////////////////////////////////////////////////
// Date time pattern appenders
///////////////////////////////////////////////////////////////////////
static const char* ampm(const tm& t)
{
return t.tm_hour >= 12 ? "PM" : "AM";
}
static int to12h(const tm& t)
{
return t.tm_hour > 12 ? t.tm_hour - 12 : t.tm_hour;
}
//Abbreviated weekday name
static const std::string days[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
class a_formatter:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
msg.formatted << days[tm_time.tm_wday];
}
};
//Full weekday name
static const std::string full_days[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
class A_formatter:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
msg.formatted << full_days[tm_time.tm_wday];
}
};
//Abbreviated month
static const std::string months[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" };
class b_formatter:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
msg.formatted << months[tm_time.tm_mon];
}
};
//Full month name
static const std::string full_months[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
class B_formatter:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
msg.formatted << full_months[tm_time.tm_mon];
}
};
//write 2 ints separated by sep with padding of 2
static fmt::MemoryWriter& pad_n_join(fmt::MemoryWriter& w, int v1, int v2, char sep)
{
w << fmt::pad(v1, 2, '0') << sep << fmt::pad(v2, 2, '0');
return w;
}
//write 3 ints separated by sep with padding of 2
static fmt::MemoryWriter& pad_n_join(fmt::MemoryWriter& w, int v1, int v2, int v3, char sep)
{
w << fmt::pad(v1, 2, '0') << sep << fmt::pad(v2, 2, '0') << sep << fmt::pad(v3, 2, '0');
return w;
}
//Date and time representation (Thu Aug 23 15:35:46 2014)
class c_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
msg.formatted << days[tm_time.tm_wday] << ' ' << months[tm_time.tm_mon] << ' ' << tm_time.tm_mday << ' ';
pad_n_join(msg.formatted, tm_time.tm_hour, tm_time.tm_min, tm_time.tm_sec, ':') << ' ' << tm_time.tm_year + 1900;
}
};
// year - 2 digit
class C_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
msg.formatted << fmt::pad(tm_time.tm_year % 100, 2, '0');
}
};
// Short MM/DD/YY date, equivalent to %m/%d/%y 08/23/01
class D_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
pad_n_join(msg.formatted, tm_time.tm_mon + 1, tm_time.tm_mday, tm_time.tm_year % 100, '/');
}
};
// year - 4 digit
class Y_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
msg.formatted << tm_time.tm_year + 1900;
}
};
// month 1-12
class m_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
msg.formatted << fmt::pad(tm_time.tm_mon + 1, 2, '0');
}
};
// day of month 1-31
class d_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
msg.formatted << fmt::pad(tm_time.tm_mday, 2, '0');
}
};
// hours in 24 format 0-23
class H_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
msg.formatted << fmt::pad(tm_time.tm_hour, 2, '0');
}
};
// hours in 12 format 1-12
class I_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
msg.formatted << fmt::pad(to12h(tm_time), 2, '0');
}
};
// minutes 0-59
class M_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
msg.formatted << fmt::pad(tm_time.tm_min, 2, '0');
}
};
// seconds 0-59
class S_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
msg.formatted << fmt::pad(tm_time.tm_sec, 2, '0');
}
};
// milliseconds
class e_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm&) override
{
auto duration = msg.time.time_since_epoch();
auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count() % 1000;
msg.formatted << fmt::pad(static_cast<int>(millis), 3, '0');
}
};
// microseconds
class f_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm&) override
{
auto duration = msg.time.time_since_epoch();
auto micros = std::chrono::duration_cast<std::chrono::microseconds>(duration).count() % 1000000;
msg.formatted << fmt::pad(static_cast<int>(micros), 6, '0');
}
};
// nanoseconds
class F_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm&) override
{
auto duration = msg.time.time_since_epoch();
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration).count() % 1000000000;
msg.formatted << fmt::pad(static_cast<int>(ns), 9, '0');
}
};
class E_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm&) override
{
auto duration = msg.time.time_since_epoch();
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(duration).count();
msg.formatted << seconds;
}
};
// AM/PM
class p_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
msg.formatted << ampm(tm_time);
}
};
// 12 hour clock 02:55:02 pm
class r_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
pad_n_join(msg.formatted, to12h(tm_time), tm_time.tm_min, tm_time.tm_sec, ':') << ' ' << ampm(tm_time);
}
};
// 24-hour HH:MM time, equivalent to %H:%M
class R_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
pad_n_join(msg.formatted, tm_time.tm_hour, tm_time.tm_min, ':');
}
};
// ISO 8601 time format (HH:MM:SS), equivalent to %H:%M:%S
class T_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
pad_n_join(msg.formatted, tm_time.tm_hour, tm_time.tm_min, tm_time.tm_sec, ':');
}
};
// ISO 8601 offset from UTC in timezone (+-HH:MM)
class z_formatter SPDLOG_FINAL:public flag_formatter
{
public:
const std::chrono::seconds cache_refresh = std::chrono::seconds(5);
z_formatter():_last_update(std::chrono::seconds(0)), _offset_minutes(0)
{}
z_formatter(const z_formatter&) = delete;
z_formatter& operator=(const z_formatter&) = delete;
void format(details::log_msg& msg, const std::tm& tm_time) override
{
#ifdef _WIN32
int total_minutes = get_cached_offset(msg, tm_time);
#else
// No need to chache under gcc,
// it is very fast (already stored in tm.tm_gmtoff)
int total_minutes = os::utc_minutes_offset(tm_time);
#endif
bool is_negative = total_minutes < 0;
char sign;
if (is_negative)
{
total_minutes = -total_minutes;
sign = '-';
}
else
{
sign = '+';
}
int h = total_minutes / 60;
int m = total_minutes % 60;
msg.formatted << sign;
pad_n_join(msg.formatted, h, m, ':');
}
private:
log_clock::time_point _last_update;
int _offset_minutes;
std::mutex _mutex;
int get_cached_offset(const log_msg& msg, const std::tm& tm_time)
{
using namespace std::chrono;
std::lock_guard<std::mutex> l(_mutex);
if (msg.time - _last_update >= cache_refresh)
{
_offset_minutes = os::utc_minutes_offset(tm_time);
_last_update = msg.time;
}
return _offset_minutes;
}
};
// Thread id
class t_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm&) override
{
msg.formatted << msg.thread_id;
}
};
// Current pid
class pid_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm&) override
{
msg.formatted << details::os::pid();
}
};
// message counter formatter
class i_formatter SPDLOG_FINAL :public flag_formatter
{
void format(details::log_msg& msg, const std::tm&) override
{
msg.formatted << fmt::pad(msg.msg_id, 6, '0');
}
};
class v_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm&) override
{
msg.formatted << fmt::StringRef(msg.raw.data(), msg.raw.size());
}
};
class ch_formatter SPDLOG_FINAL:public flag_formatter
{
public:
explicit ch_formatter(char ch): _ch(ch)
{}
void format(details::log_msg& msg, const std::tm&) override
{
msg.formatted << _ch;
}
private:
char _ch;
};
//aggregate user chars to display as is
class aggregate_formatter SPDLOG_FINAL:public flag_formatter
{
public:
aggregate_formatter()
{}
void add_ch(char ch)
{
_str += ch;
}
void format(details::log_msg& msg, const std::tm&) override
{
msg.formatted << _str;
}
private:
std::string _str;
};
// Full info formatter
// pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] %v
class full_formatter SPDLOG_FINAL:public flag_formatter
{
void format(details::log_msg& msg, const std::tm& tm_time) override
{
#ifndef SPDLOG_NO_DATETIME
auto duration = msg.time.time_since_epoch();
auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count() % 1000;
/* Slower version(while still very fast - about 3.2 million lines/sec under 10 threads),
msg.formatted.write("[{:d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.{:03d}] [{}] [{}] {} ",
tm_time.tm_year + 1900,
tm_time.tm_mon + 1,
tm_time.tm_mday,
tm_time.tm_hour,
tm_time.tm_min,
tm_time.tm_sec,
static_cast<int>(millis),
msg.logger_name,
level::to_str(msg.level),
msg.raw.str());*/
// Faster (albeit uglier) way to format the line (5.6 million lines/sec under 10 threads)
msg.formatted << '[' << static_cast<unsigned int>(tm_time.tm_year + 1900) << '-'
<< fmt::pad(static_cast<unsigned int>(tm_time.tm_mon + 1), 2, '0') << '-'
<< fmt::pad(static_cast<unsigned int>(tm_time.tm_mday), 2, '0') << ' '
<< fmt::pad(static_cast<unsigned int>(tm_time.tm_hour), 2, '0') << ':'
<< fmt::pad(static_cast<unsigned int>(tm_time.tm_min), 2, '0') << ':'
<< fmt::pad(static_cast<unsigned int>(tm_time.tm_sec), 2, '0') << '.'
<< fmt::pad(static_cast<unsigned int>(millis), 3, '0') << "] ";
//no datetime needed
#else
(void)tm_time;
#endif
#ifndef SPDLOG_NO_NAME
msg.formatted << '[' << *msg.logger_name << "] ";
#endif
msg.formatted << '[' << level::to_str(msg.level) << "] ";
msg.formatted << fmt::StringRef(msg.raw.data(), msg.raw.size());
}
};
}
}
///////////////////////////////////////////////////////////////////////////////
// pattern_formatter inline impl
///////////////////////////////////////////////////////////////////////////////
inline spdlog::pattern_formatter::pattern_formatter(const std::string& pattern, pattern_time_type pattern_time)
: _pattern_time(pattern_time)
{
compile_pattern(pattern);
}
inline void spdlog::pattern_formatter::compile_pattern(const std::string& pattern)
{
auto end = pattern.end();
std::unique_ptr<details::aggregate_formatter> user_chars;
for (auto it = pattern.begin(); it != end; ++it)
{
if (*it == '%')
{
if (user_chars) //append user chars found so far
_formatters.push_back(std::move(user_chars));
if (++it != end)
handle_flag(*it);
else
break;
}
else // chars not following the % sign should be displayed as is
{
if (!user_chars)
user_chars = std::unique_ptr<details::aggregate_formatter>(new details::aggregate_formatter());
user_chars->add_ch(*it);
}
}
if (user_chars) //append raw chars found so far
{
_formatters.push_back(std::move(user_chars));
}
}
inline void spdlog::pattern_formatter::handle_flag(char flag)
{
switch (flag)
{
// logger name
case 'n':
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::name_formatter()));
break;
case 'l':
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::level_formatter()));
break;
case 'L':
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::short_level_formatter()));
break;
case('t'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::t_formatter()));
break;
case('v'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::v_formatter()));
break;
case('a'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::a_formatter()));
break;
case('A'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::A_formatter()));
break;
case('b'):
case('h'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::b_formatter()));
break;
case('B'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::B_formatter()));
break;
case('c'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::c_formatter()));
break;
case('C'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::C_formatter()));
break;
case('Y'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::Y_formatter()));
break;
case('D'):
case('x'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::D_formatter()));
break;
case('m'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::m_formatter()));
break;
case('d'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::d_formatter()));
break;
case('H'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::H_formatter()));
break;
case('I'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::I_formatter()));
break;
case('M'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::M_formatter()));
break;
case('S'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::S_formatter()));
break;
case('e'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::e_formatter()));
break;
case('f'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::f_formatter()));
break;
case('F'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::F_formatter()));
break;
case('E'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::E_formatter()));
break;
case('p'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::p_formatter()));
break;
case('r'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::r_formatter()));
break;
case('R'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::R_formatter()));
break;
case('T'):
case('X'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::T_formatter()));
break;
case('z'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::z_formatter()));
break;
case ('+'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::full_formatter()));
break;
case ('P'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::pid_formatter()));
break;
case ('i'):
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::i_formatter()));
break;
default: //Unknown flag appears as is
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::ch_formatter('%')));
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::ch_formatter(flag)));
break;
}
}
inline std::tm spdlog::pattern_formatter::get_time(details::log_msg& msg)
{
if (_pattern_time == pattern_time_type::local)
return details::os::localtime(log_clock::to_time_t(msg.time));
else
return details::os::gmtime(log_clock::to_time_t(msg.time));
}
inline void spdlog::pattern_formatter::format(details::log_msg& msg)
{
#ifndef SPDLOG_NO_DATETIME
auto tm_time = get_time(msg);
#else
std::tm tm_time;
#endif
for (auto &f : _formatters)
{
f->format(msg, tm_time);
}
//write eol
msg.formatted.write(details::os::eol, details::os::eol_size);
}

View File

@ -0,0 +1,26 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/details/periodic_worker.h>
#endif
namespace spdlog {
namespace details {
// stop the worker thread and join it
SPDLOG_INLINE periodic_worker::~periodic_worker() {
if (worker_thread_.joinable()) {
{
std::lock_guard<std::mutex> lock(mutex_);
active_ = false;
}
cv_.notify_one();
worker_thread_.join();
}
}
} // namespace details
} // namespace spdlog

View File

@ -0,0 +1,58 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
// periodic worker thread - periodically executes the given callback function.
//
// RAII over the owned thread:
// creates the thread on construction.
// stops and joins the thread on destruction (if the thread is executing a callback, wait for it
// to finish first).
#include <chrono>
#include <condition_variable>
#include <functional>
#include <mutex>
#include <thread>
namespace spdlog {
namespace details {
class SPDLOG_API periodic_worker {
public:
template <typename Rep, typename Period>
periodic_worker(const std::function<void()> &callback_fun,
std::chrono::duration<Rep, Period> interval) {
active_ = (interval > std::chrono::duration<Rep, Period>::zero());
if (!active_) {
return;
}
worker_thread_ = std::thread([this, callback_fun, interval]() {
for (;;) {
std::unique_lock<std::mutex> lock(this->mutex_);
if (this->cv_.wait_for(lock, interval, [this] { return !this->active_; })) {
return; // active_ == false, so exit this thread
}
callback_fun();
}
});
}
std::thread &get_thread() { return worker_thread_; }
periodic_worker(const periodic_worker &) = delete;
periodic_worker &operator=(const periodic_worker &) = delete;
// stop the worker thread and join it
~periodic_worker();
private:
bool active_;
std::thread worker_thread_;
std::mutex mutex_;
std::condition_variable cv_;
};
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "periodic_worker-inl.h"
#endif

View File

@ -0,0 +1,261 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/details/registry.h>
#endif
#include <spdlog/common.h>
#include <spdlog/details/periodic_worker.h>
#include <spdlog/logger.h>
#include <spdlog/pattern_formatter.h>
#ifndef SPDLOG_DISABLE_DEFAULT_LOGGER
// support for the default stdout color logger
#ifdef _WIN32
#include <spdlog/sinks/wincolor_sink.h>
#else
#include <spdlog/sinks/ansicolor_sink.h>
#endif
#endif // SPDLOG_DISABLE_DEFAULT_LOGGER
#include <chrono>
#include <functional>
#include <memory>
#include <string>
#include <unordered_map>
namespace spdlog {
namespace details {
SPDLOG_INLINE registry::registry()
: formatter_(new pattern_formatter()) {
#ifndef SPDLOG_DISABLE_DEFAULT_LOGGER
// create default logger (ansicolor_stdout_sink_mt or wincolor_stdout_sink_mt in windows).
#ifdef _WIN32
auto color_sink = std::make_shared<sinks::wincolor_stdout_sink_mt>();
#else
auto color_sink = std::make_shared<sinks::ansicolor_stdout_sink_mt>();
#endif
const char *default_logger_name = "";
default_logger_ = std::make_shared<spdlog::logger>(default_logger_name, std::move(color_sink));
loggers_[default_logger_name] = default_logger_;
#endif // SPDLOG_DISABLE_DEFAULT_LOGGER
}
SPDLOG_INLINE registry::~registry() = default;
SPDLOG_INLINE void registry::register_logger(std::shared_ptr<logger> new_logger) {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
register_logger_(std::move(new_logger));
}
SPDLOG_INLINE void registry::initialize_logger(std::shared_ptr<logger> new_logger) {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
new_logger->set_formatter(formatter_->clone());
if (err_handler_) {
new_logger->set_error_handler(err_handler_);
}
// set new level according to previously configured level or default level
auto it = log_levels_.find(new_logger->name());
auto new_level = it != log_levels_.end() ? it->second : global_log_level_;
new_logger->set_level(new_level);
new_logger->flush_on(flush_level_);
if (backtrace_n_messages_ > 0) {
new_logger->enable_backtrace(backtrace_n_messages_);
}
if (automatic_registration_) {
register_logger_(std::move(new_logger));
}
}
SPDLOG_INLINE std::shared_ptr<logger> registry::get(const std::string &logger_name) {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
auto found = loggers_.find(logger_name);
return found == loggers_.end() ? nullptr : found->second;
}
SPDLOG_INLINE std::shared_ptr<logger> registry::default_logger() {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
return default_logger_;
}
// Return raw ptr to the default logger.
// To be used directly by the spdlog default api (e.g. spdlog::info)
// This make the default API faster, but cannot be used concurrently with set_default_logger().
// e.g do not call set_default_logger() from one thread while calling spdlog::info() from another.
SPDLOG_INLINE logger *registry::get_default_raw() { return default_logger_.get(); }
// set default logger.
// default logger is stored in default_logger_ (for faster retrieval) and in the loggers_ map.
SPDLOG_INLINE void registry::set_default_logger(std::shared_ptr<logger> new_default_logger) {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
if (new_default_logger != nullptr) {
loggers_[new_default_logger->name()] = new_default_logger;
}
default_logger_ = std::move(new_default_logger);
}
SPDLOG_INLINE void registry::set_tp(std::shared_ptr<thread_pool> tp) {
std::lock_guard<std::recursive_mutex> lock(tp_mutex_);
tp_ = std::move(tp);
}
SPDLOG_INLINE std::shared_ptr<thread_pool> registry::get_tp() {
std::lock_guard<std::recursive_mutex> lock(tp_mutex_);
return tp_;
}
// Set global formatter. Each sink in each logger will get a clone of this object
SPDLOG_INLINE void registry::set_formatter(std::unique_ptr<formatter> formatter) {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
formatter_ = std::move(formatter);
for (auto &l : loggers_) {
l.second->set_formatter(formatter_->clone());
}
}
SPDLOG_INLINE void registry::enable_backtrace(size_t n_messages) {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
backtrace_n_messages_ = n_messages;
for (auto &l : loggers_) {
l.second->enable_backtrace(n_messages);
}
}
SPDLOG_INLINE void registry::disable_backtrace() {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
backtrace_n_messages_ = 0;
for (auto &l : loggers_) {
l.second->disable_backtrace();
}
}
SPDLOG_INLINE void registry::set_level(level::level_enum log_level) {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
for (auto &l : loggers_) {
l.second->set_level(log_level);
}
global_log_level_ = log_level;
}
SPDLOG_INLINE void registry::flush_on(level::level_enum log_level) {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
for (auto &l : loggers_) {
l.second->flush_on(log_level);
}
flush_level_ = log_level;
}
SPDLOG_INLINE void registry::set_error_handler(err_handler handler) {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
for (auto &l : loggers_) {
l.second->set_error_handler(handler);
}
err_handler_ = std::move(handler);
}
SPDLOG_INLINE void registry::apply_all(
const std::function<void(const std::shared_ptr<logger>)> &fun) {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
for (auto &l : loggers_) {
fun(l.second);
}
}
SPDLOG_INLINE void registry::flush_all() {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
for (auto &l : loggers_) {
l.second->flush();
}
}
SPDLOG_INLINE void registry::drop(const std::string &logger_name) {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
auto is_default_logger = default_logger_ && default_logger_->name() == logger_name;
loggers_.erase(logger_name);
if (is_default_logger) {
default_logger_.reset();
}
}
SPDLOG_INLINE void registry::drop_all() {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
loggers_.clear();
default_logger_.reset();
}
// clean all resources and threads started by the registry
SPDLOG_INLINE void registry::shutdown() {
{
std::lock_guard<std::mutex> lock(flusher_mutex_);
periodic_flusher_.reset();
}
drop_all();
{
std::lock_guard<std::recursive_mutex> lock(tp_mutex_);
tp_.reset();
}
}
SPDLOG_INLINE std::recursive_mutex &registry::tp_mutex() { return tp_mutex_; }
SPDLOG_INLINE void registry::set_automatic_registration(bool automatic_registration) {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
automatic_registration_ = automatic_registration;
}
SPDLOG_INLINE void registry::set_levels(log_levels levels, level::level_enum *global_level) {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
log_levels_ = std::move(levels);
auto global_level_requested = global_level != nullptr;
global_log_level_ = global_level_requested ? *global_level : global_log_level_;
for (auto &logger : loggers_) {
auto logger_entry = log_levels_.find(logger.first);
if (logger_entry != log_levels_.end()) {
logger.second->set_level(logger_entry->second);
} else if (global_level_requested) {
logger.second->set_level(*global_level);
}
}
}
SPDLOG_INLINE registry &registry::instance() {
static registry s_instance;
return s_instance;
}
SPDLOG_INLINE void registry::apply_logger_env_levels(std::shared_ptr<logger> new_logger) {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
auto it = log_levels_.find(new_logger->name());
auto new_level = it != log_levels_.end() ? it->second : global_log_level_;
new_logger->set_level(new_level);
}
SPDLOG_INLINE void registry::throw_if_exists_(const std::string &logger_name) {
if (loggers_.find(logger_name) != loggers_.end()) {
throw_spdlog_ex("logger with name '" + logger_name + "' already exists");
}
}
SPDLOG_INLINE void registry::register_logger_(std::shared_ptr<logger> new_logger) {
auto logger_name = new_logger->name();
throw_if_exists_(logger_name);
loggers_[logger_name] = std::move(new_logger);
}
} // namespace details
} // namespace spdlog

View File

@ -1,19 +1,15 @@
//
// Copyright(c) 2015 Gabi Melman.
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
// Loggers registy of unique name->logger pointer
// An attempt to create a logger with an already existing name will be ignored
// Loggers registry of unique name->logger pointer
// An attempt to create a logger with an already existing name will result with spdlog_ex exception.
// If user requests a non existing logger, nullptr will be returned
// This class is thread safe
#include "../details/null_mutex.h"
#include "../logger.h"
#include "../async_logger.h"
#include "../common.h"
#include <spdlog/common.h>
#include <spdlog/details/periodic_worker.h>
#include <chrono>
#include <functional>
@ -22,193 +18,112 @@
#include <string>
#include <unordered_map>
namespace spdlog
{
namespace details
{
template <class Mutex> class registry_t
{
namespace spdlog {
class logger;
namespace details {
class thread_pool;
class SPDLOG_API registry {
public:
using log_levels = std::unordered_map<std::string, level::level_enum>;
registry(const registry &) = delete;
registry &operator=(const registry &) = delete;
void register_logger(std::shared_ptr<logger> logger)
{
std::lock_guard<Mutex> lock(_mutex);
auto logger_name = logger->name();
throw_if_exists(logger_name);
_loggers[logger_name] = logger;
void register_logger(std::shared_ptr<logger> new_logger);
void initialize_logger(std::shared_ptr<logger> new_logger);
std::shared_ptr<logger> get(const std::string &logger_name);
std::shared_ptr<logger> default_logger();
// Return raw ptr to the default logger.
// To be used directly by the spdlog default api (e.g. spdlog::info)
// This make the default API faster, but cannot be used concurrently with set_default_logger().
// e.g do not call set_default_logger() from one thread while calling spdlog::info() from
// another.
logger *get_default_raw();
// set default logger and add it to the registry if not registered already.
// default logger is stored in default_logger_ (for faster retrieval) and in the loggers_ map.
// Note: Make sure to unregister it when no longer needed or before calling again with a new
// logger.
void set_default_logger(std::shared_ptr<logger> new_default_logger);
void set_tp(std::shared_ptr<thread_pool> tp);
std::shared_ptr<thread_pool> get_tp();
// Set global formatter. Each sink in each logger will get a clone of this object
void set_formatter(std::unique_ptr<formatter> formatter);
void enable_backtrace(size_t n_messages);
void disable_backtrace();
void set_level(level::level_enum log_level);
void flush_on(level::level_enum log_level);
template <typename Rep, typename Period>
void flush_every(std::chrono::duration<Rep, Period> interval) {
std::lock_guard<std::mutex> lock(flusher_mutex_);
auto clbk = [this]() { this->flush_all(); };
periodic_flusher_ = details::make_unique<periodic_worker>(clbk, interval);
}
std::shared_ptr<logger> get(const std::string& logger_name)
{
std::lock_guard<Mutex> lock(_mutex);
auto found = _loggers.find(logger_name);
return found == _loggers.end() ? nullptr : found->second;
std::unique_ptr<periodic_worker> &get_flusher() {
std::lock_guard<std::mutex> lock(flusher_mutex_);
return periodic_flusher_;
}
template<class It>
std::shared_ptr<logger> create(const std::string& logger_name, const It& sinks_begin, const It& sinks_end)
{
std::lock_guard<Mutex> lock(_mutex);
throw_if_exists(logger_name);
std::shared_ptr<logger> new_logger;
if (_async_mode)
new_logger = std::make_shared<async_logger>(logger_name, sinks_begin, sinks_end, _async_q_size, _overflow_policy, _worker_warmup_cb, _flush_interval_ms, _worker_teardown_cb);
else
new_logger = std::make_shared<logger>(logger_name, sinks_begin, sinks_end);
void set_error_handler(err_handler handler);
if (_formatter)
new_logger->set_formatter(_formatter);
void apply_all(const std::function<void(const std::shared_ptr<logger>)> &fun);
if (_err_handler)
new_logger->set_error_handler(_err_handler);
void flush_all();
new_logger->set_level(_level);
void drop(const std::string &logger_name);
void drop_all();
//Add to registry
_loggers[logger_name] = new_logger;
return new_logger;
}
// clean all resources and threads started by the registry
void shutdown();
template<class It>
std::shared_ptr<async_logger> create_async(const std::string& logger_name, size_t queue_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb, const It& sinks_begin, const It& sinks_end)
{
std::lock_guard<Mutex> lock(_mutex);
throw_if_exists(logger_name);
auto new_logger = std::make_shared<async_logger>(logger_name, sinks_begin, sinks_end, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb);
std::recursive_mutex &tp_mutex();
if (_formatter)
new_logger->set_formatter(_formatter);
void set_automatic_registration(bool automatic_registration);
if (_err_handler)
new_logger->set_error_handler(_err_handler);
// set levels for all existing/future loggers. global_level can be null if should not set.
void set_levels(log_levels levels, level::level_enum *global_level);
new_logger->set_level(_level);
static registry &instance();
//Add to registry
_loggers[logger_name] = new_logger;
return new_logger;
}
void apply_all(std::function<void(std::shared_ptr<logger>)> fun)
{
std::lock_guard<Mutex> lock(_mutex);
for (auto &l : _loggers)
fun(l.second);
}
void drop(const std::string& logger_name)
{
std::lock_guard<Mutex> lock(_mutex);
_loggers.erase(logger_name);
}
void drop_all()
{
std::lock_guard<Mutex> lock(_mutex);
_loggers.clear();
}
std::shared_ptr<logger> create(const std::string& logger_name, sinks_init_list sinks)
{
return create(logger_name, sinks.begin(), sinks.end());
}
std::shared_ptr<logger> create(const std::string& logger_name, sink_ptr sink)
{
return create(logger_name, { sink });
}
std::shared_ptr<async_logger> create_async(const std::string& logger_name, size_t queue_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb, sinks_init_list sinks)
{
return create_async(logger_name, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb, sinks.begin(), sinks.end());
}
std::shared_ptr<async_logger> create_async(const std::string& logger_name, size_t queue_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb, sink_ptr sink)
{
return create_async(logger_name, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb, { sink });
}
void formatter(formatter_ptr f)
{
std::lock_guard<Mutex> lock(_mutex);
_formatter = f;
for (auto& l : _loggers)
l.second->set_formatter(_formatter);
}
void set_pattern(const std::string& pattern)
{
std::lock_guard<Mutex> lock(_mutex);
_formatter = std::make_shared<pattern_formatter>(pattern);
for (auto& l : _loggers)
l.second->set_formatter(_formatter);
}
void set_level(level::level_enum log_level)
{
std::lock_guard<Mutex> lock(_mutex);
for (auto& l : _loggers)
l.second->set_level(log_level);
_level = log_level;
}
void set_error_handler(log_err_handler handler)
{
for (auto& l : _loggers)
l.second->set_error_handler(handler);
_err_handler = handler;
}
void set_async_mode(size_t q_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb)
{
std::lock_guard<Mutex> lock(_mutex);
_async_mode = true;
_async_q_size = q_size;
_overflow_policy = overflow_policy;
_worker_warmup_cb = worker_warmup_cb;
_flush_interval_ms = flush_interval_ms;
_worker_teardown_cb = worker_teardown_cb;
}
void set_sync_mode()
{
std::lock_guard<Mutex> lock(_mutex);
_async_mode = false;
}
static registry_t<Mutex>& instance()
{
static registry_t<Mutex> s_instance;
return s_instance;
}
void apply_logger_env_levels(std::shared_ptr<logger> new_logger);
private:
registry_t<Mutex>() {}
registry_t<Mutex>(const registry_t<Mutex>&) = delete;
registry_t<Mutex>& operator=(const registry_t<Mutex>&) = delete;
registry();
~registry();
void throw_if_exists(const std::string &logger_name)
{
if (_loggers.find(logger_name) != _loggers.end())
throw spdlog_ex("logger with name '" + logger_name + "' already exists");
}
Mutex _mutex;
std::unordered_map <std::string, std::shared_ptr<logger>> _loggers;
formatter_ptr _formatter;
level::level_enum _level = level::info;
log_err_handler _err_handler;
bool _async_mode = false;
size_t _async_q_size = 0;
async_overflow_policy _overflow_policy = async_overflow_policy::block_retry;
std::function<void()> _worker_warmup_cb = nullptr;
std::chrono::milliseconds _flush_interval_ms;
std::function<void()> _worker_teardown_cb = nullptr;
void throw_if_exists_(const std::string &logger_name);
void register_logger_(std::shared_ptr<logger> new_logger);
bool set_level_from_cfg_(logger *logger);
std::mutex logger_map_mutex_, flusher_mutex_;
std::recursive_mutex tp_mutex_;
std::unordered_map<std::string, std::shared_ptr<logger>> loggers_;
log_levels log_levels_;
std::unique_ptr<formatter> formatter_;
spdlog::level::level_enum global_log_level_ = level::info;
level::level_enum flush_level_ = level::off;
err_handler err_handler_;
std::shared_ptr<thread_pool> tp_;
std::unique_ptr<periodic_worker> periodic_flusher_;
std::shared_ptr<logger> default_logger_;
bool automatic_registration_ = true;
size_t backtrace_n_messages_ = 0;
};
#ifdef SPDLOG_NO_REGISTRY_MUTEX
typedef registry_t<spdlog::details::null_mutex> registry;
#else
typedef registry_t<std::mutex> registry;
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "registry-inl.h"
#endif
}
}

View File

@ -1,263 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
//
// Global registry functions
//
#include "../spdlog.h"
#include "../details/registry.h"
#include "../sinks/file_sinks.h"
#include "../sinks/stdout_sinks.h"
#ifdef SPDLOG_ENABLE_SYSLOG
#include "../sinks/syslog_sink.h"
#endif
#ifdef _WIN32
#include "../sinks/wincolor_sink.h"
#else
#include "../sinks/ansicolor_sink.h"
#endif
#ifdef __ANDROID__
#include "../sinks/android_sink.h"
#endif
#include <chrono>
#include <functional>
#include <memory>
#include <string>
inline void spdlog::register_logger(std::shared_ptr<logger> logger)
{
return details::registry::instance().register_logger(logger);
}
inline std::shared_ptr<spdlog::logger> spdlog::get(const std::string& name)
{
return details::registry::instance().get(name);
}
inline void spdlog::drop(const std::string &name)
{
details::registry::instance().drop(name);
}
// Create multi/single threaded simple file logger
inline std::shared_ptr<spdlog::logger> spdlog::basic_logger_mt(const std::string& logger_name, const filename_t& filename, bool truncate)
{
return create<spdlog::sinks::simple_file_sink_mt>(logger_name, filename, truncate);
}
inline std::shared_ptr<spdlog::logger> spdlog::basic_logger_st(const std::string& logger_name, const filename_t& filename, bool truncate)
{
return create<spdlog::sinks::simple_file_sink_st>(logger_name, filename, truncate);
}
// Create multi/single threaded rotating file logger
inline std::shared_ptr<spdlog::logger> spdlog::rotating_logger_mt(const std::string& logger_name, const filename_t& filename, size_t max_file_size, size_t max_files)
{
return create<spdlog::sinks::rotating_file_sink_mt>(logger_name, filename, max_file_size, max_files);
}
inline std::shared_ptr<spdlog::logger> spdlog::rotating_logger_st(const std::string& logger_name, const filename_t& filename, size_t max_file_size, size_t max_files)
{
return create<spdlog::sinks::rotating_file_sink_st>(logger_name, filename, max_file_size, max_files);
}
// Create file logger which creates new file at midnight):
inline std::shared_ptr<spdlog::logger> spdlog::daily_logger_mt(const std::string& logger_name, const filename_t& filename, int hour, int minute)
{
return create<spdlog::sinks::daily_file_sink_mt>(logger_name, filename, hour, minute);
}
inline std::shared_ptr<spdlog::logger> spdlog::daily_logger_st(const std::string& logger_name, const filename_t& filename, int hour, int minute)
{
return create<spdlog::sinks::daily_file_sink_st>(logger_name, filename, hour, minute);
}
//
// stdout/stderr loggers
//
inline std::shared_ptr<spdlog::logger> spdlog::stdout_logger_mt(const std::string& logger_name)
{
return spdlog::details::registry::instance().create(logger_name, spdlog::sinks::stdout_sink_mt::instance());
}
inline std::shared_ptr<spdlog::logger> spdlog::stdout_logger_st(const std::string& logger_name)
{
return spdlog::details::registry::instance().create(logger_name, spdlog::sinks::stdout_sink_st::instance());
}
inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_mt(const std::string& logger_name)
{
return spdlog::details::registry::instance().create(logger_name, spdlog::sinks::stderr_sink_mt::instance());
}
inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_st(const std::string& logger_name)
{
return spdlog::details::registry::instance().create(logger_name, spdlog::sinks::stderr_sink_st::instance());
}
//
// stdout/stderr color loggers
//
#ifdef _WIN32
inline std::shared_ptr<spdlog::logger> spdlog::stdout_color_mt(const std::string& logger_name)
{
auto sink = std::make_shared<spdlog::sinks::wincolor_stdout_sink_mt>();
return spdlog::details::registry::instance().create(logger_name, sink);
}
inline std::shared_ptr<spdlog::logger> spdlog::stdout_color_st(const std::string& logger_name)
{
auto sink = std::make_shared<spdlog::sinks::wincolor_stdout_sink_st>();
return spdlog::details::registry::instance().create(logger_name, sink);
}
inline std::shared_ptr<spdlog::logger> spdlog::stderr_color_mt(const std::string& logger_name)
{
auto sink = std::make_shared<spdlog::sinks::wincolor_stderr_sink_mt>();
return spdlog::details::registry::instance().create(logger_name, sink);
}
inline std::shared_ptr<spdlog::logger> spdlog::stderr_color_st(const std::string& logger_name)
{
auto sink = std::make_shared<spdlog::sinks::wincolor_stderr_sink_st>();
return spdlog::details::registry::instance().create(logger_name, sink);
}
#else //ansi terminal colors
inline std::shared_ptr<spdlog::logger> spdlog::stdout_color_mt(const std::string& logger_name)
{
auto sink = std::make_shared<spdlog::sinks::ansicolor_stdout_sink_mt>();
return spdlog::details::registry::instance().create(logger_name, sink);
}
inline std::shared_ptr<spdlog::logger> spdlog::stdout_color_st(const std::string& logger_name)
{
auto sink = std::make_shared<spdlog::sinks::ansicolor_stdout_sink_st>();
return spdlog::details::registry::instance().create(logger_name, sink);
}
inline std::shared_ptr<spdlog::logger> spdlog::stderr_color_mt(const std::string& logger_name)
{
auto sink = std::make_shared<spdlog::sinks::ansicolor_stderr_sink_mt>();
return spdlog::details::registry::instance().create(logger_name, sink);
}
inline std::shared_ptr<spdlog::logger> spdlog::stderr_color_st(const std::string& logger_name)
{
auto sink = std::make_shared<spdlog::sinks::ansicolor_stderr_sink_st>();
return spdlog::details::registry::instance().create(logger_name, sink);
}
#endif
#ifdef SPDLOG_ENABLE_SYSLOG
// Create syslog logger
inline std::shared_ptr<spdlog::logger> spdlog::syslog_logger(const std::string& logger_name, const std::string& syslog_ident, int syslog_option, int syslog_facility)
{
return create<spdlog::sinks::syslog_sink>(logger_name, syslog_ident, syslog_option, syslog_facility);
}
#endif
#ifdef __ANDROID__
inline std::shared_ptr<spdlog::logger> spdlog::android_logger(const std::string& logger_name, const std::string& tag)
{
return create<spdlog::sinks::android_sink>(logger_name, tag);
}
#endif
// Create and register a logger a single sink
inline std::shared_ptr<spdlog::logger> spdlog::create(const std::string& logger_name, const spdlog::sink_ptr& sink)
{
return details::registry::instance().create(logger_name, sink);
}
//Create logger with multiple sinks
inline std::shared_ptr<spdlog::logger> spdlog::create(const std::string& logger_name, spdlog::sinks_init_list sinks)
{
return details::registry::instance().create(logger_name, sinks);
}
template <typename Sink, typename... Args>
inline std::shared_ptr<spdlog::logger> spdlog::create(const std::string& logger_name, Args... args)
{
sink_ptr sink = std::make_shared<Sink>(args...);
return details::registry::instance().create(logger_name, { sink });
}
template<class It>
inline std::shared_ptr<spdlog::logger> spdlog::create(const std::string& logger_name, const It& sinks_begin, const It& sinks_end)
{
return details::registry::instance().create(logger_name, sinks_begin, sinks_end);
}
// Create and register an async logger with a single sink
inline std::shared_ptr<spdlog::logger> spdlog::create_async(const std::string& logger_name, const sink_ptr& sink, size_t queue_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb)
{
return details::registry::instance().create_async(logger_name, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb, sink);
}
// Create and register an async logger with multiple sinks
inline std::shared_ptr<spdlog::logger> spdlog::create_async(const std::string& logger_name, sinks_init_list sinks, size_t queue_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb )
{
return details::registry::instance().create_async(logger_name, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb, sinks);
}
template<class It>
inline std::shared_ptr<spdlog::logger> spdlog::create_async(const std::string& logger_name, const It& sinks_begin, const It& sinks_end, size_t queue_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb)
{
return details::registry::instance().create_async(logger_name, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb, sinks_begin, sinks_end);
}
inline void spdlog::set_formatter(spdlog::formatter_ptr f)
{
details::registry::instance().formatter(f);
}
inline void spdlog::set_pattern(const std::string& format_string)
{
return details::registry::instance().set_pattern(format_string);
}
inline void spdlog::set_level(level::level_enum log_level)
{
return details::registry::instance().set_level(log_level);
}
inline void spdlog::set_error_handler(log_err_handler handler)
{
return details::registry::instance().set_error_handler(handler);
}
inline void spdlog::set_async_mode(size_t queue_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb)
{
details::registry::instance().set_async_mode(queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb);
}
inline void spdlog::set_sync_mode()
{
details::registry::instance().set_sync_mode();
}
inline void spdlog::apply_all(std::function<void(std::shared_ptr<logger>)> fun)
{
details::registry::instance().apply_all(fun);
}
inline void spdlog::drop_all()
{
details::registry::instance().drop_all();
}

View File

@ -0,0 +1,22 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#include "registry.h"
namespace spdlog {
// Default logger factory- creates synchronous loggers
class logger;
struct synchronous_factory {
template <typename Sink, typename... SinkArgs>
static std::shared_ptr<spdlog::logger> create(std::string logger_name, SinkArgs &&...args) {
auto sink = std::make_shared<Sink>(std::forward<SinkArgs>(args)...);
auto new_logger = std::make_shared<spdlog::logger>(std::move(logger_name), std::move(sink));
details::registry::instance().initialize_logger(new_logger);
return new_logger;
}
};
} // namespace spdlog

View File

@ -0,0 +1,135 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#define WIN32_LEAN_AND_MEAN
// tcp client helper
#include <spdlog/common.h>
#include <spdlog/details/os.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#pragma comment(lib, "Ws2_32.lib")
#pragma comment(lib, "Mswsock.lib")
#pragma comment(lib, "AdvApi32.lib")
namespace spdlog {
namespace details {
class tcp_client {
SOCKET socket_ = INVALID_SOCKET;
static void init_winsock_() {
WSADATA wsaData;
auto rv = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (rv != 0) {
throw_winsock_error_("WSAStartup failed", ::WSAGetLastError());
}
}
static void throw_winsock_error_(const std::string &msg, int last_error) {
char buf[512];
::FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
last_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf,
(sizeof(buf) / sizeof(char)), NULL);
throw_spdlog_ex(fmt_lib::format("tcp_sink - {}: {}", msg, buf));
}
public:
tcp_client() { init_winsock_(); }
~tcp_client() {
close();
::WSACleanup();
}
bool is_connected() const { return socket_ != INVALID_SOCKET; }
void close() {
::closesocket(socket_);
socket_ = INVALID_SOCKET;
}
SOCKET fd() const { return socket_; }
// try to connect or throw on failure
void connect(const std::string &host, int port) {
if (is_connected()) {
close();
}
struct addrinfo hints {};
ZeroMemory(&hints, sizeof(hints));
hints.ai_family = AF_UNSPEC; // To work with IPv4, IPv6, and so on
hints.ai_socktype = SOCK_STREAM; // TCP
hints.ai_flags = AI_NUMERICSERV; // port passed as as numeric value
hints.ai_protocol = 0;
auto port_str = std::to_string(port);
struct addrinfo *addrinfo_result;
auto rv = ::getaddrinfo(host.c_str(), port_str.c_str(), &hints, &addrinfo_result);
int last_error = 0;
if (rv != 0) {
last_error = ::WSAGetLastError();
WSACleanup();
throw_winsock_error_("getaddrinfo failed", last_error);
}
// Try each address until we successfully connect(2).
for (auto *rp = addrinfo_result; rp != nullptr; rp = rp->ai_next) {
socket_ = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if (socket_ == INVALID_SOCKET) {
last_error = ::WSAGetLastError();
WSACleanup();
continue;
}
if (::connect(socket_, rp->ai_addr, (int)rp->ai_addrlen) == 0) {
break;
} else {
last_error = ::WSAGetLastError();
close();
}
}
::freeaddrinfo(addrinfo_result);
if (socket_ == INVALID_SOCKET) {
WSACleanup();
throw_winsock_error_("connect failed", last_error);
}
// set TCP_NODELAY
int enable_flag = 1;
::setsockopt(socket_, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<char *>(&enable_flag),
sizeof(enable_flag));
}
// Send exactly n_bytes of the given data.
// On error close the connection and throw.
void send(const char *data, size_t n_bytes) {
size_t bytes_sent = 0;
while (bytes_sent < n_bytes) {
const int send_flags = 0;
auto write_result =
::send(socket_, data + bytes_sent, (int)(n_bytes - bytes_sent), send_flags);
if (write_result == SOCKET_ERROR) {
int last_error = ::WSAGetLastError();
close();
throw_winsock_error_("send failed", last_error);
}
if (write_result == 0) // (probably should not happen but in any case..)
{
break;
}
bytes_sent += static_cast<size_t>(write_result);
}
}
};
} // namespace details
} // namespace spdlog

Some files were not shown because too many files have changed in this diff Show More