addapt filelogger to the new logging infraestructure
This commit is contained in:
parent
920c8e4fbb
commit
9adb553f14
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue