## QsLog - the simple Qt logger ##
QsLog is an easy to use logger that is based on Qt's QDebug class. QsLog is released as open source, under the MIT license.
###Contribution policy###
Bug fixes are welcome, larger changes however are not encouraged at this point due to the lack of time on my side for reviewing and integrating them. Your best bet in this case would be to open a ticket for your change or forking the project and implementing your change there, with the possibility of having it integrated in the future.
All contributions will be credited, license of the contributions should be MIT.
### Features ###
* Six logging levels (from trace to fatal)
* Logging level threshold configurable at runtime.
* Minimum overhead when logging is turned off.
* Supports multiple destinations, comes with file and debug destinations.
* Thread-safe
* Supports logging of common Qt types out of the box.
* Small dependency: just drop it in your project directly.
### Usage ###
* Include QsLog.h. Include QsLogDest.h only where you create/add destinations.
* Get the instance of the logger by calling QsLogging::Logger::instance();
* Optionally set the logging level. Info is default.
* Create as many destinations as you want by using the QsLogging::DestinationFactory.
* Add the destinations to the logger instance by calling addDestination.
**Note**: The logger does not take ownership of the destinations. Make sure that the destinations still exist when you call one of the logging macros. A good place to create the destinations is the program's main function.
### Disabling logging ###
Sometimes it's necessary to turn off logging. This can be done in several ways:
* globally, at compile time, by enabling the QS_LOG_DISABLE macro in the supplied .pri file.
* globally, at run time, by setting the log level to "OffLevel".
* per file, at compile time, by including QsLogDisableForThisFile.h in the target file.
### Thread safety ###
The Qt docs say:
A **thread-safe** function can be called simultaneously from multiple threads, even when the invocations use shared data, because all references to the shared data are serialized.
A **reentrant** function can also be called simultaneously from multiple threads, but only if each invocation uses its own data.
Since sending the log message to the destinations is protected by a mutex, the logging macros are thread-safe provided that the log has been initialized - i.e: instance() has been called.
The instance function and the setup functions (e.g: setLoggingLevel, addDestination) are NOT thread-safe and are NOT reentrant.
QsLog源码(库+demo 亲测可用)
5星 · 超过95%的资源 需积分: 50 73 浏览量
2018-04-18
09:56:25
上传
评论 1
收藏 34KB ZIP 举报
安得一鱼
- 粉丝: 6
- 资源: 3
最新资源
- 杨辉三角(Pascal's Triangle)是一个在数学中非常著名的数列,它以一种特定的模式排列数字,内容以5种代码实例实现
- yolov5数据集:CT图像肾脏、结石检测(2类别,包含训练集、验证集)
- 电力102规约请求报文实录
- RTL8723 linux+安卓驱动 2020版本
- ISO 26262 道路车辆-功能安全-系统级产品开发
- 数据挖掘期末题 选择填空简答
- EKF在CTRV模型上的建模推导
- 用于:https://laoshifu.blog.csdn.net/article/details/138191428 多层创建
- 电力102规约(电能累计量的传输规约)培训
- 「常用」E9外部流程接口
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈