34#pragma warning(disable: 4127)
65 static QMap<QString,Logger*> staticLog;
66 QMap<QString,Logger*>::iterator it = staticLog.find(zone);
67 if (it == staticLog.end())
70 for (
auto& destination: Destinations::instance().destinations())
74 return **staticLog.insert(zone, logger);
80 void addDestination(std::shared_ptr<Destination> destination);
82 void setLoggingLevel(
Level newLevel);
84 Level loggingLevel()
const;
85 const QString& zone()
const;
88 bool isLoggingEnabled()
const;
90 bool isTraceEnabled()
const;
92 bool isDebugEnabled()
const;
94 bool isInfoEnabled()
const;
96 bool isWarnEnabled()
const;
98 bool isErrorEnabled()
const;
100 bool isFatalEnabled()
const;
125 Logger(
const QString& aZone = QLatin1String(
""));
129 void write(
const QString& message);
140#ifndef QS_LOG_LINE_NUMBERS
141 #define QLOG_TRACE() \
142 if( logger.loggingLevel() > QsLogging::TraceLevel ){} \
143 else QsLogging::Logger::Helper(QsLogging::TraceLevel, logger.zone()).stream()
144 #define QLOG_DEBUG() \
145 if( logger.loggingLevel() > QsLogging::DebugLevel ){} \
146 else QsLogging::Logger::Helper(QsLogging::DebugLevel, logger.zone()).stream()
147 #define QLOG_INFO() \
148 if( logger.loggingLevel() > QsLogging::InfoLevel ){} \
149 else QsLogging::Logger::Helper(QsLogging::InfoLevel, logger.zone()).stream()
150 #define QLOG_WARN() \
151 if( logger.loggingLevel() > QsLogging::WarnLevel ){} \
152 else QsLogging::Logger::Helper(QsLogging::WarnLevel, logger.zone()).stream()
153 #define QLOG_ERROR() \
154 if( logger.loggingLevel() > QsLogging::ErrorLevel ){} \
155 else QsLogging::Logger::Helper(QsLogging::ErrorLevel, logger.zone()).stream()
156 #define QLOG_FATAL() \
157 QsLogging::Logger::Helper(QsLogging::FatalLevel, logger.zone()).stream()
159 #define QLOG_TRACE() \
160 if( logger.loggingLevel() > QsLogging::TraceLevel ){} \
161 else QsLogging::Logger::Helper(QsLogging::TraceLevel, logger.zone()).stream() << __FILE__ << '@' << __LINE__
162 #define QLOG_DEBUG() \
163 if( logger.loggingLevel() > QsLogging::DebugLevel ){} \
164 else QsLogging::Logger::Helper(QsLogging::DebugLevel, logger.zone()).stream() << __FILE__ << '@' << __LINE__
165 #define QLOG_INFO() \
166 if( logger.loggingLevel() > QsLogging::InfoLevel ){} \
167 else QsLogging::Logger::Helper(QsLogging::InfoLevel, logger.zone()).stream() << __FILE__ << '@' << __LINE__
168 #define QLOG_WARN() \
169 if( logger.loggingLevel() > QsLogging::WarnLevel ){} \
170 else QsLogging::Logger::Helper(QsLogging::WarnLevel, logger.zone()).stream() << __FILE__ << '@' << __LINE__
171 #define QLOG_ERROR() \
172 if( logger.loggingLevel() > QsLogging::ErrorLevel ){} \
173 else QsLogging::Logger::Helper(QsLogging::ErrorLevel, logger.zone()).stream() << __FILE__ << '@' << __LINE__
174 #define QLOG_FATAL() \
175 QsLogging::Logger::Helper(QsLogging::FatalLevel, logger.zone()).stream() << __FILE__ << '@' << __LINE__
#define LIMA_COMMONQSLOG_EXPORT
The helper forwards the streaming to QDebug and builds the final log message.
Helper(Level logLevel, const QString &zone)
static Logger & instance(const QString &zone=QLatin1String(""))
void addDestination(std::shared_ptr< Destination > destination)
Adds a log message destination. Don't add null destinations.
Logger & operator=(const Logger &)
LIMA_COMMONQSLOG_EXPORT QDebug & operator<<(QDebug &qd, const std::string &str)