X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Flogger.h;h=d9b51a63a44d9fede89534c7551c4cd2ed214567;hp=168b3bdd80c1128978c8ab98012af29dcb7db9a4;hb=7897b8623a42967511e31c68d5c102033a1dcdb9;hpb=8699dd758516d0ded076811e8ea656adc95e69d0 diff --git a/src/common/logger.h b/src/common/logger.h index 168b3bdd..d9b51a63 100644 --- a/src/common/logger.h +++ b/src/common/logger.h @@ -18,24 +18,44 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _LOGGER_H_ -#define _LOGGER_H_ - -#include - -class Logger : public QObject { - Q_OBJECT - - public: - Logger(); - virtual ~Logger(); - - - - private: - //void messageHandler(QtMsgType type, const char *msg); +#ifndef LOGGER_H +#define LOGGER_H + +#include "types.h" + +#include +#include +#include + +class Logger { +public: + enum LogLevel { + DebugLevel, + InfoLevel, + WarningLevel, + ErrorLevel + }; + + inline Logger(LogLevel level) : _stream(&_buffer, QIODevice::WriteOnly), _logLevel(level) {} + ~Logger(); + + static void logMessage(QtMsgType type, const char *msg); + + template + inline Logger &operator<<(const T &value) { _stream << value << " "; return *this; } + inline Logger &operator<<(const QStringList & t) { _stream << t.join(" ") << " "; return *this; } + inline Logger &operator<<(bool t) { _stream << (t ? "true" : "false") << " "; return *this; } + +private: + void log(); + QTextStream _stream; + QString _buffer; + LogLevel _logLevel; }; - +class quInfo : public Logger { +public: + inline quInfo() : Logger(Logger::InfoLevel) {} +}; #endif