2
0
mirror of https://github.com/boostorg/log.git synced 2026-01-31 08:12:30 +00:00
Commit Graph

229 Commits

Author SHA1 Message Date
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
Fabrice Fontaine
d206141950 src/event.cpp: fix build on riscv32
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>
2021-05-29 17:06:02 +03:00
Andrey Semashev
d99d9891dd Removed the use of virtual functions from threadsafe_queue implementation.
This should amount to a more efficient code and smaller binaries.
2021-01-28 02:42:39 +03:00
Andrey Semashev
a75c4f45c4 Corrected a formal race in the threadsafe_queue implementation.
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.
2021-01-28 01:55:20 +03:00
Andrey Semashev
84b82a4de4 Removed BOOST_LOG_ASSUME postulating that a reference is not null.
Normally, this should be inferred by compiler, as references are not
allowed to be null. This silences a clang-cl warning.
2020-09-08 18:28:06 +03:00
Andrey Semashev
dd5a8f1b41 Fixed file counter in the target filename generated by text file backend.
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.
2020-08-20 19:57:21 +03:00
Andrey Semashev
e7d4fd2d13 Include config.hpp before checking BOOST_LOG_WITHOUT_SYSLOG.
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.
2020-08-01 21:59:33 +03:00
Andrey Semashev
9a85efde08 Added noexcept specifiers. Made logger move ctors more noexcept-friendly.
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.
2020-05-07 20:35:14 +03:00
Andrey Semashev
706fed3bf4 Avoid unnecessary copy of the filename string. 2020-05-07 17:48:38 +03:00
Eugene Zelenko
4019d171a3 Use BOOST_OVERRIDE to fix GCC -Wsuggest-override and Clang-tidy modernize-use-override warnings. 2020-05-03 20:29:19 -07:00
Andrey Semashev
1e92e84b80 Added checking for IP version in addresses in syslog backend.
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.
2020-04-27 21:47:41 +03:00
Andrey Semashev
c068c2a5aa Add explicit markup of fallthrough between switch/case labels.
Silences some compiler warnings.

Closes https://github.com/boostorg/log/issues/115.
2020-04-14 00:29:14 +03:00
Marian Klymov
e6c6479d91 Add missing filesystem includes.
Fix compilation with BOOST_FILESYSTEM_NO_DEPRECATED
2020-04-03 18:55:34 +03:00
Andrey Semashev
5f48284bf9 Nonessential cleanup. 2020-03-04 13:38:45 +03:00
Andrey Semashev
68d38321b3 Updated deprecated uses of boost::bind to silence warnings. 2020-03-04 00:44:23 +03:00
Andrey Semashev
60cf554ee9 Ported to use newer API of Boost.Atomic. 2020-03-04 00:32:52 +03:00
Andrey Semashev
a7b4a140d9 Use atomic to implement logging_enabled flag. 2020-02-29 16:01:00 +03:00
Andrey Semashev
9474c57264 Perform automatic flush in default sink.
Closes https://github.com/boostorg/log/issues/103.
2020-02-29 15:44:41 +03:00
Andrey Semashev
e5f305a8a5 Make core::flush call flush on the default sink.
When trivial logging is used and no sinks are registered, allow
users to manually flush the default sink.

Related to https://github.com/boostorg/log/issues/103.
2020-02-29 15:43:34 +03:00
Andrey Semashev
4d9ce5cdba Check for feature test macros after including config.hpp.
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.
2020-02-21 18:44:48 +03:00
Andrey Semashev
2f15b44dc1 Converted some uses of Boost.MPL to Boost.TypeTraits. 2020-02-17 18:41:29 +03:00
Andrey Semashev
34d9e64815 Reordered day and day kind initializers to match declaration order.
Silences compiler warnings.
2020-02-17 15:54:45 +03:00
Andrey Semashev
c721453aeb Ported named_scope_list and pool_allocator to allocator_traits.
This fixes compilation problems with C++20 std::allocator, which removed
deprecated typedefs and member functions.

Closes https://github.com/boostorg/log/pull/100.
2020-02-17 15:49:58 +03:00
Andrey Semashev
8a7cc8efd6 Move log file status check before renaming to the target file name.
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.
2020-02-17 15:12:36 +03:00
Andrey Semashev
42b4463ad2 Fixed day kind representation in rotation_at_time_point.
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.
2020-02-05 17:30:55 +03:00
Andrey Semashev
10a63204b3 Added a workaround for openlog not saving ident string.
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.
2020-01-22 21:37:56 +03:00
Andrey Semashev
e80dce7fec Removed unused local typedefs. 2019-10-22 20:06:26 +03:00
Andrey Semashev
08bd1fb809 Added support for trivial::severity_level to filter/formatter parsers.
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.
2019-06-25 18:54:55 +03:00
Andrey Semashev
e903d3aef7 Fixed compilation in C++03. 2019-06-24 04:34:44 +03:00
Andrey Semashev
894acde57e Added support for controling trailing newline insertion in the text sinks.
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.
2019-06-23 21:02:51 +03:00
Andrey Semashev
2154cafa46 Optimized file status requesting while scanning for files. 2019-04-14 20:34:44 +03:00
Andrey Semashev
d7a87119e6 Fixed incorrect matching of digits in a file name against a placeholder.
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.
2019-04-14 20:14:58 +03:00
Andrey Semashev
958ced0edd Work around MSVC name lookup bugs.
The compiler fails to find a symbol defined in an anonymous namespace, if
the name is qualified up to the namespace enclosing the anonymous namespace.
2019-01-06 02:00:44 +03:00
Andrey Semashev
e823f88467 Added support for a separate target file name pattern in text file sink.
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.
2019-01-05 21:15:33 +03:00
Andrey Semashev
46560ff9fb Removed unnecessary optimization in the check for an operator keyword.
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.
2019-01-05 15:04:26 +03:00
Andrey Semashev
67eef1afba Switch to uncaught_exceptions from Boost.Core.
The implementation in Boost.Core was based in unhandled_exception_count
in Boost.Log, therefore we remove our loca implementation in favor
of the common one.
2018-12-17 19:21:25 +03:00
Andrey Semashev
b222110738 Prefer std::uncaught_exceptions on compilers that provide it. 2018-11-05 12:59:52 +03:00
Andrey Semashev
f8954f6662 Work around incorrect total file size estimate in file_collector.
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.
2018-10-30 04:29:49 +03:00
Andrey Semashev
a95dc575a1 Updated Boost.ASIO usage to avoid using deprecated APIs.
Fixes https://github.com/boostorg/log/issues/59.
2018-10-21 22:21:10 +03:00
Andrey Semashev
8418a749ea Save/restore full rbx on 64-bit VxWorks. 2018-08-13 20:22:12 +03:00
Andrey Semashev
95ebf8c62d Post-merge corrections. 2018-06-01 14:18:46 +03:00
Brian Kuhl
26e36fbc1d Review changes; keep example clean, consolidate BOOST_LOG_NO_GETPWUID_R 2018-04-29 20:54:01 -04:00
Brian Kuhl
1f6543e94c Merge remote-tracking branch 'upstream/develop' into develop
# Conflicts:
#	src/dump.cpp
2018-04-24 23:58:12 -04:00
Andrey Semashev
d88339870c Added cache line sizes for PowerPC and IBM Z.
The cache line sizes were taken from Boost.Lockfree.
2018-04-19 22:18:42 +03:00
Andrey Semashev
a1f61ac15b Save and restore ebx around cpuid on 32-bit PIE targets.
Also use a more efficient and reliable save and restore code. The previous
implementation could potentially result in invalid code generated if the
memory reference generated by compiler involved ebx.
2018-04-18 07:55:54 +03:00
Andrey Semashev
444e6b5bda Updated NTAPI calling convention macro. 2018-03-11 02:44:49 +03:00
Andrey Semashev
d268933c2a Updated WINAPI calling convention macro.
Boost.WinAPI no longer defines WINAPI calling convention macro and instead
defines its own BOOST_WINAPI_WINAPI_CC macro.
2018-03-11 02:31:06 +03:00
Andrey Semashev
cafc525479 Added periodic refresh calls to emulated GetTickCount64.
Periodic refreshes make sure that the 32-bit GetTickCount wraparounds are
properly counted even if the user doesn't call GetTickCount64 for extended
periods of time.
2018-02-21 21:07:55 +03:00
Brian Kuhl
8d0ada3a41 If no gid or sid substitute uid,
Object name scopes remain non-overlapping & all tests pass
2018-01-20 22:01:26 -05:00
Andrey Semashev
19973d0488 Updated Boost.WinAPI usage to the new location and namespace. 2017-10-24 22:55:48 +03:00