boost::log (boost logging):BOOST_LOG_FUNCTION只在主线程中工作
boost::log (boost logging): BOOST_LOG_FUNCTION only works in main thread
考虑以下函数:
void thread()
{
BOOST_LOG_FUNCTION();
while(true) {
// Create log entry
}
}
如果我只是在"main"中调用"thread()",我在"thread()"中创建的日志条目看起来符合预期:
[void __cdecl thread(void) (c:...maintest.cpp:16)]
但是,如果您在函数中使用"thread()":
boost::thread t(thread);
相应的日志条目为空:
[]
我该如何解决这个问题?
我从提升日志作者那里得到了反馈。要使范围在登录过程中可用,您必须添加"范围"作为属性。它做到了:
logging::core::get()->add_thread_attribute("Scope", attrs::named_scope());
但是,这仅与指示的当前线程相关。如果使用多个线程,则必须调用:
logging::core::get()->add_global_attribute("Scope", attrs::named_scope());
相关文章:
- BOOST线程:线程还是进程
- 如何解决传递给boost线程的函数中的歧义
- cpp 为什么 boost::线程内部的循环不遍历所有值并且推送相同的值?
- C 从类的构造函数运行Boost线程
- 重新分配独立的boost ::线程安全吗?
- Boost::线程如何在主线程和工作线程之间同步
- 链接Boost线程库
- BOOST ::线程内会成员功能调用返回unique_lock Instantiation错误
- Boost ::线程何时终止?如何管理Boost ::线程
- 链接到boost ::线程失败
- 在C 中处理Boost线程条件
- Poco任务管理器/Boost线程混合和匹配
- 创建一个 boost::线程 带有 boost::bind() 或不带
- 为不受支持的平台调整Boost线程/进程
- 删除boost ::线程后代
- 我需要在Boost线程功能中调用Unlock()
- C OPENCV图像在Boost线程中不显示
- boost ::线程在删除可加入线程时存在什么问题
- 增强异步插座和Boost ::线程
- 如何使boost ::线程入睡