addapt filelogger to the new logging infraestructure

This commit is contained in:
ps 2011-01-17 20:30:12 +00:00
parent 920c8e4fbb
commit 9adb553f14
2 changed files with 4 additions and 3 deletions

View file

@ -67,7 +67,7 @@ void FileLogger::syncBufferToDisk()
} }
} }
void FileLogger::addMessage(int loglevel,string logmessage) void FileLogger::addMessage(string file,int line,int loglevel,string logmessage)
{ {
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
if(cfg.getLogRotationFrequency()>0&&last_rotation+(cfg.getLogRotationFrequency()*60)<time(NULL)) if(cfg.getLogRotationFrequency()>0&&last_rotation+(cfg.getLogRotationFrequency()*60)<time(NULL))
@ -76,6 +76,7 @@ void FileLogger::addMessage(int loglevel,string logmessage)
cout << "Rotating log to file " << getProcessedRotateFilename() << " at " << time(NULL) << " with a last rotation of " << last_rotation << endl; cout << "Rotating log to file " << getProcessedRotateFilename() << " at " << time(NULL) << " with a last rotation of " << last_rotation << endl;
#endif //REALLY_VERBOSE_DEBUG #endif //REALLY_VERBOSE_DEBUG
rotateLog(); rotateLog();
addMessage(__FILE__,__LINE__,LOG_DEBUG,"Rotated log to file " + getProcessedRotateFilename() + " at " + Utils::ulongtostr(time(NULL)) + " with a last rotation of " + Utils::ulongtostr(last_rotation));
} }
try try
{ {
@ -85,7 +86,7 @@ void FileLogger::addMessage(int loglevel,string logmessage)
{ {
openFile(cfg.getFileLoggerFilename()); openFile(cfg.getFileLoggerFilename());
if(NULL!=f) if(NULL!=f)
fprintf(f,"%s: %s\n",Utils::rfc2821_date().c_str(),logmessage.c_str()); fprintf(f,"%s: %s:%ld %s\n",Utils::rfc2821_date().c_str(),file.c_str(),long(line),logmessage.c_str());
} }
if(++linecount>30) if(++linecount>30)
{ {

View file

@ -52,7 +52,7 @@ class FileLogger: public Logger
public: public:
FileLogger(); FileLogger();
~FileLogger(); ~FileLogger();
void addMessage(int,string); void addMessage(string,int,int,string);
}; };
#endif //FILELOGGER_H #endif //FILELOGGER_H