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.
Public Member Functions | Private Attributes | List of all members
qtwebapp::LoggerWithFile Class Reference

#include <loggerwithfile.h>

+ Inheritance diagram for qtwebapp::LoggerWithFile:
+ Collaboration diagram for qtwebapp::LoggerWithFile:

Public Member Functions

 LoggerWithFile (QObject *parent=0)
 
virtual ~LoggerWithFile ()
 
void createOrSetFileLogger (const FileLoggerSettings &settings, const int refreshInterval=10000)
 
void destroyFileLogger ()
 
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)
 
bool getUseFileLogger () const
 
void setUseFileLogger (bool use)
 
bool hasFileLogger () const
 
FileLoggerSettings getFileLoggerSettings () const
 
void setFileLoggerSettings (const FileLoggerSettings &settings)
 
void setConsoleMinMessageLevel (const QtMsgType &msgLevel)
 
void setFileMinMessageLevel (const QtMsgType &msgLevel)
 
void getConsoleMinMessageLevelStr (QString &levelStr)
 
void getFileMinMessageLevelStr (QString &levelStr)
 
void getLogFileName (QString &fileName)
 
void logToFile (const QtMsgType type, const QString &message, const QString &file="", const QString &function="", const int line=0)
 
- Public Member Functions inherited from qtwebapp::Logger
 Logger (QObject *parent)
 
 Logger (const QString msgFormat="{timestamp} {type} {msg}", const QString timestampFormat="yyyy-MM-dd HH:mm:ss.zzz", const QtMsgType minLevel=QtDebugMsg, const int bufferSize=0, QObject *parent=0)
 
virtual ~Logger ()
 
void installMsgHandler ()
 
void setMinMessageLevel (const QtMsgType &minMsgLevel)
 
QtMsgType getMinMessageLevel () const
 

Private Attributes

LoggerconsoleLogger
 
FileLoggerfileLogger
 
bool useFileFlogger
 

Additional Inherited Members

- Static Public Member Functions inherited from qtwebapp::Logger
static void set (const QString &name, const QString &value)
 
- Protected Member Functions inherited from qtwebapp::Logger
virtual void write (const LogMessage *logMessage)
 
- Protected Attributes inherited from qtwebapp::Logger
QString msgFormat
 
QString timestampFormat
 
QtMsgType minLevel
 
int bufferSize
 
- Static Protected Attributes inherited from qtwebapp::Logger
static QMutex mutex
 

Detailed Description

Logs messages to console and optionally to a file simultaneously.

See also
FileLogger for a description of the two underlying file logger.
Logger for a description of the console loger.

Definition at line 25 of file loggerwithfile.h.

Constructor & Destructor Documentation

◆ LoggerWithFile()

LoggerWithFile::LoggerWithFile ( QObject *  parent = 0)

Definition at line 12 of file loggerwithfile.cpp.

References consoleLogger, and qtwebapp::Logger::Logger().

13  :Logger(parent), fileLogger(0), useFileFlogger(false)
14 {
15  consoleLogger = new Logger(this);
16 }
Logger(QObject *parent)
Definition: logger.cpp:25
+ Here is the call graph for this function:

◆ ~LoggerWithFile()

LoggerWithFile::~LoggerWithFile ( )
virtual

Definition at line 18 of file loggerwithfile.cpp.

References consoleLogger, and destroyFileLogger().

19 {
21  delete consoleLogger;
22 }
+ Here is the call graph for this function:

Member Function Documentation

◆ clear()

void LoggerWithFile::clear ( const bool  buffer = true,
const bool  variables = true 
)
virtual

Clear the thread-local data of the current thread. This method is thread safe.

Parameters
bufferWhether to clear the backtrace buffer
variablesWhether to clear the log variables

Reimplemented from qtwebapp::Logger.

Definition at line 58 of file loggerwithfile.cpp.

References qtwebapp::Logger::clear(), consoleLogger, fileLogger, and useFileFlogger.

59 {
60  consoleLogger->clear(buffer,variables);
61 
62  if (fileLogger && useFileFlogger) {
63  fileLogger->clear(buffer,variables);
64  }
65 }
virtual void clear(const bool buffer=true, const bool variables=true)
Definition: logger.cpp:134
+ Here is the call graph for this function:

◆ createOrSetFileLogger()

void LoggerWithFile::createOrSetFileLogger ( const FileLoggerSettings settings,
const int  refreshInterval = 10000 
)

Definition at line 24 of file loggerwithfile.cpp.

References fileLogger, and qtwebapp::FileLogger::setFileLoggerSettings().

Referenced by MainCore::setLoggingOptions(), and MainWindow::setLoggingOptions().

25 {
26  if (!fileLogger) {
27  fileLogger = new FileLogger(settings, refreshInterval, this);
28  } else {
30  }
31 }
void setFileLoggerSettings(const FileLoggerSettings &settings)
Definition: filelogger.h:93
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroyFileLogger()

void LoggerWithFile::destroyFileLogger ( )

Definition at line 33 of file loggerwithfile.cpp.

References fileLogger.

Referenced by ~LoggerWithFile().

34 {
35  if (fileLogger)
36  {
37  delete fileLogger;
38  fileLogger = 0;
39  }
40 }
+ Here is the caller graph for this function:

◆ getConsoleMinMessageLevelStr()

void LoggerWithFile::getConsoleMinMessageLevelStr ( QString &  levelStr)

Definition at line 79 of file loggerwithfile.cpp.

References consoleLogger, and qtwebapp::Logger::getMinMessageLevel().

Referenced by WebAPIAdapterGUI::instanceLoggingGet(), WebAPIAdapterSrv::instanceLoggingGet(), WebAPIAdapterSrv::instanceSummary(), and WebAPIAdapterGUI::instanceSummary().

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 }
QtMsgType getMinMessageLevel() const
Definition: logger.h:107
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFileLoggerSettings()

FileLoggerSettings qtwebapp::LoggerWithFile::getFileLoggerSettings ( ) const
inline

Get a file logger settings copy

Returns
The current file logger settings

Definition at line 64 of file loggerwithfile.h.

Referenced by MainCore::setLoggingOptions(), and MainWindow::setLoggingOptions().

64 { return fileLogger->getFileLoggerSettings(); }
FileLoggerSettings getFileLoggerSettings() const
Definition: filelogger.h:87
+ Here is the caller graph for this function:

◆ getFileMinMessageLevelStr()

void LoggerWithFile::getFileMinMessageLevelStr ( QString &  levelStr)

Definition at line 102 of file loggerwithfile.cpp.

References fileLogger, and qtwebapp::Logger::getMinMessageLevel().

Referenced by WebAPIAdapterGUI::instanceLoggingGet(), WebAPIAdapterSrv::instanceLoggingGet(), WebAPIAdapterSrv::instanceSummary(), and WebAPIAdapterGUI::instanceSummary().

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 }
QtMsgType getMinMessageLevel() const
Definition: logger.h:107
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLogFileName()

void LoggerWithFile::getLogFileName ( QString &  fileName)

Definition at line 125 of file loggerwithfile.cpp.

References fileLogger, qtwebapp::FileLoggerSettings::fileName, and qtwebapp::FileLogger::getFileLoggerSettings().

Referenced by WebAPIAdapterGUI::instanceLoggingGet(), WebAPIAdapterSrv::instanceLoggingGet(), WebAPIAdapterSrv::instanceSummary(), and WebAPIAdapterGUI::instanceSummary().

126 {
128 }
FileLoggerSettings getFileLoggerSettings() const
Definition: filelogger.h:87
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUseFileLogger()

bool qtwebapp::LoggerWithFile::getUseFileLogger ( ) const
inline

◆ hasFileLogger()

bool qtwebapp::LoggerWithFile::hasFileLogger ( ) const
inline

Definition at line 58 of file loggerwithfile.h.

Referenced by MainCore::setLoggingOptions(), and MainWindow::setLoggingOptions().

58 { return fileLogger != 0; }
+ Here is the caller graph for this function:

◆ log()

void LoggerWithFile::log ( const QtMsgType  type,
const QString &  message,
const QString &  file = "",
const QString &  function = "",
const int  line = 0 
)
virtual

Decorate and log the message, if type>=minLevel. This method is thread safe.

Parameters
typeMessage type (level)
messageMessage text
fileName of the source file where the message was generated (usually filled with the macro FILE)
functionName of the function where the message was generated (usually filled with the macro LINE)
lineLine Number of the source file, where the message was generated (usually filles with the macro func or FUNCTION)
See also
LogMessage for a description of the message decoration.

Reimplemented from qtwebapp::Logger.

Definition at line 42 of file loggerwithfile.cpp.

References consoleLogger, fileLogger, qtwebapp::Logger::log(), and useFileFlogger.

43 {
44  consoleLogger->log(type,message,file,function,line);
45 
46  if (fileLogger && useFileFlogger) {
47  fileLogger->log(type,message,file,function,line);
48  }
49 }
virtual void log(const QtMsgType type, const QString &message, const QString &file="", const QString &function="", const int line=0)
Definition: logger.cpp:153
+ Here is the call graph for this function:

◆ logToFile()

void LoggerWithFile::logToFile ( const QtMsgType  type,
const QString &  message,
const QString &  file = "",
const QString &  function = "",
const int  line = 0 
)

This will log to file only

Definition at line 51 of file loggerwithfile.cpp.

References fileLogger, qtwebapp::Logger::log(), and useFileFlogger.

Referenced by MainCore::setLoggingOptions(), and MainWindow::setLoggingOptions().

52 {
53  if (fileLogger && useFileFlogger) {
54  fileLogger->log(type,message,file,function,line);
55  }
56 }
virtual void log(const QtMsgType type, const QString &message, const QString &file="", const QString &function="", const int line=0)
Definition: logger.cpp:153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setConsoleMinMessageLevel()

void LoggerWithFile::setConsoleMinMessageLevel ( const QtMsgType &  msgLevel)

Definition at line 67 of file loggerwithfile.cpp.

References consoleLogger, and qtwebapp::Logger::setMinMessageLevel().

Referenced by MainCore::setLoggingOptions(), and MainWindow::setLoggingOptions().

68 {
70 }
void setMinMessageLevel(const QtMsgType &minMsgLevel)
Definition: logger.h:100
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFileLoggerSettings()

void qtwebapp::LoggerWithFile::setFileLoggerSettings ( const FileLoggerSettings settings)
inline

Set new file logger settings data

Parameters
Filelogger settings to replace current data

Definition at line 70 of file loggerwithfile.h.

70 { fileLogger->setFileLoggerSettings(settings); }
void setFileLoggerSettings(const FileLoggerSettings &settings)
Definition: filelogger.h:93

◆ setFileMinMessageLevel()

void LoggerWithFile::setFileMinMessageLevel ( const QtMsgType &  msgLevel)

Definition at line 72 of file loggerwithfile.cpp.

References fileLogger, and qtwebapp::Logger::setMinMessageLevel().

Referenced by MainCore::setLoggingOptions(), and MainWindow::setLoggingOptions().

73 {
74  if (fileLogger) {
75  fileLogger->setMinMessageLevel(msgLevel);
76  }
77 }
void setMinMessageLevel(const QtMsgType &minMsgLevel)
Definition: logger.h:100
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUseFileLogger()

void qtwebapp::LoggerWithFile::setUseFileLogger ( bool  use)
inline

Definition at line 57 of file loggerwithfile.h.

Referenced by MainCore::setLoggingOptions(), and MainWindow::setLoggingOptions().

+ Here is the caller graph for this function:

Member Data Documentation

◆ consoleLogger

Logger* qtwebapp::LoggerWithFile::consoleLogger
private

First console logger

Definition at line 84 of file loggerwithfile.h.

Referenced by clear(), getConsoleMinMessageLevelStr(), log(), LoggerWithFile(), setConsoleMinMessageLevel(), and ~LoggerWithFile().

◆ fileLogger

FileLogger* qtwebapp::LoggerWithFile::fileLogger
private

◆ useFileFlogger

bool qtwebapp::LoggerWithFile::useFileFlogger
private

Use file logger indicator

Definition at line 90 of file loggerwithfile.h.

Referenced by clear(), log(), and logToFile().


The documentation for this class was generated from the following files: