X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Flogger.h;h=744c980037798aac5b02b4943ec8fd29536c48d8;hp=c372a11c1aa782316967613e980b6112e8b52853;hb=245a92b091b754bfdb8a5d6bd4da470ead5aaa29;hpb=c9b7f5cfe4377cc242c24212fff48aad70192b48 diff --git a/src/common/logger.h b/src/common/logger.h index c372a11c..744c9800 100644 --- a/src/common/logger.h +++ b/src/common/logger.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005 by the Quassel Project * + * Copyright (C) 2005-2012 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -21,54 +21,44 @@ #ifndef LOGGER_H #define LOGGER_H -#include "types.h" - -#include #include #include -class Logger { - public: - enum LogLevel { - DebugLevel, - InfoLevel, - WarningLevel, - ErrorLevel - }; +#include "quassel.h" +#include "types.h" - inline Logger(LogLevel level) : _stream(&_buffer, QIODevice::WriteOnly), _logLevel(level) {} - ~Logger(); +class Logger { +public: + inline Logger(Quassel::LogLevel level) : _stream(&_buffer, QIODevice::WriteOnly), _logLevel(level) {} + ~Logger(); - 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<<(const char* t) { _stream << QString::fromLocal8Bit(t); return *this; } - inline Logger &operator<<(bool t) { _stream << (t ? "true" : "false"); return *this; } + static void logMessage(QtMsgType type, const char *msg); - private: - void log(); - QTextStream _stream; - QString _buffer; - LogLevel _logLevel; -}; + 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; } -class quDebug : public Logger { - public: - inline quDebug() : Logger(Logger::DebugLevel) {} +private: + void log(); + QTextStream _stream; + QString _buffer; + Quassel::LogLevel _logLevel; }; class quInfo : public Logger { - public: - inline quInfo() : Logger(Logger::InfoLevel) {} +public: + inline quInfo() : Logger(Quassel::InfoLevel) {} }; class quWarning : public Logger { - public: - inline quWarning() : Logger(Logger::WarningLevel) {} +public: + inline quWarning() : Logger(Quassel::WarningLevel) {} }; class quError : public Logger { - public: - inline quError() : Logger(Logger::ErrorLevel) {} +public: + inline quError() : Logger(Quassel::ErrorLevel) {} }; + #endif