2
0
mirror of https://github.com/boostorg/log.git synced 2026-01-19 16:32:09 +00:00

236 Commits

Author SHA1 Message Date
Andrey Semashev
826df254f0 Fixed a long loop on file rotation if filename pattern did not include counter.
If the log file is configured for appending and rotation_size limit is set,
text_file_backend::consume would repeatedly attempt to reopen the log file with
a new counter value in attempt to find a file with a size below the
rotation_size limit. This logic breaks if the file name pattern does not
include a file counter placeholder, as it means the backend would repeatedly
attempt to open the same file, whose size would exceed the limit. The loop
would terminate after 2^32 iterations, but that may take a while.

Avoid this fallback if we know the file counter placeholder is missing
in the file name pattern.

Also, make fil size checks more robust against integer overflows.

Fixes https://github.com/boostorg/log/issues/252.
2025-11-06 00:59:55 +03:00
Andrey Semashev
b1fd6a2423 Fix incorrect constant used for PP iteration limit in value_ref visitation.
This fixes generation of apply_visitor_dispatch template specializations
that are supposed to terminate the lookup recursion and optimize for
a small number of (last) lookup steps. The bug was reported on the ML:

https://lists.boost.org/archives/list/boost@lists.boost.org/message/PN6TVYAFH2ICX5ENT76ARTQ7V372G5F2/
2025-10-25 01:45:59 +03:00
Andrey Semashev
ad2eb6c4e5 Added docs, examples and test for wrap_formatter. 2025-07-11 10:28:46 +03:00
Andrey Semashev
86c8cdcced Added a wrap_filter utility.
The wrap_filter helper can be used to inject user-defined filter
functions into Boost.Log filtering expressions.

Added implementation, tests, docs and examples.

Refs https://github.com/boostorg/log/issues/195.
2025-07-11 03:23:01 +03:00
Christopher Kohlhoff
ef6aec2abb Use new minimal boost_asio_core dependency.
Re-enable Boost.Asio in 32-bit MinGW-w64 job in AppVeyor.
2025-07-08 22:30:42 +10:00
Andrey Semashev
ecc4466bc0 Added BOOST_LOG_WITHOUT_ASIO config option.
This lets users to disable Boost.ASIO-related functionality and remove
the dependency on Boost.ASIO. This may be useful on platforms where
Boost.ASIO or its dependencies don't work or disabled.

Refs https://github.com/chriskohlhoff/asio/issues/1637.
2025-06-13 17:17:31 +03:00
René Ferdinand Rivera Morell
2530a4e03a Add support for modular build structure. (#233)
* Make the library modular usable.

* Switch to library requirements instead of source. As source puts extra source in install targets.

* Clean up build dependencies.

* Remove external build references and avoid custom project loading.

* Use relative paths to declare config sub-projects.

* Add missing NO_LIB usage requirements.

* Add missing library ref.

* Add missing import-search for cconfig/predef checks.

* Add requires-b2 check to top-level build file.

* Update dependencies.

* Bump B2 require to 5.2

* Update copyright dates.

* Move inter-lib dependencies to a project variable and into the build targets.

* Remove custom symbolic project names for config subprojects. And use project root relative targets.

* Move private deps to the build project.

* Put back default boost locale link as locale build is now fixed.

* Set default address-model and architecture to avoid extra/custom detection logic. Put back missing check and config rules.

* Adjust doc build to avoid boost-root references.

* Fix ref to predef.jam location.

* Have B2 build use same deps as CML for per-target private/public.

* Add log dep to log_setup, as it's needed on some platforms.

* Add boost_log_with_support target to mirror CML.

* Fix platform specific winapi dependency spec.
2025-05-26 00:48:16 +03:00
Andrey Semashev
75f2e8eb6d Use locale-independent formatting of the file counter in text_file_backend.
This fixes failures in the subsequent parsing of the file names in
file_collector::scan_for_files.

Closes https://github.com/boostorg/log/pull/246.
2025-04-19 18:07:22 +03:00
Andrey Semashev
724e888b5a Only reuse the old counter if the file name pattern has a counter placeholder.
If text_file_backend is set up to append to a previously written file, and
the actively written file name pattern does not include a file counter
placeholder but the target file name pattern does, we used to skip incrementing
the file counter in an attempt to generate the same file name as was last used,
so that we open the last used file for appending. While it did result in
reusing the last written file, since the counter was not incremented, the next
rotation would generate the last used target file name, which would result in
overwriting the last rotated file instead of adding a new file to the storage.

To mitigate this, only skip incrementing the counter if the file name pattern
for the actively written file actually has a counter placeholder. This way,
the counter will get incremented in the case described above, and on rotation
a new target file name will be generated.

Fixes https://github.com/boostorg/log/issues/245.
2025-03-18 01:46:11 +03:00
Andrey Semashev
3dacd004ae Added linking log_setup with ws2_32 on MinGW-w64.
The dependency is introduced by Boost.ASIO, when it is enabled.

Closes https://github.com/boostorg/log/pull/241.
2024-12-15 19:02:49 +03:00
Andrey Semashev
ddb9868bfb Disable std::codecvt<char16_t> and std::codecvt<char32_t> for C++20 and later.
These specializations were deprecated in C++20, and libc++-19 now generates
deprecation warnings when using std::codecvt<char16_t> and
std::codecvt<char32_t> in C++20 and later modes.
2024-12-07 17:32:58 +03:00
Andrey Semashev
29e5fc6504 Fixed grammar in the docs. 2024-10-29 18:50:49 +03:00
Andrey Semashev
26c93dc061 Replaced Boost.Thread synchronization primitives with std equivalents.
This replaces boost::thread and most mutexes and condition variables with
std equivalents. It also adds support for std lock types to the strictest_lock
type trait.

This significantly, although not completely, reduces the dependency on
Boost.Thread.

Refs https://github.com/boostorg/log/issues/232.
2024-08-16 20:01:18 +03:00
Andrey Semashev
8c8124c730 Added a changelog entry for the windres.exe workaround. 2024-06-13 21:15:15 +03:00
Andrey Semashev
2d932ddcb5 Updated links to Boost libraries docs. 2024-04-07 23:58:00 +03:00
Andrey Semashev
e5e4e9554f Changed http to https in Boost URLs. 2024-04-07 20:15:43 +03:00
Andrey Semashev
ea643a6f1d Updated URL to Boost.System docs. 2024-04-07 20:13:57 +03:00
Andrey Semashev
e79cfd841f Explicitly specify TOC depth. 2024-03-02 18:38:56 +03:00
Andrey Semashev
5f84f9130c Expanded leading explanation for attributes.
Related to https://github.com/boostorg/log/issues/226.
2024-03-02 18:10:25 +03:00
Andrey Semashev
433aa87b8c Minor wording improvement. 2024-03-02 16:01:59 +03:00
Andrey Semashev
d9d1f59375 Moved How to read and Definitions to the front page of the docs.
This makes these sections better exposed to an impatient reader, as
that information is useful for better understanding of the rest of
the docs.

Also extracted installation sections to a separate file.

Related to https://github.com/boostorg/log/issues/226.
2024-03-02 15:41:02 +03:00
Andrey Semashev
8b921b6352 Removed gcc-4.8 and 4.9 from GHA CI. Added gcc-11 toolchain for clang.
Boost.ASIO does not compile in C++11 mode on gcc prior to 5 as it uses
std::align.

Clang prior to 16 does not support libstdc++13 that is installed in
GHA ubuntu-22.04 image by default in C++20 mode. Use libstdc++11
instead.
2023-11-25 15:51:14 +03:00
Andrey Semashev
07edd2faa3 Updated b2 executable name in docs. 2023-11-25 15:05:30 +03:00
Andrey Semashev
ae9bf80017 Added a note about deprecation of Windows versions prior to 10. 2023-10-08 20:51:55 +03:00
Andrey Semashev
4db6450fe8 Conditionally link with Boost.Regex library, if it's in C++03 mode.
Boost.Log supports compilers that do not qualify as C++11 compilers
for Boost.Regex, even if they are compiling in C++11 mode. In that
case, we still need to link with Boost.Regex v4 prebuilt library.

For more recent compilers, Boost.Regex v5 is used, and that is
a header-only library. This commit removes linking with Boost.Regex
when this is detected at configure time.

Note that only Boost.Build is updated. CMake doesn't need to be
updated since even header-only libraries need to be listed as
dependencies.

Closes https://github.com/boostorg/log/pull/219.
2023-09-25 20:14:34 +03:00
Andrey Semashev
adbdc63e10 Drop gcc 4.6 and 4.7 from CI.
Boost.Variant now uses reference qualitication for its methods, which
is only supported since gcc 4.8.
2023-09-03 03:52:11 +03:00
Andrey Semashev
e175d010e6 Updated docs to note that C++11 is now required. 2023-08-13 15:53:19 +03:00
Andrey Semashev
b5c4277140 Don't rotate the empty log file if the message size exceeds rotation_size.
In text_file_backend, we try to avoid exceeding the rotation_size limit when we
open a new file, potentially in append mode. To do so, we check the combined
size of the opened file and the formatted log record to write against this
limit. It was possible that the log record alone exceeds the limit, which makes
this check always fail and cause an infinite loop of rotating files.

To avoid this, don't perform the check if the file size is 0, which is the case
when a new file is created. In this case, we will write the log record (thus
exceeding the rotation_size limit) and then rotate the file upon the next
log record we write.

Closes https://github.com/boostorg/log/issues/209.
2023-05-10 19:55:32 +03:00
Andrey Semashev
f6808349bf Added a note about C++03 deprecation. 2023-03-29 02:14:28 +03:00
Andrey Semashev
f8b3ad8850 Fixed a typo. 2022-08-29 02:59:20 +03:00
Andrey Semashev
b7cfe7ee0e Wording improvements in the docs. 2022-08-29 00:23:44 +03:00
Andrey Semashev
01d627a480 Updated docs copyright years. 2022-08-28 23:40:06 +03:00
Andrey Semashev
dcea5e6b0f Added a docs section discussing Boost.Log use in libraries.
Closes https://github.com/boostorg/log/issues/193.
2022-08-28 23:39:59 +03:00
Andrey Semashev
269cedff6c Added a workaround for std::codecvt::do_length bug in libstdc++.
Apparently, std::codecvt::do_length in libstdc++ from gcc 11.2 accesses
input characters outside the input range if max is specified larger than
the input range. This causes buffer overflow and a crash. Use the input
range size as the max limit, which should have the same effect as the
previous hardcoded limit.

gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857
2022-06-05 18:29:30 +03:00
Andrey Semashev
dda118619a Fixed binding IPv4 local address in syslog_backend when IPv6 target is used.
Fixes https://github.com/boostorg/log/issues/181.
2022-04-22 18:14:11 +03:00
Andrey Semashev
a268b41149 Added a new invoke stream manipulator.
The manipulator allows to inject user's function into a stream output
expression. The manipulator will pass a reference to the stream to
the user's function as the first parameter, optionally followed by
additional arguments passed to the manipulator construction.
2022-02-27 05:43:11 +03:00
Andrey Semashev
69ec057e7c Added support for appending to files with file counter placeholders in names.
Previously, text_file_backend would generate a new file name when the file
name pattern contained a file counter placeholder, which prevented appending
to the file. Appending was only possible when the active file name was
stable across process restarts (effectively, this prohibited the file counter
to be used in the active file name).

This commit adds support for appending in such configuration. The file
collector has been updated to return the last found file counter during
filesystem scanning, and the sink backend doesn't increment it when the initial
file is opened, when appending is enabled, and when the file to be opened
exists and, if file collector is used, is in the target storage of the file
collector. In all other cases the file counter is incremented, which leaves
the behavior unchanged.

Closes https://github.com/boostorg/log/issues/179.
2022-02-27 00:03:37 +03:00
Andrey Semashev
656fd1b0c1 Avoid updating file counter in scan_for_files if no new files are found.
This prevents the file counter from being reset to zero if scan_for_files
is called multiple times, and subsequent calls don't find any new files.

Reported in https://github.com/boostorg/log/issues/179.
2022-02-26 16:01:21 +03:00
Andrey Semashev
d78f9c1fd5 Added a warning about using named scopes with coroutines and similar APIs.
This is in response to https://github.com/boostorg/log/issues/178.
2022-02-10 23:56:28 +03:00
Andrey Semashev
d55f122f74 Added notes for CMake users in the docs. 2021-10-31 03:42:19 +03:00
Andrey Semashev
e90d4b7a8d Added a release note for added support for CMake. 2021-10-30 20:42:42 +03:00
Andrey Semashev
63325283f5 Improved performance of SSSE3/AVX2 implementations of dump manipulator.
Use byte shuffle instead of arithmetics and masking to convert half-bytes
to characters.

Since the new algorithm more heavilly relies on pshufb, and it is slow
on some older Intel Atom CPUs, retain the old implementation and use it
when we know pshufb is slow. We might drop it eventually.
2021-10-24 21:18:10 +03:00
Andrey Semashev
1d6a8d9a50 Added a dummy export from boost_log_setup if settings parsers are disabled.
When settings parsers were disabled by a config macro, boost_log_setup would
be empty, and MSVC linker would produce no library at all. This broke
installing Boost.Log, as Boost.Build would expect a library file to be present.

We're adding a dummy export from the library as a workaround, so that the
library is always created, even if empty. This workaround should be considered
temporary, until we can disable the library proper after a Boost.Build bug
is fixed:

https://github.com/bfgroup/b2/issues/104

Closes https://github.com/boostorg/log/issues/164.
Closes https://github.com/boostorg/log/pull/165.
2021-10-24 16:09:04 +03:00
Andrey Semashev
6d4a13cddf Added a new nt62 OS API version tag in the library version namespace.
This is to indicate that the minimum target Windows version is Windows 8.
This is important for Boost.Atomic as it enables using WaitOnAddress API,
which further affects binary representation of the event object in Boost.Log.
2021-09-17 23:45:32 +03:00
Andrey Semashev
24117c7a0c Fixed a race in reliable_message_queue::open_or_create on POSIX systems.
The open_or_create implementation assumed that the created shared memory
size of 0 meant that the shared memory segment was freshly created. This
is not the case if multiple threads call open_or_create and check the
segment size before one of them resizes it. This could result in
initializing the shared memory multiple times and even corrupting it
if other threads were sending or receiving messages in the mean time.

While at it, converted the use of atomics in shared memory to ipc_atomic.

Fixes https://github.com/boostorg/log/issues/162.
2021-09-15 16:33:25 +03:00
Andrey Semashev
0d36026a7d Added support for std::byte to receive methods of IPC message queue. 2021-09-13 19:59:40 +03:00
Andrey Semashev
13b848b47e Added a release note for #159. 2021-08-20 01:36:57 +03:00
Andrey Semashev
9fe832c344 Add ios_base::ate when ios_base::app is specified for text_file_backend.
This ensures that the writing position is actual immediately after the
log file is opened for appending. This fixes incorrect accounting for
the initial file size with MSVC and possibly other compilers.

Closes https://github.com/boostorg/log/issues/151.
2021-07-20 01:03:53 +03:00
Andrey Semashev
d723878e72 Added release notes about fixing compilation on riscv32. (#150)
Closes https://github.com/boostorg/log/pull/150.
2021-05-29 17:10:07 +03:00
Andrey Semashev
df4bc60d05 Added a changelog entry for the removal of __MSVCRT_VERSION__. 2021-04-06 00:59:48 +03:00