3.QT中的debug相关的函数,以及文件锁的使用
1
新建项目T33Debug
main.cpp |
#include #include #include void { //使用一个文件锁,当在写文件的时候,要等写完之后才能继续执行 static mutex.lock(); QString //在QMessageLogContext中保存的有文件名,文件行号,方法等信息 strContext.sprintf("%s QString if(type { QFile file.open(QFile::WriteOnly file.write(output.toUtf8()); file.close(); } if(type { QFile file.open(QFile::WriteOnly|QFile::Append); file.write(output.toUtf8()); file.close(); } if(type { QFile file.open(QFile::WriteOnly file.write(output.toUtf8()); file.close(); } if(type { QFile file.open(QFile::WriteOnly file.write(output.toUtf8()); file.close(); } printf("%s",output.toUtf8().data()); mutex.unlock(); } int { //To //handler qInstallMessageHandler(MyMessageHandler); qDebug() qDebug("%s,%d","outputdebug",1); qWarning() qCritical() //可以放开下面的一句,然后发现目录也有相应的fatal.log文件 //qFatal("fatal } |
运行结果: 输入目录(E:\QT\build-T33Debug-Desktop_Qt_5_3_MinGW_32bit-Debug)的文件如下: |
最新文章
- 激活Microsoft Office professional plus 2010
- n全排列输出和 n个数的组合(数字范围a~b)
- 《信息安全系统设计基础》第一次实验报告--Linux 基础入门
- go 函数
- Yii2框架数据库增删改查小结
- iOS -数据持久化之CoreData
- OpenJDK1.8 安装
- 【设计模式 - 7】之过滤器模式(Filter)
- Writing a ServiceMain Function(使用RegisterServiceCtrlHandler函数)
- mysql常用语法
- maven入门(6)maven的生命周期
- Oracle 查看链接数、创建索引等的DDL语句
- Ambari2.6.2 HDP2.6.5 大数据集群搭建
- [国家集训队]middle 解题报告
- python2.x编码问题实例
- Mongodb集群搭建之 Sharding+ Replica Sets集群架构(2)
- Django---Mysql数据库链接
- dD Geometry Kernel ( Geometry Kernels) CGAL 4.13 -User Manual
- LIS学习笔记(两种算法)O(n^2) 和 O(nlogn)
- [转]glyphicons-halflings-regular字体 图标