mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix log chattiness. Add a new configuration parameter "debug_logfile"
This commit is contained in:
31
src/Log.cpp
31
src/Log.cpp
@@ -1,15 +1,15 @@
|
||||
|
||||
#include "Log.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
boost::recursive_mutex Log::sLock;
|
||||
|
||||
#ifdef DEBUG
|
||||
LogSeverity Log::sMinSeverity = lsTRACE;
|
||||
#else
|
||||
LogSeverity Log::sMinSeverity = lsINFO;
|
||||
#endif
|
||||
LogSeverity Log::sMinSeverity = lsWARNING;
|
||||
|
||||
std::ofstream* Log::outStream = NULL;
|
||||
|
||||
Log::~Log()
|
||||
{
|
||||
@@ -26,9 +26,9 @@ Log::~Log()
|
||||
logMsg += oss.str();
|
||||
boost::recursive_mutex::scoped_lock sl(sLock);
|
||||
if (mSeverity >= sMinSeverity)
|
||||
{
|
||||
std::cerr << logMsg << std::endl;
|
||||
}
|
||||
if (outStream != NULL)
|
||||
(*outStream) << logMsg << std::endl;
|
||||
}
|
||||
|
||||
void Log::setMinSeverity(LogSeverity s)
|
||||
@@ -36,3 +36,20 @@ void Log::setMinSeverity(LogSeverity s)
|
||||
boost::recursive_mutex::scoped_lock sl(sLock);
|
||||
sMinSeverity = s;
|
||||
}
|
||||
|
||||
void Log::setLogFile(boost::filesystem::path path)
|
||||
{
|
||||
std::ofstream* newStream = new std::ofstream(path.c_str(), std::fstream::app);
|
||||
if (!newStream->good())
|
||||
{
|
||||
delete newStream;
|
||||
newStream = NULL;
|
||||
}
|
||||
|
||||
boost::recursive_mutex::scoped_lock sl(sLock);
|
||||
if (outStream != NULL)
|
||||
delete outStream;
|
||||
outStream = newStream;
|
||||
if (outStream)
|
||||
Log(lsINFO) << "Starting up";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user