mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-20 10:35:50 +00:00
add simple log rotating, tentative Ripple pathfinder work
This commit is contained in:
@@ -119,7 +119,7 @@
|
|||||||
1
|
1
|
||||||
|
|
||||||
[debug_logfile]
|
[debug_logfile]
|
||||||
debug.log
|
log/debug.log
|
||||||
|
|
||||||
[sntp_servers]
|
[sntp_servers]
|
||||||
time.windows.com
|
time.windows.com
|
||||||
|
|||||||
46
src/Log.cpp
46
src/Log.cpp
@@ -10,6 +10,8 @@ boost::recursive_mutex Log::sLock;
|
|||||||
LogSeverity Log::sMinSeverity = lsINFO;
|
LogSeverity Log::sMinSeverity = lsINFO;
|
||||||
|
|
||||||
std::ofstream* Log::outStream = NULL;
|
std::ofstream* Log::outStream = NULL;
|
||||||
|
boost::filesystem::path *Log::pathToLog = NULL;
|
||||||
|
uint32 Log::logRotateCounter = 0;
|
||||||
|
|
||||||
Log::~Log()
|
Log::~Log()
|
||||||
{
|
{
|
||||||
@@ -31,6 +33,48 @@ Log::~Log()
|
|||||||
(*outStream) << logMsg << std::endl;
|
(*outStream) << logMsg << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string Log::rotateLog(void)
|
||||||
|
{
|
||||||
|
boost::recursive_mutex::scoped_lock sl(sLock);
|
||||||
|
boost::filesystem::path abs_path;
|
||||||
|
std::string abs_path_str;
|
||||||
|
|
||||||
|
uint32 failsafe = 0;
|
||||||
|
|
||||||
|
std::string abs_new_path_str;
|
||||||
|
do {
|
||||||
|
std::string s;
|
||||||
|
std::stringstream out;
|
||||||
|
|
||||||
|
failsafe++;
|
||||||
|
if (failsafe == std::numeric_limits<uint32>::max()) {
|
||||||
|
return "unable to create new log file; too many log files!";
|
||||||
|
}
|
||||||
|
abs_path = boost::filesystem::absolute("");
|
||||||
|
abs_path /= *pathToLog;
|
||||||
|
abs_path_str = abs_path.parent_path().string();
|
||||||
|
out << logRotateCounter;
|
||||||
|
s = out.str();
|
||||||
|
|
||||||
|
|
||||||
|
abs_new_path_str = abs_path_str + "/" + s + + "_" + pathToLog->filename().string();
|
||||||
|
|
||||||
|
logRotateCounter++;
|
||||||
|
|
||||||
|
} while (boost::filesystem::exists(boost::filesystem::path(abs_new_path_str)));
|
||||||
|
|
||||||
|
outStream->close();
|
||||||
|
boost::filesystem::rename(abs_path, boost::filesystem::path(abs_new_path_str));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
setLogFile(*pathToLog);
|
||||||
|
|
||||||
|
return abs_new_path_str;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void Log::setMinSeverity(LogSeverity s)
|
void Log::setMinSeverity(LogSeverity s)
|
||||||
{
|
{
|
||||||
boost::recursive_mutex::scoped_lock sl(sLock);
|
boost::recursive_mutex::scoped_lock sl(sLock);
|
||||||
@@ -52,4 +96,6 @@ void Log::setLogFile(boost::filesystem::path path)
|
|||||||
outStream = newStream;
|
outStream = newStream;
|
||||||
if (outStream)
|
if (outStream)
|
||||||
Log(lsINFO) << "Starting up";
|
Log(lsINFO) << "Starting up";
|
||||||
|
|
||||||
|
pathToLog = new boost::filesystem::path(path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
// Ensure that we don't get value.h without writer.h
|
// Ensure that we don't get value.h without writer.h
|
||||||
#include "../json/json.h"
|
#include "../json/json.h"
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
enum LogSeverity
|
enum LogSeverity
|
||||||
{
|
{
|
||||||
lsTRACE = 0,
|
lsTRACE = 0,
|
||||||
@@ -33,6 +36,9 @@ protected:
|
|||||||
mutable std::ostringstream oss;
|
mutable std::ostringstream oss;
|
||||||
LogSeverity mSeverity;
|
LogSeverity mSeverity;
|
||||||
|
|
||||||
|
static boost::filesystem::path *pathToLog;
|
||||||
|
static uint32 logRotateCounter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Log(LogSeverity s) : mSeverity(s)
|
Log(LogSeverity s) : mSeverity(s)
|
||||||
{ ; }
|
{ ; }
|
||||||
@@ -51,6 +57,7 @@ public:
|
|||||||
|
|
||||||
static void setMinSeverity(LogSeverity);
|
static void setMinSeverity(LogSeverity);
|
||||||
static void setLogFile(boost::filesystem::path);
|
static void setLogFile(boost::filesystem::path);
|
||||||
|
static std::string rotateLog(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -14,6 +14,11 @@
|
|||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "RippleLines.h"
|
#include "RippleLines.h"
|
||||||
|
|
||||||
|
#include "Pathfinder.h"
|
||||||
|
#include "Conversion.h"
|
||||||
|
|
||||||
|
extern uint160 humanTo160(const std::string& buf);
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
@@ -1795,6 +1800,16 @@ Json::Value RPCServer::doSend(const Json::Value& params)
|
|||||||
|
|
||||||
STPathSet spsPaths;
|
STPathSet spsPaths;
|
||||||
|
|
||||||
|
uint160 srcCurrencyID;
|
||||||
|
bool ret_b;
|
||||||
|
ret_b = false;
|
||||||
|
STAmount::currencyFromString(srcCurrencyID, sSrcCurrency);
|
||||||
|
|
||||||
|
Pathfinder pf(naSrcAccountID, naDstAccountID, srcCurrencyID, saDstAmount);
|
||||||
|
|
||||||
|
ret_b = pf.findPaths(5, 1, spsPaths);
|
||||||
|
// TODO: Nope; the above can't be right
|
||||||
|
|
||||||
trans = Transaction::sharedPayment(
|
trans = Transaction::sharedPayment(
|
||||||
naAccountPublic, naAccountPrivate,
|
naAccountPublic, naAccountPrivate,
|
||||||
naSrcAccountID,
|
naSrcAccountID,
|
||||||
@@ -2518,6 +2533,11 @@ Json::Value RPCServer::doLogin(const Json::Value& params)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Json::Value RPCServer::doLogRotate(const Json::Value& params)
|
||||||
|
{
|
||||||
|
return Log::rotateLog();
|
||||||
|
}
|
||||||
|
|
||||||
Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params)
|
Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params)
|
||||||
{
|
{
|
||||||
Log(lsTRACE) << "RPC:" << command;
|
Log(lsTRACE) << "RPC:" << command;
|
||||||
@@ -2543,6 +2563,7 @@ Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params
|
|||||||
{ "data_fetch", &RPCServer::doDataFetch, 1, 1, true },
|
{ "data_fetch", &RPCServer::doDataFetch, 1, 1, true },
|
||||||
{ "data_store", &RPCServer::doDataStore, 2, 2, true },
|
{ "data_store", &RPCServer::doDataStore, 2, 2, true },
|
||||||
{ "ledger", &RPCServer::doLedger, 0, 2, false, optNetwork },
|
{ "ledger", &RPCServer::doLedger, 0, 2, false, optNetwork },
|
||||||
|
{ "logrotate", &RPCServer::doLogRotate, 0, 0, true, optCurrent },
|
||||||
{ "nickname_info", &RPCServer::doNicknameInfo, 1, 1, false, optCurrent },
|
{ "nickname_info", &RPCServer::doNicknameInfo, 1, 1, false, optCurrent },
|
||||||
{ "nickname_set", &RPCServer::doNicknameSet, 2, 3, false, optCurrent },
|
{ "nickname_set", &RPCServer::doNicknameSet, 2, 3, false, optCurrent },
|
||||||
{ "offer_create", &RPCServer::doOfferCreate, 9, 10, false, optCurrent },
|
{ "offer_create", &RPCServer::doOfferCreate, 9, 10, false, optCurrent },
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ private:
|
|||||||
Json::Value doDataFetch(const Json::Value& params);
|
Json::Value doDataFetch(const Json::Value& params);
|
||||||
Json::Value doDataStore(const Json::Value& params);
|
Json::Value doDataStore(const Json::Value& params);
|
||||||
Json::Value doLedger(const Json::Value& params);
|
Json::Value doLedger(const Json::Value& params);
|
||||||
|
Json::Value doLogRotate(const Json::Value& params);
|
||||||
Json::Value doNicknameInfo(const Json::Value& params);
|
Json::Value doNicknameInfo(const Json::Value& params);
|
||||||
Json::Value doNicknameSet(const Json::Value& params);
|
Json::Value doNicknameSet(const Json::Value& params);
|
||||||
Json::Value doOfferCreate(const Json::Value& params);
|
Json::Value doOfferCreate(const Json::Value& params);
|
||||||
@@ -184,6 +185,7 @@ private:
|
|||||||
|
|
||||||
Json::Value doLogin(const Json::Value& params);
|
Json::Value doLogin(const Json::Value& params);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static pointer create(boost::asio::io_service& io_service, NetworkOPs* mNetOps)
|
static pointer create(boost::asio::io_service& io_service, NetworkOPs* mNetOps)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ void printHelp(const po::options_description& desc)
|
|||||||
cout << " data_fetch <key>" << endl;
|
cout << " data_fetch <key>" << endl;
|
||||||
cout << " data_store <key> <value>" << endl;
|
cout << " data_store <key> <value>" << endl;
|
||||||
cout << " ledger [<id>|current|lastclosed] [full]" << endl;
|
cout << " ledger [<id>|current|lastclosed] [full]" << endl;
|
||||||
|
cout << " logrotate " << endl;
|
||||||
cout << " nickname_info <nickname>" << endl;
|
cout << " nickname_info <nickname>" << endl;
|
||||||
cout << " nickname_set <seed> <paying_account> <nickname> [<offer_minimum>] [<authorization>]" << endl;
|
cout << " nickname_set <seed> <paying_account> <nickname> [<offer_minimum>] [<authorization>]" << endl;
|
||||||
cout << " offer_create <seed> <paying_account> <taker_pays_amount> <taker_pays_currency> <taker_pays_issuer> <takers_gets_amount> <takers_gets_currency> <takers_gets_issuer> <expires> [passive]" << endl;
|
cout << " offer_create <seed> <paying_account> <taker_pays_amount> <taker_pays_currency> <taker_pays_issuer> <takers_gets_amount> <takers_gets_currency> <takers_gets_issuer> <expires> [passive]" << endl;
|
||||||
|
|||||||
Submodule websocketpp updated: f78b9df4ad...dd9899c34b
Reference in New Issue
Block a user