Commit Graph

2218 Commits

Author SHA1 Message Date
Sandor Magyar
1bb1f05d73 Adjust MongoCXX instance handling in mongo_sink
Changes suggested by @gabime on #2519
2022-10-18 20:13:17 -04: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
Daniil
93b9132b0a Replace iterator difference with std::distance 2022-10-13 12:29:48 +03:00
offa
06f9953fa8 Workaround deprecation warning on Clang with C++20 2022-09-29 20:14:53 +02:00
Nigel Stewart
1eaf98cc10 SPDLOG_NO_SOURCE_LOC implementation refinement 2022-09-03 12:51:31 +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
Gabi Melman
f44fa31f51
Fix #2434 2022-08-17 17:47:22 +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
Shen-Ta Hsieh
5f8877b665
Explicitly casting level_enum to size_t.
See commit 2a4c34b878
2022-07-21 20:24:01 +08: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
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
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
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
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
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
Gabi Melman
0d8197cc9d
Update common.h
Init file event handlers to nullptr
2022-05-13 23:06:11 +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
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
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
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
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
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
espkk
e6265c04ae Make file_event_handlers an aggregate 2022-04-15 11:54:11 +03: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
Delgan
36b4b9dac9 Add optional "ident" argument to systemd sink constructor 2022-04-01 23:20:28 +02: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
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
Andrey Bugaevskiy
5ee969e4f6 Fix fopen_s error reporting with PREVENT_CHILD_FD 2022-03-11 19:22:45 +00: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
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
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
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
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
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
Sprite
3540ba32e9 Reset current size if rotated files on open 2022-01-04 09:16:20 +08: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
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 7e95963940.
2021-12-19 21:05:21 +04:00
Vladislav Nepogodin
7e95963940
Useless cast 2021-12-19 15:04:47 +04: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
semenov_gv
e3e4c4bc95 minor changes added const ref params 2021-12-11 16:09:19 +02: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
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
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
232df72b82 use pthread_getthrds_np for AIX 2021-11-20 09:48:14 +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
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
gabime
dc030ec53c clang-format 2021-11-16 23:44:35 +02:00
gabime
2b4e07dd91 Fixed wchar support for std::format 2021-11-16 23:42:06 +02:00
Gabi Melman
24e47efae0
fix gcc 4.8 compile warning 2021-11-16 22:48:02 +02:00