add option to control verboseness of log
This commit is contained in:
parent
f1bd5df29d
commit
2dde08953a
|
@ -150,6 +150,12 @@ string,submit_stats_username,"anonymous"
|
|||
* password
|
||||
string,submit_stats_password,"anonymous"
|
||||
|
||||
* log level:
|
||||
* 0: log only errors
|
||||
* 1: log errors and information (default)
|
||||
* 2: debug (passwords might be written in plaintext with this option, so use with care)
|
||||
int,log_level,1
|
||||
|
||||
#if LOGGER_CLASS==FileLogger
|
||||
* if you are using the filelogger, which file to log to.
|
||||
string,file_logger_filename,"hermes.log"
|
||||
|
|
|
@ -70,12 +70,12 @@ void FileLogger::syncBufferToDisk()
|
|||
|
||||
void FileLogger::addMessage(string file,int line,int loglevel,string logmessage)
|
||||
{
|
||||
|
||||
if(loglevel>cfg.getLogLevel()) return;
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
if(cfg.getLogRotationFrequency()>0&&last_rotation+(cfg.getLogRotationFrequency()*60)<time(NULL))
|
||||
{
|
||||
#ifdef REALLY_VERBOSE_DEBUG
|
||||
cout << "Rotating log to file " << getProcessedRotateFilename() << " at " << time(NULL) << " with a last rotation of " << last_rotation << endl;
|
||||
#endif //REALLY_VERBOSE_DEBUG
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -39,9 +39,9 @@ class Logger
|
|||
#endif //WIN32
|
||||
|
||||
#ifndef LOG_INFO
|
||||
#define LOG_INFO 0
|
||||
#define LOG_DEBUG 1
|
||||
#define LOG_ERR 2
|
||||
#define LOG_ERR 0
|
||||
#define LOG_INFO 1
|
||||
#define LOG_DEBUG 2
|
||||
#endif //LOG_INFO
|
||||
#include "FileLogger.h"
|
||||
#include "NullLogger.h"
|
||||
|
|
|
@ -36,8 +36,11 @@ void UnixLogger::addMessage(string file,int line,int loglevel,string logmessage)
|
|||
{
|
||||
string message;
|
||||
|
||||
message=file+":"+Utils::inttostr(line)+" [" + Utils::inttostr(connection_id) + "] " + logmessage;
|
||||
if(false==cfg.getBackground())
|
||||
cout << message << endl;
|
||||
syslog(loglevel,message.c_str());
|
||||
if(loglevel<=cfg.getLogLevel())
|
||||
{
|
||||
message=file+":"+Utils::inttostr(line)+" [" + Utils::inttostr(connection_id) + "] " + logmessage;
|
||||
if(false==cfg.getBackground())
|
||||
cout << message << endl;
|
||||
syslog(loglevel,message.c_str());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue