~ubuntu-branches/ubuntu/jaunty/quassel/jaunty-backports

« back to all changes in this revision

Viewing changes to src/common/logger.h

  • Committer: Bazaar Package Importer
  • Author(s): Harald Sitter
  • Date: 2008-11-17 15:22:46 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20081117152246-3lwlpnr4r08910kv
Tags: 0.3.1-0ubuntu1
* New upstream release (LP: #271403)
* Drop all patches originated from upstream (quassel_*)
* Compile with non-builtin quassel icons
  + Introduce new quassel-data package
  + quassel and quassel-client depend on quassel-data
  + Don't manually enforce icon installation for desktop files in debian/rules
  + Add quassel_01_fix_iconloader.patch
* Drop perl build dependency, I have no clue why it was added in the first
  place. Neither changelog nor Bazaar knows, and since quassel compiles just
  fine without it, removing it should be save.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <QTextStream>
29
29
 
30
30
class Logger {
31
 
  public:
32
 
    enum LogLevel {
33
 
      DebugLevel,
34
 
      InfoLevel,
35
 
      WarningLevel,
36
 
      ErrorLevel
37
 
    };
38
 
 
39
 
    inline Logger(LogLevel level) : _stream(&_buffer, QIODevice::WriteOnly), _logLevel(level) {}
40
 
    ~Logger();
41
 
 
42
 
    template<typename T>
43
 
    inline Logger &operator<<(const T &value) { _stream << value << " "; return *this; }
44
 
    inline Logger &operator<<(const QStringList & t) { _stream << t.join(" ") << " "; return *this; }
45
 
    inline Logger &operator<<(bool t) { _stream << (t ? "true" : "false") << " "; return *this; }
46
 
 
47
 
  private:
48
 
    void log();
49
 
    QTextStream _stream;
50
 
    QString _buffer;
51
 
    LogLevel _logLevel;
52
 
};
53
 
 
54
 
class quDebug : public Logger {
55
 
  public:
56
 
    inline quDebug() : Logger(Logger::DebugLevel) {}
 
31
public:
 
32
  enum LogLevel {
 
33
    DebugLevel,
 
34
    InfoLevel,
 
35
    WarningLevel,
 
36
    ErrorLevel
 
37
  };
 
38
 
 
39
  inline Logger(LogLevel level) : _stream(&_buffer, QIODevice::WriteOnly), _logLevel(level) {}
 
40
  ~Logger();
 
41
 
 
42
  static void logMessage(QtMsgType type, const char *msg);
 
43
 
 
44
  template<typename T>
 
45
  inline Logger &operator<<(const T &value) { _stream << value << " "; return *this; }
 
46
  inline Logger &operator<<(const QStringList & t) { _stream << t.join(" ") << " "; return *this; }
 
47
  inline Logger &operator<<(bool t) { _stream << (t ? "true" : "false") << " "; return *this; }
 
48
 
 
49
private:
 
50
  void log();
 
51
  QTextStream _stream;
 
52
  QString _buffer;
 
53
  LogLevel _logLevel;
57
54
};
58
55
 
59
56
class quInfo : public Logger {
60
 
  public:
61
 
    inline quInfo() : Logger(Logger::InfoLevel) {}
62
 
};
63
 
 
64
 
class quWarning : public Logger {
65
 
  public:
66
 
    inline quWarning() : Logger(Logger::WarningLevel) {}
67
 
};
68
 
 
69
 
class quError : public Logger {
70
 
  public:
71
 
    inline quError() : Logger(Logger::ErrorLevel) {}
72
 
};
 
57
public:
 
58
  inline quInfo() : Logger(Logger::InfoLevel) {}
 
59
};
 
60
 
73
61
#endif