|
Boost Users : |
Subject: Re: [Boost-users] Log: [Bug] Setting attribute makes log entry disappear
From: Florian Lindner (mailinglists_at_[hidden])
Date: 2015-10-12 10:54:21
Florian Lindner wrote:
> Hello,
>
> I have a tracer, that should log going in and out of a function:
>
> class Tracer
> {
> public:
> Tracer(Logger logger, std::string function, std::string file)
> :
> _logger(logger),
> _function(function),
> _file(file)
> {}
>
> ~Tracer()
> {
> using namespace boost::log;
> //
> attribute_cast<attributes::mutable_constant<int>>(core::get()-
>get_global_attributes()["Line"]).set(1);
> attribute_cast<attributes::mutable_constant<std::string>>(core::get()-
>get_global_attributes()["File"]).set(_file);
> attribute_cast<attributes::mutable_constant<std::string>>(core::get()-
>get_global_attributes()["Function"]).set(_function);
> BOOST_LOG_SEV(_logger, trivial::severity_level::trace) << "Leaving "
> << _function;
> }
>
> private:
> Logger _logger;
> std::string _function;
> std::string _file;
> };
>
> This works fine, but as soon as I uncomment the line that sets the Line
> attribut I don't get any Leaving messages anymore.
>
> The attributes are added beforehand like that:
>
> using namespace boost::log;
> add_common_attributes();
> core::get()->add_global_attribute("Scope", attributes::named_scope());
> core::get()->add_global_attribute("Rank",
> attributes::constant<int>(5));
> core::get()->add_global_attribute("Line",
> attributes::mutable_constant<int>(5));
> core::get()->add_global_attribute("File",
> attributes::mutable_constant<std::string>(""));
> core::get()->add_global_attribute("Function",
> attributes::mutable_constant<std::string>(""));
>
> Setting all other attributes, similiar to Line works fine. I'm puzzled
> because Line does not seem to be a reserved name, it works somewhere else
> and the boost::log sources reveal no relevant usages of that name.
Sorry, forgot to add what the actual problem is: The log message
(Leaving...) is simply discarded. All log message before and after that are
printed fine, but this one.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net