|
EZLog
|
logger class More...
#include <Logger.h>
Public Types | |
| enum | Level { Log_Debug , Log_Info , Log_Warn , Log_Error , Log_Critical , Log_Off } |
| Log levels, divided into 6 levels, in ascending order. Only logs with a level higher than the setting will be output. The default log level is the lowest level Log_Debug_Info, which prints all levels of logs. More... | |
| using | Callback = std::function< void(const QString &)> |
| Callback function type. | |
Public Member Functions | |
| Logger & | notimestamp () |
| Return version without timestamp. | |
| Logger & | timestamp () |
| Return version with timestamp. | |
| Logger & | noleveltag () |
| Return version without level tag. | |
| Logger & | leveltag () |
| Return version with level tag. | |
| Logger & | nooutput () |
| Return version without output. | |
| Logger & | output () |
| Return version with output. | |
| ~Logger () | |
| Destruct and handle log information. | |
| Logger & | operator<< (QChar t) |
| Stream input of QChar type data. | |
| Logger & | operator<< (bool t) |
| Stream input of bool type data. | |
| Logger & | operator<< (char t) |
| Stream input of char type data. | |
| Logger & | operator<< (signed short t) |
| Stream input of signed short type data. | |
| Logger & | operator<< (unsigned short t) |
| Stream input of unsigned short type data. | |
| Logger & | operator<< (signed int t) |
| Stream input of signed int type data. | |
| Logger & | operator<< (unsigned int t) |
| Stream input of unsigned int type data. | |
| Logger & | operator<< (signed long t) |
| Stream input of signed long type data. | |
| Logger & | operator<< (unsigned long t) |
| Stream input of unsigned long type data. | |
| Logger & | operator<< (qint64 t) |
| Stream input of qint64 type data. | |
| Logger & | operator<< (quint64 t) |
| Stream input of quint64 type data. | |
| Logger & | operator<< (float t) |
| Stream input of float type data. | |
| Logger & | operator<< (double t) |
| Stream input of double type data. | |
| Logger & | operator<< (const char *t) |
| Stream input of char* type data. | |
| Logger & | operator<< (const QString &t) |
| Stream input of QString type data. | |
| Logger & | operator<< (const QStringRef &t) |
| Stream input of QStringRef type data. | |
| Logger & | operator<< (QStringView s) |
| Stream input of QStringView type data. | |
| Logger & | operator<< (QLatin1String t) |
| Stream input of QLatin1String type data. | |
| Logger & | operator<< (const QByteArray &t) |
| Stream input of QByteArray type data. | |
| Logger & | operator<< (const void *t) |
| Stream input of void* type data. | |
| Logger & | operator<< (QTextStreamFunction f) |
| Stream input of QTextStreamFunction type data. | |
| Logger & | operator<< (QTextStreamManipulator m) |
| Stream input of QTextStreamManipulator type data. | |
| template<typename SequentialContainer > | |
| Logger & | printSequentialContainer (Logger &logger, const char *which, const SequentialContainer &c) |
| Print sequential container message. | |
| template<typename T > | |
| Logger & | operator<< (const QList< T > &list) |
| Stream input of QList type data. | |
| template<typename T > | |
| Logger & | operator<< (const QVector< T > &vec) |
| Stream input of QVector type data. | |
| template<typename T , typename Alloc > | |
| Logger & | operator<< (const std::vector< T, Alloc > &vec) |
| Stream input of std::vector type data. | |
| template<typename T , typename Alloc > | |
| Logger & | operator<< (const std::list< T, Alloc > &list) |
| Stream input of std::list type data. | |
| template<typename Key , typename T , typename Compare , typename Alloc > | |
| Logger & | operator<< (const std::map< Key, T, Compare, Alloc > &map) |
| Stream input of std::map type data. | |
| template<typename Key , typename T , typename Compare , typename Alloc > | |
| Logger & | operator<< (const std::multimap< Key, T, Compare, Alloc > &map) |
| Stream input of std::multimap type data. | |
| template<class Key , class T > | |
| Logger & | operator<< (const QMap< Key, T > &map) |
| Stream input of QMap type data. | |
| template<class Key , class T > | |
| Logger & | operator<< (const QHash< Key, T > &hash) |
| Stream input of QHash type data. | |
| template<class T1 , class T2 > | |
| Logger & | operator<< (const QPair< T1, T2 > &pair) |
| Stream input of QPair type data. | |
| template<class T1 , class T2 > | |
| Logger & | operator<< (const std::pair< T1, T2 > &pair) |
| Stream input of std::pair type data. | |
| template<typename T > | |
| Logger & | operator<< (const QSet< T > &set) |
| Stream input of QSet type data. | |
| template<typename T > | |
| Logger & | operator<< (const QContiguousCache< T > &cache) |
| Stream input of QContiguousCache type data. | |
| Logger (Level level) | |
| Logger constructor. | |
| Logger (const Logger &other) | |
| Logger copy constructor. | |
| Logger & | operator= (const Logger &other) |
| Logger assignment operator. | |
| Logger & | space () |
| Write a space character to the message stream and return logger. Subsequent write operations will automatically insert a space. | |
| Logger & | nospace () |
| Disable automatic space insertion and return logger. | |
| Logger & | maybeSpace () |
| Write a space character to the stream, depending on the current setting for automatic insertion of spaces, and return logger. | |
| bool | autoInsertSpaces () const |
| Return current setting for automatic space insertion. | |
| void | setAutoInsertSpaces (bool set) |
| Set whether to automatically insert spaces. | |
Static Public Member Functions | |
| static bool | Initialize (const QString &projectName="Project", const QString &logPrefix="log", const QString &logDir="Logs/") |
| Initialize the logging system. | |
| static QString | errMsg () |
| Error message. Used to retrieve error information when the logging system fails to initialize. | |
| static void | InstallMessageHandler () |
| Take over qDebug output. | |
| static void | UninstallMessageHandler () |
| Cancel taking over qDebug output. | |
| static void | SetLogLevel (int level) |
| Set the log level, only logs with a level higher than the set level will be processed. When the log level is set to Log_Off, the log is turned off. | |
| static Level | logLevel () |
| Return current log level. | |
| static void | ReadConfig (const QString &filePath) |
| Read log level config file. The file should be in INI format, and this method will read the configuration with the key 'logLevel' and apply it. | |
| static void | SetShowTimeStamp (bool set) |
| Set whether to show timestamps by default. | |
| static void | SetTimeStampFormat (const QString &format) |
| Set timestamp format. | |
| static void | SetShowLevelTag (bool set) |
| Set whether to show level tag by default. | |
| static void | SetDebugTag (const QString &tag) |
| Set debug-level tag. | |
| static void | SetInfoTag (const QString &tag) |
| Set info-level tag. | |
| static void | SetWarnTag (const QString &tag) |
| Set warn-level tag. | |
| static void | SetErrorTag (const QString &tag) |
| Set error-level tag. | |
| static void | SetCriticalTag (const QString &tag) |
| Set critical-level tag. | |
| static void | SetNeedOutput (bool set) |
| Set whether to output log by default. | |
| static void | SetUnifiedCallback (const Callback &callback) |
| Set unified callback, triggered when logging any-level logs. | |
| static void | SetDebugCallback (const Callback &callback) |
| Set debug-level callback, triggered when logging debug-level logs. | |
| static void | SetInfoCallback (const Callback &callback) |
| Set info-level callback, triggered when logging info-level logs. | |
| static void | SetWarnCallback (const Callback &callback) |
| Set warn-level callback, triggered when logging warn-level logs. | |
| static void | SetErrorCallback (const Callback &callback) |
| Set error-level callback, triggered when logging error-level logs. | |
| static void | SetCriticalCallback (const Callback &callback) |
| Set critical-level callback, triggered when logging critical-level logs. | |
| static Logger | Debug () |
| Create debug-level logger. | |
| static Logger | Info () |
| Create info-level logger. | |
| static Logger | Warn () |
| Create warn-level logger. | |
| static Logger | Error () |
| Create error-level logger. | |
| static Logger | Critical () |
| Create critical-level logger. | |
| static Logger | Debug (const QString &msg) |
| Record debug-level information in the log. | |
| static Logger | Info (const QString &msg) |
| Record info-level information in the log. | |
| static Logger | Warn (const QString &msg) |
| Record warn-level information in the log. | |
| static Logger | Error (const QString &msg) |
| Record error-level information in the log. | |
| static Logger | Critical (const QString &msg) |
| Record critical-level information in the log. | |
logger class
| using EZLog::Logger::Callback = std::function<void(const QString&)> |
Callback function type.
| enum EZLog::Logger::Level |
Log levels, divided into 6 levels, in ascending order. Only logs with a level higher than the setting will be output. The default log level is the lowest level Log_Debug_Info, which prints all levels of logs.
|
inline |
Destruct and handle log information.
|
inlineexplicit |
Logger constructor.
| level | logger level |
|
inline |
Logger copy constructor.
| other | object to be copied |
|
inline |
Return current setting for automatic space insertion.
|
inlinestatic |
Create critical-level logger.
|
inlinestatic |
Record critical-level information in the log.
| msg | information to be logged |
|
inlinestatic |
Create debug-level logger.
|
inlinestatic |
Record debug-level information in the log.
| msg | information to be logged |
|
inlinestatic |
Error message. Used to retrieve error information when the logging system fails to initialize.
|
inlinestatic |
Create error-level logger.
|
inlinestatic |
Record error-level information in the log.
| msg | information to be logged |
|
inlinestatic |
Create info-level logger.
|
inlinestatic |
Record info-level information in the log.
| msg | information to be logged |
|
inlinestatic |
Initialize the logging system.
| projectName | project name |
| logPrefix | log file prefix |
| logDir | log storage location |
|
inlinestatic |
Take over qDebug output.
|
inline |
Return version with level tag.
|
inlinestatic |
Return current log level.
|
inline |
Write a space character to the stream, depending on the current setting for automatic insertion of spaces, and return logger.
|
inline |
Return version without level tag.
|
inline |
Return version without output.
|
inline |
Disable automatic space insertion and return logger.
|
inline |
Return version without timestamp.
|
inline |
Stream input of bool type data.
| t | data |
|
inline |
Stream input of char type data.
| t | data |
|
inline |
Stream input of char* type data.
| t | data |
|
inline |
Stream input of QByteArray type data.
| t | data |
|
inline |
Stream input of QContiguousCache type data.
| cache | data |
|
inline |
Stream input of QHash type data.
| hash | data |
|
inline |
Stream input of QList type data.
| list | data |
|
inline |
Stream input of QMap type data.
| map | data |
|
inline |
Stream input of QPair type data.
| pair | data |
|
inline |
Stream input of QSet type data.
| set | data |
|
inline |
Stream input of QString type data.
| t | data |
|
inline |
Stream input of QStringRef type data.
| t | data |
|
inline |
Stream input of QVector type data.
| vec | data |
|
inline |
Stream input of std::list type data.
| list | data |
|
inline |
Stream input of std::map type data.
| map | data |
|
inline |
Stream input of std::multimap type data.
| map | data |
|
inline |
Stream input of std::pair type data.
| pair | data |
|
inline |
Stream input of std::vector type data.
| vec | data |
|
inline |
Stream input of void* type data.
| t | data |
|
inline |
Stream input of double type data.
| t | data |
|
inline |
Stream input of float type data.
| t | data |
|
inline |
Stream input of QChar type data.
| t | data |
|
inline |
Stream input of qint64 type data.
| t | data |
|
inline |
Stream input of QLatin1String type data.
| t | data |
|
inline |
Stream input of QStringView type data.
| s | data |
|
inline |
Stream input of QTextStreamFunction type data.
| f | data |
|
inline |
Stream input of QTextStreamManipulator type data.
| m | data |
|
inline |
Stream input of quint64 type data.
| t | data |
|
inline |
Stream input of signed int type data.
| t | data |
|
inline |
Stream input of signed long type data.
| t | data |
|
inline |
Stream input of signed short type data.
| t | data |
|
inline |
Stream input of unsigned int type data.
| t | data |
|
inline |
Stream input of unsigned long type data.
| t | data |
|
inline |
Stream input of unsigned short type data.
| t | data |
|
inline |
Return version with output.
|
inline |
Print sequential container message.
| logger | logger |
| which | container name |
| c | container |
|
inlinestatic |
Read log level config file. The file should be in INI format, and this method will read the configuration with the key 'logLevel' and apply it.
| filePath | config file path |
|
inline |
Set whether to automatically insert spaces.
| set | whether to set |
|
inlinestatic |
Set critical-level callback, triggered when logging critical-level logs.
| callback | callback method |
|
inlinestatic |
Set critical-level tag.
| tag | tag content, default is [critical] |
|
inlinestatic |
Set debug-level callback, triggered when logging debug-level logs.
| callback | callback method |
|
inlinestatic |
Set debug-level tag.
| tag | tag content, default is [debug] |
|
inlinestatic |
Set error-level callback, triggered when logging error-level logs.
| callback | callback method |
|
inlinestatic |
Set error-level tag.
| tag | tag content, default is [error] |
|
inlinestatic |
Set info-level callback, triggered when logging info-level logs.
| callback | callback method |
|
inlinestatic |
Set info-level tag.
| tag | tag content, default is [info] |
|
inlinestatic |
Set the log level, only logs with a level higher than the set level will be processed. When the log level is set to Log_Off, the log is turned off.
| level | log level, default is Log_Debug |
|
inlinestatic |
Set whether to output log by default.
| set | whether to output, default is false |
|
inlinestatic |
Set whether to show level tag by default.
| set | whether to show, default is true |
|
inlinestatic |
Set whether to show timestamps by default.
| set | whether to show, default is false |
|
inlinestatic |
Set timestamp format.
| format | timestamp format, default is [HH:mm:ss] |
|
inlinestatic |
Set unified callback, triggered when logging any-level logs.
| callback | callback method |
|
inlinestatic |
Set warn-level callback, triggered when logging warn-level logs.
| callback | callback method |
|
inlinestatic |
Set warn-level tag.
| tag | tag content, default is [warning] |
|
inline |
Write a space character to the message stream and return logger. Subsequent write operations will automatically insert a space.
|
inline |
Return version with timestamp.
|
inlinestatic |
Cancel taking over qDebug output.
|
inlinestatic |
Create warn-level logger.
|
inlinestatic |
Record warn-level information in the log.
| msg | information to be logged |