00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 #ifndef LOG4QT_LISTAPPENDER_H
00026 #define LOG4QT_LISTAPPENDER_H
00027 
00028 
00029 
00030 
00031 
00032 
00033 #include "log4qt/appenderskeleton.h"
00034 
00035 #include <QtCore/QList>
00036 #include <QtCore/QMutex>
00037 #include "log4qt/loggingevent.h"
00038 
00039 
00040 
00041 
00042 
00043 
00044 namespace Log4Qt
00045 {
00046         
00056     class ListAppender : public AppenderSkeleton
00057     {
00058         Q_OBJECT
00059         
00067         Q_PROPERTY(bool configuratorList READ configuratorList WRITE setConfiguratorList)
00068         
00069         
00076         Q_PROPERTY(int maxCount READ maxCount WRITE setMaxCount)
00077         
00078     public:
00079         ListAppender(QObject *pParent = 0);
00080         virtual ~ListAppender();
00081     private:
00082         ListAppender(const ListAppender &rOther); 
00083         ListAppender &operator=(const ListAppender &rOther); 
00084             
00085     public:
00092         bool configuratorList() const;
00093         
00094         QList<LoggingEvent> list() const;
00095         int maxCount() const;
00096         
00105         void setConfiguratorList(bool isConfiguratorList);
00106         
00107         void setMaxCount(int n);
00108         
00109         QList<LoggingEvent> clearList();
00110         virtual bool requiresLayout() const;
00111         
00112     protected:
00113         virtual void append(const LoggingEvent &rEvent);
00114         
00115 #ifndef QT_NO_DEBUG_STREAM
00116 
00127         virtual QDebug debug(QDebug &rDebug) const;
00128 #endif // QT_NO_DEBUG_STREAM
00129     
00135         void ensureMaxCount();
00136         
00137     private:
00138         volatile bool mConfiguratorList; 
00139         QList<LoggingEvent> mList;
00140         volatile int mMaxCount;
00141     };
00142     
00143     
00144     
00145 
00146 
00147     
00148     
00149     
00150 
00151 
00152     
00153     inline bool ListAppender::configuratorList() const
00154     {   
00155         return mConfiguratorList;   }
00156 
00157     inline int ListAppender::maxCount() const
00158     {   return mMaxCount;    }
00159     
00160     inline void ListAppender::setConfiguratorList(bool isConfiguratorList)
00161     {   
00162         mConfiguratorList = isConfiguratorList;   }
00163 
00164     inline bool ListAppender::requiresLayout() const
00165     {   return false;    }
00166     
00167     
00168 } 
00169 
00170 
00171 
00172 
00173 
00174 #endif // LOG4QT_LISTAPPENDER_H