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,6 +31,11 @@
|
||||
# Note: $XDG_CONFIG_HOME defaults to $HOME/.config
|
||||
# $XDG_DATA_HOME defaults to $HOME/.local/share
|
||||
#
|
||||
# [debug_logfile]
|
||||
# Specifies were a debug logfile is kept. By default, no debug log is kept
|
||||
#
|
||||
# Example: debug.log
|
||||
#
|
||||
# [validators_site]:
|
||||
# Specifies where to find validators.txt for UNL boostrapping and RPC command unl_network.
|
||||
# During alpha testing, this defaults to: redstem.com
|
||||
@@ -117,6 +122,9 @@
|
||||
[rpc_allow_remote]
|
||||
1
|
||||
|
||||
[debug_logfile]
|
||||
debug.log
|
||||
|
||||
[validation_seed]
|
||||
snTBDmrhUK3znvF8AaQURLm4UCkbS
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "utils.h"
|
||||
#include "TaggedCache.h"
|
||||
#include "boost/filesystem.hpp"
|
||||
#include "Log.h"
|
||||
|
||||
Application* theApp = NULL;
|
||||
|
||||
@@ -54,6 +55,8 @@ void Application::stop()
|
||||
void Application::run()
|
||||
{
|
||||
assert(mTxnDB == NULL);
|
||||
if (!theConfig.DEBUG_LOGFILE.empty())
|
||||
Log::setLogFile(theConfig.DEBUG_LOGFILE);
|
||||
|
||||
//
|
||||
// Construct databases.
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <iostream>
|
||||
|
||||
#define SECTION_ACCOUNT_PROBE_MAX "account_probe_max"
|
||||
#define SECTION_DEBUG_LOGFILE "debug_logfile"
|
||||
#define SECTION_FEE_ACCOUNT_CREATE "fee_account_create"
|
||||
#define SECTION_FEE_DEFAULT "fee_default"
|
||||
#define SECTION_FEE_NICKNAME_CREATE "fee_nickname_create"
|
||||
@@ -233,6 +234,9 @@ void Config::load()
|
||||
|
||||
if (sectionSingleB(secConfig, SECTION_UNL_DEFAULT, strTemp))
|
||||
UNL_DEFAULT = strTemp;
|
||||
|
||||
if (sectionSingleB(secConfig, SECTION_DEBUG_LOGFILE, strTemp))
|
||||
DEBUG_LOGFILE = strTemp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
boost::filesystem::path CONFIG_FILE;
|
||||
boost::filesystem::path CONFIG_DIR;
|
||||
boost::filesystem::path DATA_DIR;
|
||||
boost::filesystem::path DEBUG_LOGFILE;
|
||||
boost::filesystem::path UNL_DEFAULT;
|
||||
|
||||
std::string VALIDATORS_SITE; // Where to find validators.txt on the Internet.
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <sstream>
|
||||
|
||||
#include <boost/thread/recursive_mutex.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
enum LogSeverity
|
||||
{
|
||||
@@ -24,6 +25,7 @@ private:
|
||||
protected:
|
||||
static boost::recursive_mutex sLock;
|
||||
static LogSeverity sMinSeverity;
|
||||
static std::ofstream* outStream;
|
||||
|
||||
mutable std::ostringstream oss;
|
||||
LogSeverity mSeverity;
|
||||
@@ -45,6 +47,7 @@ public:
|
||||
}
|
||||
|
||||
static void setMinSeverity(LogSeverity);
|
||||
static void setLogFile(boost::filesystem::path);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user