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.
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.
Use inline asm instead of _mm256_broadcastsi128_si256 to work around issues:
- gcc 4.7 is missing _mm256_broadcastsi128_si256 declaration in immintrin.h.
- gcc 4.8 generates vmovdqu+vinserti128 instead of a single vbroadcasti128.
- clang up until 4.0 generates vmovdqu+vinserti128 or worse.
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.
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.
This allows to reuse the futex abstraction layer from Boost.Atomic and
also use futex-like APIs available on other systems.
Closes https://github.com/boostorg/log/issues/161.
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.
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.
riscv32 fails to build because __NR_futex is not defined on this
architecture:
libs/log/src/event.cpp: In member function 'void boost::log::v2_mt_posix::aux::futex_based_event::wait()':
libs/log/src/event.cpp:38:29: error: '__NR_futex' was not declared in this scope
38 | #define BOOST_LOG_SYS_FUTEX __NR_futex
| ^~~~~~~~~~
Fixes:
- http://autobuild.buildroot.org/results/8c8135fd7c0517c66c9b3975c494da6d7934cc1b
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
The pointer to the next node can be read and written concurrently
by push and try_pop methods. This does not impose a real problem
as long as pointer-sized loads and stores generated by the compiler
are atomic on a given target platform, which it typically is.
No memory ordering constraints are needed in this context.
To guarantee atomicity, use Boost.Atomic for these pointers.
Fixes https://github.com/boostorg/log/issues/139.
The file counter gets incremented when a new file is opened. Since the
target filename was generated later, on file rotation, the target filename
got the next value of the counter. This caused some values of the counter
being skipped when the application restarts and scans for the previous
log files.
Fixes https://github.com/boostorg/log/issues/125.
Boost.Log's config.hpp may define BOOST_LOG_WITHOUT_SYSLOG if no native
syslog API or Boost.ASIO is available, so we need to include the header
before checking the macro.
Closes https://github.com/boostorg/log/pull/123.
Logger move constructors don't need to add the attributes to the logger
attributes since the latter are moved from the source logger, just as the
attributes. This allows move constructors to be noexcept, provided that
they are non-noexcept for other reasons.
Closes https://github.com/boostorg/log/issues/121.
The syslog sink backend now verifies the IP version of the local and target
addresses set by user. The addresses must have the same IP version as was
specified in the ip_version named parameter on the sink backend construction.
When an address is obtained as a result of host name resolution, only addresses
with matching IP version are considered.
This should protect against using local and target addresses with mismatching
IP versions, which results in errors on sending datagrams.
Fixes https://github.com/boostorg/log/issues/119.
This avoids possible inconsistency when the BOOST_LOG_WITHOUT_DEBUG_OUTPUT
and BOOST_LOG_WITHOUT_EVENT_LOG macros are defined in config.hpp but not
in command line.
Related to https://github.com/boostorg/log/issues/102.
This fixes compilation problems with C++20 std::allocator, which removed
deprecated typedefs and member functions.
Closes https://github.com/boostorg/log/pull/100.
If the log file has not been created (e.g. when there are no log records
written yet), rotate_file could throw as it attempted to rename the file
to the target file name before rotation. The check for file presence that
was intended to protect from this was made later on, before the file collector
is invoked. This commit moves the check before renaming.
Since day_kind is enum, it may be represented by a signed integer type.
Some compilers (e.g. MSVC) use sign extension when loading the day kind
field from the bit field, which corrupts the monthday value (which is 2)
and makes the rotation never happen. Fix this by using an unsigned type
to store the day kind and then cast the value to the enum.
Also, rearranged the bitfields for slightly better codegen.
Fixes https://github.com/boostorg/log/issues/98.
Some syslog implementations (e.g. glibc) do not save the ident string
in openlog and instead only save a pointer to the user-provided string.
This requires the caller to preserve the passed string for the whole
duration of logging.
Fixes https://github.com/boostorg/log/issues/97.
The default filter/formatter factories will now be able to extract severity
level values of type boost::log::trivial::severity_level. For filters, this
is only supported for attributes with the "Severity" name.
Text ostream, file and multifile sink backends now support controlling trailing
newline insertion after every log records. The supported modes are described by
the auto_newline_mode enum. The behavior can be controlled via the same-named
named parameter, a set_auto_newline_mode call or the AutoNewline parameter
in the settings.
The default behavior has changed from the previous releases. From now on the
trailing newline will only be added if there isn't one in the formatted log
message already.
If a file name pattern ended with a placeholder, e.g. a file counter, file names
fitting that pattern would not be matched by scan_for_files, leaving such files
unmanaged.
Fixes https://github.com/boostorg/log/issues/78.
This allows to have different file names when actively writing the log file
and when rotating. In particular, this solves the problem with appending
to the previous file, when the log files are also collected and are supposed
to have distincs names.
Modern compilers are able to optimize memcmp to a single cmp instruction
with a constant, which was the intention of the optimization. This should
fix UBSan errors.