当前位置:网站首页>Boost研究:Boost Log
Boost研究:Boost Log
2022-06-30 11:18:00 【JiNan.YouQuan.Soft】
日志系统用于记录软件运行过程中的关键信息,是大型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.

参考资料
Boost.Log
https://www.boost.org/doc/libs/1_79_0/libs/log/doc/html/index.html
边栏推荐
- HMS core audio editing service 3D audio technology helps create an immersive auditory feast
- Kotlin 协程调度切换线程是时候解开谜团了
- 什么是微信小程序,带你推开小程序的大门
- 10天学会flutter DAY10 flutter 玩转 动画与打包
- Go语言学习之Switch语句的使用
- [untitled]
- Qualcomm released the "magic mirror" of the Internet of things case set, and digital agriculture has become a reality
- Retest the cloud native database performance: polardb is still the strongest, while tdsql-c and gaussdb have little change
- 记一次ViewPager + RecyclerView的内存泄漏
- Pointdistiller: structured knowledge distillation for efficient and compact 3D detection
猜你喜欢

ESP32-C3入门教程 问题篇⑨——Core 0 panic‘ed (Load access fault). Exception was unhandled. vfprintf.c:1528

数据库连接池 druid

Filter error in dplyr: can't transform a data frame with duplicate names

Mathematics (fast power)

Record the memory leak of viewpager + recyclerview once

Oracle netsuite helps TCM bio understand data changes and make business development more flexible

数字化不是试出来,而是蹚出来的|行知数字中国 × 富士康史喆

科普达人丨漫画图解什么是eRDMA?

The first batch in China! Alibaba cloud native data Lake products have passed the evaluation and certification of the ICT Institute

How harmful are these "unreliable" experiences in the postgraduate entrance examination?
随机推荐
Go language defer
Go语言学习之Switch语句的使用
再不上市,旷视科技就熬不住了
限时预约|6 月 Apache Pulsar 中文开发者与用户组会议
[applet practice series] Introduction to the registration life cycle of the applet framework page
线代(高斯消元法、线性基)
Evaluation of IP location query interface Ⅲ
Is the golden cycle of domestic databases coming?
Mathematics (fast power)
华三交换机清空配置
SQL必需掌握的100个重要知识点:汇总数据
一个悄然崛起的国产软件,低调又强大!
【无标题】
建立自己的网站(13)
Kongsong (ICT Institute) - cloud security capacity building and trend in the digital age
100 important knowledge points that SQL must master: grouping data
Esp32-c3 introductory tutorial basic part ⑪ - reading and writing non-volatile storage (NVS) parameters
Introduction to China Mobile oneos development board
ESP32-C3入门教程 问题篇⑨——Core 0 panic‘ed (Load access fault). Exception was unhandled. vfprintf.c:1528
STM32F407ZGT6使用SDIO方式驱动SD卡