日志系统用于记录软件运行过程中的关键信息,是大型CAx软件系统的一个重要的组件。

本文拟对Boost.Log模块进行分析,旨在记录其技术要点。

注1:限于笔者研究水平,难免有理解不当,欢迎批评指正。

注2:文章内容会不定期更新,欢迎交流讨论。

一、工作原理

Boost.Log大体上可以由Logging Sources、Logging Core、Logging Sinks等组成:Logging Sources创建log records;Logging Core对log records进行处理;Logging Sinks则完成最终格式化与输出。

Ref. from Boost.Log Design Overview

Logging sources

Getting back to the figure, in the left side your application emits log records with help of loggers - special objects that provide streams to format messages that will eventually be put to log. The library provides a number of different logger types and you can craft many more yourself, extending the existing ones. Loggers are designed as a mixture of distinct features that can be combined with each other in any combination. You can simply develop your own feature and add it to the soup. You will be able to use the constructed logger just like the others - embed it into your application classes or create and use a global instance of the logger. Either approach provides its benefits. Embedding a logger into some class provides a way to differentiate logs from different instances of the class. On the other hand, in functional-style programming it is usually more convenient to have a single global logger somewhere and have a simple access to it.

Generally speaking, the library does not require the use of loggers to write logs. The more generic term "log source" designates the entity that initiates logging by constructing a log record. Other log sources might include captured console output of a child application or data received from network. However, loggers are the most common kind of log sources.

Logging core and filtering

When the set of attribute values is composed, the logging core decides if this log record is going to be processed in sinks. This is called filtering. There are two layers of filtering available: the global filtering is applied first within the logging core itself and allows quickly wiping away unneeded log records; the sink-specific filtering is applied second, for each sink separately. The sink-specific filtering allows directing log records to particular sinks. Note that at this point it is not significant which logging source emitted the record, the filtering relies solely on the set of attribute values attached to the record.

Sinks and formatting

If a log record passes filtering for at least one sink the record is considered to be consumable. If the sink supports formatted output, this is the point when log message formatting takes place. The formatted message along with the composed set of attribute values is passed to the sink that accepted the record. Note that formatting is performed on the per-sink basis so that each sink can output log records in its own specific format.

Ref. from Boost.Log

参考资料

Boost.Loghttps://www.boost.org/doc/libs/1_79_0/libs/log/doc/html/index.html

Log4Cpphttp://log4cpp.sourceforge.net/

Boost研究:Boost Log相关推荐

  1. boost::math::boost::math::interpolators::cardinal_cubic_b_spline用法的测试程序

    boost::math::boost::math::interpolators::cardinal_cubic_b_spline用法的测试程序 实现功能 C++实现代码 实现功能 boost::mat ...

  2. Boost:Boost概念的function_requires()的测试程序

    Boost:Boost概念的function_requires()的测试程序 实现功能 C++实现代码 实现功能 Boost:Boost概念的function_requires()的测试程序 C++实 ...

  3. Boost:boost::callable_traits::function_type_t的测试程序

    Boost:boost::callable_traits::function_type_t的测试程序 实现功能 C++实现代码 实现功能 boost::callable_traits模块,boost: ...

  4. Boost:boost :: bind相等运算符的测试程序

    Boost:boost :: bind相等运算符的测试程序 实现功能 C++实现代码 实现功能 boost :: bind相等运算符的测试程序 C++实现代码 #include <boost/c ...

  5. Boost:boost :: mem_fn等式运算符的测试程序

    Boost:boost :: mem_fn等式运算符的测试程序 实现功能 C++实现代码 实现功能 boost::bind模块,boost :: mem_fn等式运算符的测试程序 C++实现代码 #i ...

  6. Boost:boost::source_location的用法测试程序

    Boost:boost::source_location的用法测试程序 实现功能 C++实现代码 实现功能 boost::source_location的用法测试程序 C++实现代码 #include ...

  7. Boost:boost::bimaps::list_of的测试程序

    Boost:boost::bimaps::list_of的测试程序 实现功能 C++实现代码 实现功能 boost::bimaps::list_of的测试程序 C++实现代码 #include < ...

  8. Boost:boost::bimaps::multiset_of的测试程序

    Boost:boost::bimaps::multiset_of的测试程序 实现功能 C++实现代码 实现功能 boost::bimaps::multiset_of的测试程序 C++实现代码 #inc ...

  9. Boost:boost::bimaps::set_of的测试程序

    Boost:boost::bimaps::set_of的测试程序 实现功能 C++实现代码 实现功能 boost::bimaps::set_of的测试程序 C++实现代码 #include <b ...

  10. Boost:boost::bimaps::unordered_multiset_of的测试程序

    Boost:boost::bimaps::unordered_multiset_of的测试程序 实现功能 C++实现代码 实现功能 boost::bimaps::unordered_multiset_ ...

最新文章

  1. 添加Page_Init事件
  2. 卷积神经网络补充—GoogleNet
  3. TF之LSTM:基于tensorflow框架自定义LSTM算法实现股票历史(1990~2015数据集,6112预测后100+单变量最高)行情回归预测
  4. dods 机器人_胜利之日机器人补丁
  5. 《JavaScript高级程序设计》Chapter 5 引用类型
  6. zhs16gbk对应mysql_数据库的编码浅谈(ZHS16GBK与US7ASCII)
  7. mybatis拦截器实现通用权限字段添加
  8. AI学习笔记(十四)CNN之图像分割
  9. 网络拓扑发现原理研究
  10. 容器技术Docker K8s 34 容器服务ACK基础与进阶-安全管理
  11. android网络框架OkHttp之get请求(源码初识)
  12. javascript弹出窗口代码
  13. 认识计算机拓扑结构图,认识计算机网络拓扑结构
  14. Cloudera 简介、安装和升级、管理、操作文档
  15. android FDE功能介绍
  16. Harmonious Graph (并查集 —父亲为最大值)
  17. 博士读一半,导师跳槽了!博士生把亲身经历发在了Science上
  18. [网络转载]IE选项注册表控制大全
  19. 2020秋招笔试题总结(华为、360、京东、中兴、快手、字节跳动、阿里、拼多多、腾讯、VIVO)~持续更新
  20. Java数组技巧攻略

热门文章

  1. 用Java实现成绩等级划分
  2. 315来了,跨境卖家们赶紧自检容易被维权举报的问题
  3. 硬盘问题导致无法开机
  4. 『Python学习笔记』Git的使用教程
  5. 技术分享 | AlertManager 源码解析
  6. 最本质的相机内参intrinsics与外参extrinsics分析,从建模,推导到求解
  7. 命令行使用oracle19c_把oracle19c数据导入oracle11g
  8. 关于网页抓取的10个误区(最新)
  9. Nginx使用stream模块分流实现端口复用
  10. 1920*1080 网页使用scale在其他分辨率或宽度下等比例缩放