modify
This commit is contained in:
@@ -0,0 +1,27 @@
|
|||||||
|
QT += core
|
||||||
|
TEMPLATE = lib
|
||||||
|
DEFINES += MYLOGGER_LIBRARY
|
||||||
|
|
||||||
|
CONFIG += c++17
|
||||||
|
|
||||||
|
INCLUDEPATH += $$PWD/
|
||||||
|
|
||||||
|
DESTDIR = $$PWD/../../Build/Libs
|
||||||
|
MOC_DIR = $$PWD/Build/moc
|
||||||
|
OBJECTS_DIR = $$PWD/Build/objs
|
||||||
|
RCC_DIR = $$PWD/Build/resources
|
||||||
|
UI_DIR = $$PWD/Build/ui
|
||||||
|
|
||||||
|
#在release下输出debug信息
|
||||||
|
DEFINES += QT_MESSAGELOGCONTEXT
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
$$PWD/loghandler.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
$$PWD/loghandler.cpp
|
||||||
|
|
||||||
|
unix {
|
||||||
|
target.path = /usr/lib
|
||||||
|
}
|
||||||
|
!isEmpty(target.path): INSTALLS += target
|
||||||
+24
-24
@@ -52,24 +52,24 @@ private:
|
|||||||
/// ///
|
/// ///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#if 0
|
#if 0
|
||||||
//template <typename T> QMutex Singleton<T>::mutex;
|
template <typename T> QMutex Singleton<T>::mutex;
|
||||||
//template <typename T> QScopedPointer<T> Singleton<T>::instance;
|
template <typename T> QScopedPointer<T> Singleton<T>::instance;
|
||||||
|
|
||||||
//template <typename T>
|
template <typename T>
|
||||||
//T& Singleton<T>::getInstance()
|
T& Singleton<T>::getInstance()
|
||||||
//{
|
{
|
||||||
// if (instance.isNull())
|
if (instance.isNull())
|
||||||
// {
|
{
|
||||||
// mutex.lock();
|
mutex.lock();
|
||||||
// if (instance.isNull())
|
if (instance.isNull())
|
||||||
// {
|
{
|
||||||
// instance.reset(new T());
|
instance.reset(new T());
|
||||||
// }
|
}
|
||||||
// mutex.unlock();
|
mutex.unlock();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// return *instance.data();
|
return *instance.data();
|
||||||
//}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -78,14 +78,14 @@ private:
|
|||||||
/// ///
|
/// ///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#if 0
|
#if 0
|
||||||
//#define SINGLETON(Class) \
|
#define SINGLETON(Class) \
|
||||||
//private: \
|
private: \
|
||||||
// Class(); \
|
Class(); \
|
||||||
// ~Class(); \
|
~Class(); \
|
||||||
// Class(const Class &other); \
|
Class(const Class &other); \
|
||||||
// Class& operator=(const Class &other); \
|
Class& operator=(const Class &other); \
|
||||||
// friend class Singleton<Class>; \
|
friend class Singleton<Class>; \
|
||||||
// friend struct QScopedPointerDeleter<Class>;
|
friend struct QScopedPointerDeleter<Class>;
|
||||||
#endif
|
#endif
|
||||||
#define SINGLETON(Class) friend class Singleton<Class>
|
#define SINGLETON(Class) friend class Singleton<Class>
|
||||||
#endif // SINGLETON_H
|
#endif // SINGLETON_H
|
||||||
|
|||||||
+11
-1
@@ -1,5 +1,15 @@
|
|||||||
#include "loghandler.h"
|
#include "loghandler.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QMutexLocker>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QTextCodec>
|
||||||
|
#include "Singleton.h"
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
QMutex g_mutex;
|
QMutex g_mutex;
|
||||||
|
|||||||
+2
-12
@@ -1,19 +1,9 @@
|
|||||||
#ifndef LOGHANDLER_H
|
#ifndef LOGHANDLER_H
|
||||||
#define LOGHANDLER_H
|
#define LOGHANDLER_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <QObject>
|
||||||
#include <QDebug>
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QMutexLocker>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QTextStream>
|
|
||||||
#include <QTextCodec>
|
|
||||||
#include "Singleton.h"
|
|
||||||
|
|
||||||
class LogHandler
|
class Q_DECL_EXPORT LogHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void installMessageHandler(); // 给Qt安装消息处理函数
|
void installMessageHandler(); // 给Qt安装消息处理函数
|
||||||
|
|||||||
Reference in New Issue
Block a user