mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-27 02:09:14 -05:00
71 lines
1.5 KiB
C++
71 lines
1.5 KiB
C++
/*
|
|
* loggerwithfile.cpp
|
|
*
|
|
* Created on: Nov 11, 2017
|
|
* Author: f4exb
|
|
*/
|
|
|
|
#include "loggerwithfile.h"
|
|
|
|
using namespace qtwebapp;
|
|
|
|
LoggerWithFile::LoggerWithFile(QObject* parent)
|
|
:Logger(parent), fileLogger(0), useFileFlogger(false)
|
|
{
|
|
consoleLogger = new Logger(this);
|
|
}
|
|
|
|
LoggerWithFile::~LoggerWithFile()
|
|
{
|
|
destroyFileLogger();
|
|
delete consoleLogger;
|
|
}
|
|
|
|
void LoggerWithFile::createOrSetFileLogger(const FileLoggerSettings& settings, const int refreshInterval)
|
|
{
|
|
if (!fileLogger) {
|
|
fileLogger = new FileLogger(settings, refreshInterval, this);
|
|
} else {
|
|
fileLogger->setFileLoggerSettings(settings);
|
|
}
|
|
}
|
|
|
|
void LoggerWithFile::destroyFileLogger()
|
|
{
|
|
if (fileLogger)
|
|
{
|
|
delete fileLogger;
|
|
fileLogger = 0;
|
|
}
|
|
}
|
|
|
|
void LoggerWithFile::log(const QtMsgType type, const QString& message, const QString &file, const QString &function, const int line)
|
|
{
|
|
consoleLogger->log(type,message,file,function,line);
|
|
|
|
if (fileLogger && useFileFlogger) {
|
|
fileLogger->log(type,message,file,function,line);
|
|
}
|
|
}
|
|
|
|
void LoggerWithFile::clear(const bool buffer, const bool variables)
|
|
{
|
|
consoleLogger->clear(buffer,variables);
|
|
|
|
if (fileLogger && useFileFlogger) {
|
|
fileLogger->clear(buffer,variables);
|
|
}
|
|
}
|
|
|
|
void LoggerWithFile::setConsoleMinMessageLevel(const QtMsgType& msgLevel)
|
|
{
|
|
consoleLogger->setMinMessageLevel(msgLevel);
|
|
}
|
|
|
|
void LoggerWithFile::setFileMinMessageLevel(const QtMsgType& msgLevel)
|
|
{
|
|
if (fileLogger) {
|
|
fileLogger->setMinMessageLevel(msgLevel);
|
|
}
|
|
}
|