SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
loggerwithfile.cpp
Go to the documentation of this file.
1 /*
2  * loggerwithfile.cpp
3  *
4  * Created on: Nov 11, 2017
5  * Author: f4exb
6  */
7 
8 #include "loggerwithfile.h"
9 
10 using namespace qtwebapp;
11 
13  :Logger(parent), fileLogger(0), useFileFlogger(false)
14 {
15  consoleLogger = new Logger(this);
16 }
17 
19 {
21  delete consoleLogger;
22 }
23 
24 void LoggerWithFile::createOrSetFileLogger(const FileLoggerSettings& settings, const int refreshInterval)
25 {
26  if (!fileLogger) {
27  fileLogger = new FileLogger(settings, refreshInterval, this);
28  } else {
30  }
31 }
32 
34 {
35  if (fileLogger)
36  {
37  delete fileLogger;
38  fileLogger = 0;
39  }
40 }
41 
42 void LoggerWithFile::log(const QtMsgType type, const QString& message, const QString &file, const QString &function, const int line)
43 {
44  consoleLogger->log(type,message,file,function,line);
45 
46  if (fileLogger && useFileFlogger) {
47  fileLogger->log(type,message,file,function,line);
48  }
49 }
50 
51 void LoggerWithFile::logToFile(const QtMsgType type, const QString& message, const QString &file, const QString &function, const int line)
52 {
53  if (fileLogger && useFileFlogger) {
54  fileLogger->log(type,message,file,function,line);
55  }
56 }
57 
58 void LoggerWithFile::clear(const bool buffer, const bool variables)
59 {
60  consoleLogger->clear(buffer,variables);
61 
62  if (fileLogger && useFileFlogger) {
63  fileLogger->clear(buffer,variables);
64  }
65 }
66 
67 void LoggerWithFile::setConsoleMinMessageLevel(const QtMsgType& msgLevel)
68 {
70 }
71 
72 void LoggerWithFile::setFileMinMessageLevel(const QtMsgType& msgLevel)
73 {
74  if (fileLogger) {
75  fileLogger->setMinMessageLevel(msgLevel);
76  }
77 }
78 
80 {
82  {
83  case QtDebugMsg:
84  levelStr = "debug";
85  break;
86  case QtInfoMsg:
87  levelStr = "info";
88  break;
89  case QtWarningMsg:
90  levelStr = "warning";
91  break;
92  case QtCriticalMsg:
93  case QtFatalMsg:
94  levelStr = "error";
95  break;
96  default:
97  levelStr = "debug";
98  break;
99  }
100 }
101 
103 {
104  switch (fileLogger->getMinMessageLevel())
105  {
106  case QtDebugMsg:
107  levelStr = "debug";
108  break;
109  case QtInfoMsg:
110  levelStr = "info";
111  break;
112  case QtWarningMsg:
113  levelStr = "warning";
114  break;
115  case QtCriticalMsg:
116  case QtFatalMsg:
117  levelStr = "error";
118  break;
119  default:
120  levelStr = "debug";
121  break;
122  }
123 }
124 
125 void LoggerWithFile::getLogFileName(QString& fileName)
126 {
128 }
void setFileLoggerSettings(const FileLoggerSettings &settings)
Definition: filelogger.h:93
void createOrSetFileLogger(const FileLoggerSettings &settings, const int refreshInterval=10000)
virtual void log(const QtMsgType type, const QString &message, const QString &file="", const QString &function="", const int line=0)
Definition: logger.cpp:153
Logger(QObject *parent)
Definition: logger.cpp:25
virtual void log(const QtMsgType type, const QString &message, const QString &file="", const QString &function="", const int line=0)
virtual void clear(const bool buffer=true, const bool variables=true)
Definition: logger.cpp:134
void setConsoleMinMessageLevel(const QtMsgType &msgLevel)
FileLoggerSettings getFileLoggerSettings() const
Definition: filelogger.h:87
QtMsgType getMinMessageLevel() const
Definition: logger.h:107
void logToFile(const QtMsgType type, const QString &message, const QString &file="", const QString &function="", const int line=0)
void getFileMinMessageLevelStr(QString &levelStr)
void setMinMessageLevel(const QtMsgType &minMsgLevel)
Definition: logger.h:100
LoggerWithFile(QObject *parent=0)
virtual void clear(const bool buffer=true, const bool variables=true)
void getConsoleMinMessageLevelStr(QString &levelStr)
void setFileMinMessageLevel(const QtMsgType &msgLevel)
void getLogFileName(QString &fileName)