30 #include "filterlog.h"
34 #include <tqdatetime.h>
40 using namespace KMail;
56 patternResult | appliedAction;
75 TQString timedLog =
"[" + TQTime::currentTime().toString() +
"] ";
76 if ( contentType & ~meta )
81 emit logEntryAdded( timedLog );
82 mCurrentLogSize += timedLog.length();
93 if ( size >= 0 && size < 1024 )
96 emit logStateChanged();
104 kdDebug(5006) <<
"----- starting filter log -----" << endl;
105 for ( TQStringList::Iterator it =
mLogEntries.begin();
108 kdDebug(5006) << *it << endl;
110 kdDebug(5006) <<
"------ end of filter log ------" << endl;
115 void FilterLog::checkLogSize()
119 kdDebug(5006) <<
"Filter log: memory limit reached, starting to discard old items, size = "
120 << TQString::number( mCurrentLogSize ) << endl;
124 TQValueListIterator<TQString> it =
mLogEntries.begin();
127 mCurrentLogSize -= (*it).length();
129 kdDebug(5006) <<
"Filter log: new size = "
130 << TQString::number( mCurrentLogSize ) << endl;
134 kdDebug(5006) <<
"Filter log: size reduction disaster!" << endl;
145 TQFile file( fileName );
146 if( file.open( IO_WriteOnly ) ) {
147 fchmod( file.handle(), S_IRUSR | S_IWUSR );
149 TQDataStream ds( &file );
150 for ( TQStringList::Iterator it =
mLogEntries.begin();
153 TQString tmpString = *it +
'\n';
154 TQCString cstr( tmpString.local8Bit() );
155 ds.writeRawBytes( cstr, cstr.size() );
165 #include "filterlog.moc"
long mMaxLogSize
max size for kept log items, when reached the last recently added items are discarded -1 means unlimi...
void dump()
dump the log - for testing purposes
int mAllowedTypes
types currently allowed to be legged
TQStringList mLogEntries
The list contains the single log pieces.
bool mLogging
the log status
void clear()
discard collected log data
bool saveToFile(TQString fileName)
save the log to a file - returns true if okay
void add(TQString logEntry, ContentType contentType)
add a log entry
virtual ~FilterLog()
destructor
bool isLogging()
check the logging state
ContentType
log data types
void setMaxLogSize(long size=-1)
control the size of the log
FilterLog()
Non-public constructor needed by the singleton implementation.
KMail Filter Log Collector.
static FilterLog * instance()
access to the singleton instance