Commit e0cb0b7d67 introduced a bug causing
stop() to infinitely wait for the feeding thread to join because it
is blocked waiting for new records or notifications. Notify the thread
when stop() is called.
Fixes https://github.com/boostorg/log/issues/135.
If run is called in a user's thread, and flush is called before the user's
thread enters run, flush would mark the sink frontend as being used by
another record feeding thread and run would exit with an exception.
To mitigate this, we now only throw exception when either run or
feed_records is being called in multiple threads, but not flush. When flush
is in progress, run and feed_records will block until the flush is
complete. This ensures that the sink backend is only used from one thread
at a time.
Additionally, stop now explicitly doesn't wait for the ongoing record
feeding operation to complete. It is generally not possible to ensure that
the record feeding thread has left (or won't enter) the feeding operation
after stop returns. When the internal feeding thread is used we ensure
that the thread is done by joining it. When user's feeding thread is used
it is the user's responsibility to ensure that the thread won't use
the frontend past stop. Joining the thread is one possible way to do it.
Fixes https://github.com/boostorg/log/issues/131.
It looks like the compiler has a bug that prevents it from finding
attachable_sstream_buf::append that takes a pointer as the first
argument.
This commit disables __builtin_assume for the compiler. The builtin
was enabled recently and triggered the bug.
The _SCL_SECURE_NO_WARNINGS, _SCL_SECURE_NO_DEPRECATE,
_CRT_SECURE_NO_WARNINGS and _CRT_SECURE_NO_DEPRECATE macros need to be
defined for every compiler that uses MSVC C/C++ runtime, so instead of
duplicating these definitions in multiple places, define them for
Windows platform regardless of the compiler. In particular, they are
now defined for clang-cl.
This should silence clang-cl warnings about deprecated uses of volatile.
Note that the previous code, although not conforming to the standard C++
memory model, did not have a problem in practice, since all relevant
architectures implement plain aligned 32-bit loads and stores atomically.
The code only modifies the counter under a mutex lock, so the atomic
is only needed to prevent load/store slicing.
Closes https://github.com/boostorg/log/issues/128.
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.
The stream will be checked in the operator<< of the value anyway, and we don't
save much performance by checking the stream before invoking
optional_manipulator::output.
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 makes the code more SFINAE-friendly. It also changes the converting
constructor and assignment operator to only work as converting constructor and
assignment and let the compiler generate the implicit copy constructor and
assignment operator. This should silence bogus clang-10 warnings about
deprecated generation of an implicit copy assignment operator in presence of
a copy constructor. (The warning is bogus because there already is an explicitly
defined assignment operator, which works as a copy assignment as well.)
Closes https://github.com/boostorg/log/issues/118.