#10246 closed Bugs (invalid)
asynchronous_sink sometimes "misses" an attribute
Reported by: | Owned by: | Andrey Semashev | |
---|---|---|---|
Milestone: | To Be Determined | Component: | log |
Version: | Boost 1.55.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Using following
boost::log::sinks::asynchronous_sink< boost::log::sinks::text_ostream_backend > boost::log::sources::severity_channel_logger_mt<Level, Group> scl;
with helper keywords (Level and Group and enums)
namespace { BOOST_LOG_ATTRIBUTE_KEYWORD(level, "Severity", Level) BOOST_LOG_ATTRIBUTE_KEYWORD(group, "Channel", Group) }
configured to use following format
void formatter( blog::record_view const& record, blog::formatting_ostream& stream ) { stream << "[" << record[level] << "]"; stream << "[" << record[group] << "]"; stream << " " << record[expr::smessage]; }
In the std::cout and/or in file output one of the attributes (I only noticed this happens for level) is (sometimes) missing, even though that they are always passed. Example:
BOOST_LOG_CHANNEL_SEV(scl, Group::General, Level::Error) << "Foo";
Possible outputs:
[Error][General] Foo
[][General] Foo
This doesn't happen in case of synchronous sink.
Visual Studio 2013
Attachments (1)
Change History (6)
comment:1 by , 8 years ago
comment:2 by , 8 years ago
Also, if the more recent version still has the problem, I'll need a small test program to reproduce the problem.
comment:4 by , 8 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
You have a race condition in operator<< for Level and Group enums. MSVC doesn't support thread-safe initialization of function-local static variables. Since these operators are called in dedicated threads of async sinks, they are called concurrently. Sometimes this results in the 'strings' arrays being uninitialized when used.
Please, test with 1.56 RC or the current git master.