You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
tianzhendong d4d18d81a0 v1.0.0 10 months ago
CMakeLists.txt v1.0.0 10 months ago
MyLogger.pri v1.0.0 10 months ago
README.md v1.0.0 10 months ago
Singleton.h v1.0.0 10 months ago
loghandler.cpp v1.0.0 10 months ago
loghandler.h v1.0.0 10 months ago

README.md

概述

  • Singleton.h

懒汉模式的单例模板类

  • loghandler.h/cpp

日志类

  • MyLogger.pri

子模块qt pri文件

使用

克隆代码

克隆代码并复制到工程Libs目录下

添加子工程

在主工程pro文件中,添加:

include($$PWD/Libs/MyLogger/MyLogger.pri)

使用

日志使用

#include <QApplication>
//头文件
#include "loghandler.h"
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
	//安装
	LogHandler::Get().installMessageHandler();
	Debug() << "Hello";
   qDebug() << "当前时间是: " << QTime::currentTime().toString("hh:mm:ss");
   qInfo() << QString("God bless you!");
	//卸载
	LogHandler::Get().uninstallMessageHandler();
    return a.exec();
}

单例模板类使用

#include "Singleton.h"
class AppConfig : public QObject
{
    Q_OBJECT
    //通过宏
    SINGLETON(AppConfig);
    .....
}