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 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 new example demostrates working with the settings container directly
and provides a more complete view on the library initialization.
Closes https://github.com/boostorg/log/issues/87.
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.
This allows to specify directly custom function objects, including C++11
lambda functions, in the filter and format named parameters in the sink
initialization calls.
Closes https://github.com/boostorg/log/issues/63.
The manipulator and formatter can be used to ensure a certain piece of output
ends with a newline without introducing duplicate newline characters if the
previous output ended with a newline already.
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.
When a user defines an output operator for std::basic_ostream and
a pointer to a user-defined type, that operator use to be ignored
because of the implicit cast to const void* that happened when
operator<< for formatting_ostream or record_ostream was called.
We now forward the pointer type to the operator<< for std::ostream,
so it is either cast then or user's operator<< is picked.
Fixes https://github.com/boostorg/log/issues/84.
Explicit output operators allow to enable character code conversion, if
one is needed, on string view output. This is in line with the existing
support for other string types.
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.
Some users mistakenly assumed that enabling compiler TLS intrinsics would
remove the need for Boost.Thread. This added note should remove that confusion.
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.
If the text file sink backend used the file that was previously scanned
by file_collector as an old log file, on rotation the collector would
store a duplicate of the file info. If the file was removed due to
storage limits, the file info would still be stored despite the file
being deleted.
Also, in case if a file that is about to be rotated is deleted, don't
hard fail with an exception. This may happen if another process have deleted
the file or Boost.Log itself has. The latter can happen if multiple sinks
write directly into the common target storage and one of them invokes
file rotation, which due to the storage limits delete the file that
is currently being written by the other sink.
This should help avoid using members that were deprecated in C++17 and thus
improve compatibility with later language versions.
The commit also adds a new internal trait rebind_alloc that helps to portably
rebind the allocator to another allocated type. The trait also avoids
instantiation of std::allocator<void> which is also deprecated in C++17.
If the target directory contained a file with counter value of UINT_MAX in its
name, scan_for_files would always return the counter value of 0, even if such
file also existed in the directory. This caused incorrectly named log files to
appear in the target directory on user's application restart.
Also made sure that the returned counter value is zero if the scanning method
is not scan_matching or the file name pattern does not include the counter
placeholder. The returned counter should not have been used by the caller
in these cases anyway, but the returned value used to be bogus.
This can be useful when the final rotation cannot be performed while global destructors are run (e.g. when a close handler depends on a global state).
It can also be useful to implement file appending with collector set up to a different target directory than the directory the backend writes to.
The auto-detection was removed in 1.62, which resulted in UDP socket-based implementation being always used. The new auto-detection verifies the presence of syslog.h and all required components it provides.
Fixes ticket #12600.