renamed log class in service project to logger
This commit is contained in:
parent
3b2948d4dd
commit
686fc754b2
7 changed files with 29 additions and 28 deletions
|
@ -83,7 +83,7 @@ bool Logger::init()
|
|||
|
||||
void Logger::deInit()
|
||||
{
|
||||
qInstallMessageHandler(0);
|
||||
qInstallMessageHandler(nullptr);
|
||||
qSetMessagePattern("%{message}");
|
||||
m_textStream.setDevice(nullptr);
|
||||
m_file.close();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <QLocalSocket>
|
||||
|
||||
#include "router.h"
|
||||
#include "log.h"
|
||||
#include "logger.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include "tapcontroller_win.h"
|
||||
|
@ -111,16 +111,16 @@ QStringList IpcServer::getTapList()
|
|||
void IpcServer::cleanUp()
|
||||
{
|
||||
qDebug() << "IpcServer::cleanUp";
|
||||
Log::deinit();
|
||||
Log::cleanUp();
|
||||
Logger::deinit();
|
||||
Logger::cleanUp();
|
||||
}
|
||||
|
||||
void IpcServer::setLogsEnabled(bool enabled)
|
||||
{
|
||||
if (enabled) {
|
||||
Log::init();
|
||||
Logger::init();
|
||||
}
|
||||
else {
|
||||
Log::deinit();
|
||||
Logger::deinit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ set(HEADERS
|
|||
${CMAKE_CURRENT_LIST_DIR}/../../ipc/ipcserver.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../../ipc/ipcserverprocess.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/localserver.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/log.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/logger.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/router.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/systemservice.h
|
||||
)
|
||||
|
@ -25,7 +25,7 @@ set(SOURCES
|
|||
${CMAKE_CURRENT_LIST_DIR}/../../ipc/ipcserver.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/../../ipc/ipcserverprocess.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/localserver.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/log.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/logger.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/main.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/router.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/systemservice.cpp
|
||||
|
@ -82,9 +82,9 @@ endif()
|
|||
include(${CMAKE_CURRENT_LIST_DIR}/../src/qtservice.cmake)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
${CMAKE_CURRENT_LIST_DIR}/../../client
|
||||
${CMAKE_CURRENT_LIST_DIR}/../../ipc
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
|
@ -107,4 +107,4 @@ add_custom_command(
|
|||
${CMAKE_SOURCE_DIR}/deploy/data/${DEPLOY_ARTIFACT_PATH}
|
||||
$<TARGET_FILE_DIR:${PROJECT}>
|
||||
COMMAND_EXPAND_LISTS
|
||||
)
|
||||
)
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
#include "logger.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "log.h"
|
||||
#include "defines.h"
|
||||
#include "utilities.h"
|
||||
|
||||
QFile Log::m_file;
|
||||
QTextStream Log::m_textStream;
|
||||
QString Log::m_logFileName = QString("%1.log").arg(SERVICE_NAME);
|
||||
QFile Logger::m_file;
|
||||
QTextStream Logger::m_textStream;
|
||||
QString Logger::m_logFileName = QString("%1.log").arg(SERVICE_NAME);
|
||||
|
||||
void debugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg)
|
||||
{
|
||||
|
@ -17,12 +18,12 @@ void debugMessageHandler(QtMsgType type, const QMessageLogContext& context, cons
|
|||
return;
|
||||
}
|
||||
|
||||
Log::m_textStream << qFormatLogMessage(type, context, msg) << Qt::endl << Qt::flush;
|
||||
Logger::m_textStream << qFormatLogMessage(type, context, msg) << Qt::endl << Qt::flush;
|
||||
|
||||
std::cout << qFormatLogMessage(type, context, msg).toStdString() << std::endl << std::flush;
|
||||
}
|
||||
|
||||
bool Log::init()
|
||||
bool Logger::init()
|
||||
{
|
||||
if (m_file.isOpen()) return true;
|
||||
|
||||
|
@ -46,19 +47,19 @@ bool Log::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void Log::deinit()
|
||||
void Logger::deinit()
|
||||
{
|
||||
m_file.close();
|
||||
m_textStream.setDevice(nullptr);
|
||||
qInstallMessageHandler(nullptr);
|
||||
}
|
||||
|
||||
QString Log::serviceLogFileNamePath()
|
||||
QString Logger::serviceLogFileNamePath()
|
||||
{
|
||||
return m_file.fileName();
|
||||
}
|
||||
|
||||
void Log::clearLogs()
|
||||
void Logger::clearLogs()
|
||||
{
|
||||
bool isLogActive = m_file.isOpen();
|
||||
m_file.close();
|
||||
|
@ -78,7 +79,7 @@ void Log::clearLogs()
|
|||
}
|
||||
}
|
||||
|
||||
void Log::cleanUp()
|
||||
void Logger::cleanUp()
|
||||
{
|
||||
clearLogs();
|
||||
deinit();
|
|
@ -1,12 +1,12 @@
|
|||
#ifndef LOG_H
|
||||
#define LOG_H
|
||||
#ifndef LOGGER_H
|
||||
#define LOGGER_H
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QString>
|
||||
#include <QTextStream>
|
||||
|
||||
class Log
|
||||
class Logger
|
||||
{
|
||||
public:
|
||||
static bool init();
|
||||
|
@ -25,4 +25,4 @@ private:
|
|||
static QTextStream m_textStream;
|
||||
};
|
||||
|
||||
#endif // LOG_H
|
||||
#endif // LOGGER_H
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "defines.h"
|
||||
#include "localserver.h"
|
||||
#include "log.h"
|
||||
#include "logger.h"
|
||||
#include "systemservice.h"
|
||||
#include "utilities.h"
|
||||
|
||||
|
@ -20,7 +20,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
Utils::initializePath(Utils::systemLogPath());
|
||||
|
||||
Log::init();
|
||||
Logger::init();
|
||||
|
||||
if (argc == 2) {
|
||||
qInfo() << "Started as console application";
|
||||
|
|
|
@ -10,7 +10,7 @@ HEADERS = \
|
|||
../../ipc/ipcserver.h \
|
||||
../../ipc/ipcserverprocess.h \
|
||||
localserver.h \
|
||||
log.h \
|
||||
logger.h \
|
||||
router.h \
|
||||
systemservice.h
|
||||
|
||||
|
@ -19,7 +19,7 @@ SOURCES = \
|
|||
../../ipc/ipcserver.cpp \
|
||||
../../ipc/ipcserverprocess.cpp \
|
||||
localserver.cpp \
|
||||
log.cpp \
|
||||
logger.cpp \
|
||||
main.cpp \
|
||||
router.cpp \
|
||||
systemservice.cpp
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue