• Main Page
  • Classes
  • Files
  • File List
  • File Members

lib/bfLogging/src/logger.h

Go to the documentation of this file.
00001 
00006 #ifndef LOGGER_H
00007 #define LOGGER_H
00008 
00009 #include <QtGlobal>
00010 #include <QThreadStorage>
00011 #include <QHash>
00012 #include <QStringList>
00013 #include <QMutex>
00014 #include "logmessage.h"
00015 
00039 class Logger : public QObject {
00040     Q_OBJECT
00041     Q_DISABLE_COPY(Logger)
00042 public:
00043 
00049     Logger(QObject* parent);
00050 
00051 
00061     Logger(const QString msgFormat="{timestamp} {type} {msg}", const QString timestampFormat="dd.MM.yyyy hh:mm:ss.zzz", const QtMsgType minLevel=QtDebugMsg, const int bufferSize=0, QObject* parent = 0);
00062 
00064     virtual ~Logger();
00065 
00073     virtual void log(const QtMsgType type, const QString& message);
00074 
00079     void installMsgHandler();
00080 
00087     static void set(const QString& name, const QString& value);
00088 
00094     static void clear(const bool buffer=true, const bool variables=true);
00095 
00096 protected:
00097 
00099     QString msgFormat;
00100 
00102     QString timestampFormat;
00103 
00105     QtMsgType minLevel;
00106 
00108     int bufferSize;
00109 
00111     static QMutex mutex;
00112 
00117     virtual void write(const LogMessage* logMessage);
00118 
00119 private:
00120 
00122     static Logger* defaultLogger;
00123 
00134     static void msgHandler(const QtMsgType type, const char* message);
00135 
00137     static QThreadStorage<QHash<QString,QString>*> logVars;
00138 
00140     static QThreadStorage<QList<LogMessage*>*> buffers;
00141 
00142 };
00143 
00144 #endif // LOGGER_H

Generated on Mon Dec 26 2011 12:09:22 for QtWebApp by  doxygen 1.7.1