scripted-diff: Rename BCLog::Logger member variables.
-BEGIN VERIFY SCRIPT- sed -i "s/fileout/m_fileout/" src/logging.h src/logging.cpp sed -i "s/mutexDebugLog/m_file_mutex/" src/logging.h src/logging.cpp sed -i "s/vMsgsBeforeOpenLog/m_msgs_before_open/" src/logging.h src/logging.cpp sed -i "s/logCategories/m_categories/" src/logging.h src/logging.cpp sed -i "s/fPrintToConsole/m_print_to_console/" src/logging.h src/logging.cpp src/init.cpp sed -i "s/fPrintToDebugLog/m_print_to_file/" src/logging.h src/logging.cpp src/init.cpp src/test/test_bitcoin.cpp src/bench/bench_bitcoin.cpp sed -i "s/fLogTimestamps/m_log_timestamps/" src/logging.h src/logging.cpp src/init.cpp sed -i "s/fLogTimeMicros/m_log_time_micros/" src/logging.h src/logging.cpp src/init.cpp sed -i "s/fReopenDebugLog/m_reopen_file/" src/logging.h src/logging.cpp src/init.cpp sed -i "s/fStartedNewLine/m_started_new_line/" src/logging.h src/logging.cpp -END VERIFY SCRIPT-
This commit is contained in:
parent
1eac317f25
commit
8e7b961388
5 changed files with 49 additions and 49 deletions
|
@ -46,7 +46,7 @@ main(int argc, char** argv)
|
||||||
RandomInit();
|
RandomInit();
|
||||||
ECC_Start();
|
ECC_Start();
|
||||||
SetupEnvironment();
|
SetupEnvironment();
|
||||||
g_logger->fPrintToDebugLog = false; // don't want to write to debug.log file
|
g_logger->m_print_to_file = false; // don't want to write to debug.log file
|
||||||
|
|
||||||
int64_t evaluations = gArgs.GetArg("-evals", DEFAULT_BENCH_EVALUATIONS);
|
int64_t evaluations = gArgs.GetArg("-evals", DEFAULT_BENCH_EVALUATIONS);
|
||||||
std::string regex_filter = gArgs.GetArg("-filter", DEFAULT_BENCH_FILTER);
|
std::string regex_filter = gArgs.GetArg("-filter", DEFAULT_BENCH_FILTER);
|
||||||
|
|
14
src/init.cpp
14
src/init.cpp
|
@ -305,7 +305,7 @@ static void HandleSIGTERM(int)
|
||||||
|
|
||||||
static void HandleSIGHUP(int)
|
static void HandleSIGHUP(int)
|
||||||
{
|
{
|
||||||
g_logger->fReopenDebugLog = true;
|
g_logger->m_reopen_file = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
@ -831,10 +831,10 @@ void InitLogging()
|
||||||
// debug.log.
|
// debug.log.
|
||||||
LogPrintf("\n\n\n\n\n");
|
LogPrintf("\n\n\n\n\n");
|
||||||
|
|
||||||
g_logger->fPrintToConsole = gArgs.GetBoolArg("-printtoconsole", !gArgs.GetBoolArg("-daemon", false));
|
g_logger->m_print_to_console = gArgs.GetBoolArg("-printtoconsole", !gArgs.GetBoolArg("-daemon", false));
|
||||||
g_logger->fPrintToDebugLog = !gArgs.IsArgNegated("-debuglogfile");
|
g_logger->m_print_to_file = !gArgs.IsArgNegated("-debuglogfile");
|
||||||
g_logger->fLogTimestamps = gArgs.GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS);
|
g_logger->m_log_timestamps = gArgs.GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS);
|
||||||
g_logger->fLogTimeMicros = gArgs.GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS);
|
g_logger->m_log_time_micros = gArgs.GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS);
|
||||||
|
|
||||||
fLogIPs = gArgs.GetBoolArg("-logips", DEFAULT_LOGIPS);
|
fLogIPs = gArgs.GetBoolArg("-logips", DEFAULT_LOGIPS);
|
||||||
|
|
||||||
|
@ -1225,7 +1225,7 @@ bool AppInitMain()
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
CreatePidFile(GetPidFile(), getpid());
|
CreatePidFile(GetPidFile(), getpid());
|
||||||
#endif
|
#endif
|
||||||
if (g_logger->fPrintToDebugLog) {
|
if (g_logger->m_print_to_file) {
|
||||||
if (gArgs.GetBoolArg("-shrinkdebugfile", g_logger->DefaultShrinkDebugFile())) {
|
if (gArgs.GetBoolArg("-shrinkdebugfile", g_logger->DefaultShrinkDebugFile())) {
|
||||||
// Do this first since it both loads a bunch of debug.log into memory,
|
// Do this first since it both loads a bunch of debug.log into memory,
|
||||||
// and because this needs to happen before any other debug.log printing
|
// and because this needs to happen before any other debug.log printing
|
||||||
|
@ -1237,7 +1237,7 @@ bool AppInitMain()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_logger->fLogTimestamps)
|
if (!g_logger->m_log_timestamps)
|
||||||
LogPrintf("Startup time: %s\n", FormatISO8601DateTime(GetTime()));
|
LogPrintf("Startup time: %s\n", FormatISO8601DateTime(GetTime()));
|
||||||
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
|
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
|
||||||
LogPrintf("Using data directory %s\n", GetDataDir().string());
|
LogPrintf("Using data directory %s\n", GetDataDir().string());
|
||||||
|
|
|
@ -38,21 +38,21 @@ fs::path BCLog::Logger::GetDebugLogPath() const
|
||||||
|
|
||||||
bool BCLog::Logger::OpenDebugLog()
|
bool BCLog::Logger::OpenDebugLog()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> scoped_lock(mutexDebugLog);
|
std::lock_guard<std::mutex> scoped_lock(m_file_mutex);
|
||||||
|
|
||||||
assert(fileout == nullptr);
|
assert(m_fileout == nullptr);
|
||||||
fs::path pathDebug = GetDebugLogPath();
|
fs::path pathDebug = GetDebugLogPath();
|
||||||
|
|
||||||
fileout = fsbridge::fopen(pathDebug, "a");
|
m_fileout = fsbridge::fopen(pathDebug, "a");
|
||||||
if (!fileout) {
|
if (!m_fileout) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
setbuf(fileout, nullptr); // unbuffered
|
setbuf(m_fileout, nullptr); // unbuffered
|
||||||
// dump buffered messages from before we opened the log
|
// dump buffered messages from before we opened the log
|
||||||
while (!vMsgsBeforeOpenLog.empty()) {
|
while (!m_msgs_before_open.empty()) {
|
||||||
FileWriteStr(vMsgsBeforeOpenLog.front(), fileout);
|
FileWriteStr(m_msgs_before_open.front(), m_fileout);
|
||||||
vMsgsBeforeOpenLog.pop_front();
|
m_msgs_before_open.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -60,7 +60,7 @@ bool BCLog::Logger::OpenDebugLog()
|
||||||
|
|
||||||
void BCLog::Logger::EnableCategory(BCLog::LogFlags flag)
|
void BCLog::Logger::EnableCategory(BCLog::LogFlags flag)
|
||||||
{
|
{
|
||||||
logCategories |= flag;
|
m_categories |= flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BCLog::Logger::EnableCategory(const std::string& str)
|
bool BCLog::Logger::EnableCategory(const std::string& str)
|
||||||
|
@ -73,7 +73,7 @@ bool BCLog::Logger::EnableCategory(const std::string& str)
|
||||||
|
|
||||||
void BCLog::Logger::DisableCategory(BCLog::LogFlags flag)
|
void BCLog::Logger::DisableCategory(BCLog::LogFlags flag)
|
||||||
{
|
{
|
||||||
logCategories &= ~flag;
|
m_categories &= ~flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BCLog::Logger::DisableCategory(const std::string& str)
|
bool BCLog::Logger::DisableCategory(const std::string& str)
|
||||||
|
@ -86,12 +86,12 @@ bool BCLog::Logger::DisableCategory(const std::string& str)
|
||||||
|
|
||||||
bool BCLog::Logger::WillLogCategory(BCLog::LogFlags category) const
|
bool BCLog::Logger::WillLogCategory(BCLog::LogFlags category) const
|
||||||
{
|
{
|
||||||
return (logCategories.load(std::memory_order_relaxed) & category) != 0;
|
return (m_categories.load(std::memory_order_relaxed) & category) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BCLog::Logger::DefaultShrinkDebugFile() const
|
bool BCLog::Logger::DefaultShrinkDebugFile() const
|
||||||
{
|
{
|
||||||
return logCategories == BCLog::NONE;
|
return m_categories == BCLog::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CLogCategoryDesc
|
struct CLogCategoryDesc
|
||||||
|
@ -178,13 +178,13 @@ std::string BCLog::Logger::LogTimestampStr(const std::string &str)
|
||||||
{
|
{
|
||||||
std::string strStamped;
|
std::string strStamped;
|
||||||
|
|
||||||
if (!fLogTimestamps)
|
if (!m_log_timestamps)
|
||||||
return str;
|
return str;
|
||||||
|
|
||||||
if (fStartedNewLine) {
|
if (m_started_new_line) {
|
||||||
int64_t nTimeMicros = GetTimeMicros();
|
int64_t nTimeMicros = GetTimeMicros();
|
||||||
strStamped = FormatISO8601DateTime(nTimeMicros/1000000);
|
strStamped = FormatISO8601DateTime(nTimeMicros/1000000);
|
||||||
if (fLogTimeMicros) {
|
if (m_log_time_micros) {
|
||||||
strStamped.pop_back();
|
strStamped.pop_back();
|
||||||
strStamped += strprintf(".%06dZ", nTimeMicros%1000000);
|
strStamped += strprintf(".%06dZ", nTimeMicros%1000000);
|
||||||
}
|
}
|
||||||
|
@ -197,9 +197,9 @@ std::string BCLog::Logger::LogTimestampStr(const std::string &str)
|
||||||
strStamped = str;
|
strStamped = str;
|
||||||
|
|
||||||
if (!str.empty() && str[str.size()-1] == '\n')
|
if (!str.empty() && str[str.size()-1] == '\n')
|
||||||
fStartedNewLine = true;
|
m_started_new_line = true;
|
||||||
else
|
else
|
||||||
fStartedNewLine = false;
|
m_started_new_line = false;
|
||||||
|
|
||||||
return strStamped;
|
return strStamped;
|
||||||
}
|
}
|
||||||
|
@ -210,30 +210,30 @@ int BCLog::Logger::LogPrintStr(const std::string &str)
|
||||||
|
|
||||||
std::string strTimestamped = LogTimestampStr(str);
|
std::string strTimestamped = LogTimestampStr(str);
|
||||||
|
|
||||||
if (fPrintToConsole) {
|
if (m_print_to_console) {
|
||||||
// print to console
|
// print to console
|
||||||
ret = fwrite(strTimestamped.data(), 1, strTimestamped.size(), stdout);
|
ret = fwrite(strTimestamped.data(), 1, strTimestamped.size(), stdout);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
if (fPrintToDebugLog) {
|
if (m_print_to_file) {
|
||||||
std::lock_guard<std::mutex> scoped_lock(mutexDebugLog);
|
std::lock_guard<std::mutex> scoped_lock(m_file_mutex);
|
||||||
|
|
||||||
// buffer if we haven't opened the log yet
|
// buffer if we haven't opened the log yet
|
||||||
if (fileout == nullptr) {
|
if (m_fileout == nullptr) {
|
||||||
ret = strTimestamped.length();
|
ret = strTimestamped.length();
|
||||||
vMsgsBeforeOpenLog.push_back(strTimestamped);
|
m_msgs_before_open.push_back(strTimestamped);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// reopen the log file, if requested
|
// reopen the log file, if requested
|
||||||
if (fReopenDebugLog) {
|
if (m_reopen_file) {
|
||||||
fReopenDebugLog = false;
|
m_reopen_file = false;
|
||||||
fs::path pathDebug = GetDebugLogPath();
|
fs::path pathDebug = GetDebugLogPath();
|
||||||
if (fsbridge::freopen(pathDebug,"a",fileout) != nullptr)
|
if (fsbridge::freopen(pathDebug,"a",m_fileout) != nullptr)
|
||||||
setbuf(fileout, nullptr); // unbuffered
|
setbuf(m_fileout, nullptr); // unbuffered
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = FileWriteStr(strTimestamped, fileout);
|
ret = FileWriteStr(strTimestamped, m_fileout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -59,42 +59,42 @@ namespace BCLog {
|
||||||
class Logger
|
class Logger
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
FILE* fileout = nullptr;
|
FILE* m_fileout = nullptr;
|
||||||
std::mutex mutexDebugLog;
|
std::mutex m_file_mutex;
|
||||||
std::list<std::string> vMsgsBeforeOpenLog;
|
std::list<std::string> m_msgs_before_open;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fStartedNewLine is a state variable that will suppress printing of
|
* m_started_new_line is a state variable that will suppress printing of
|
||||||
* the timestamp when multiple calls are made that don't end in a
|
* the timestamp when multiple calls are made that don't end in a
|
||||||
* newline.
|
* newline.
|
||||||
*/
|
*/
|
||||||
std::atomic_bool fStartedNewLine{true};
|
std::atomic_bool m_started_new_line{true};
|
||||||
|
|
||||||
/** Log categories bitfield. */
|
/** Log categories bitfield. */
|
||||||
std::atomic<uint32_t> logCategories{0};
|
std::atomic<uint32_t> m_categories{0};
|
||||||
|
|
||||||
std::string LogTimestampStr(const std::string& str);
|
std::string LogTimestampStr(const std::string& str);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool fPrintToConsole = false;
|
bool m_print_to_console = false;
|
||||||
bool fPrintToDebugLog = true;
|
bool m_print_to_file = true;
|
||||||
|
|
||||||
bool fLogTimestamps = DEFAULT_LOGTIMESTAMPS;
|
bool m_log_timestamps = DEFAULT_LOGTIMESTAMPS;
|
||||||
bool fLogTimeMicros = DEFAULT_LOGTIMEMICROS;
|
bool m_log_time_micros = DEFAULT_LOGTIMEMICROS;
|
||||||
|
|
||||||
std::atomic<bool> fReopenDebugLog{false};
|
std::atomic<bool> m_reopen_file{false};
|
||||||
|
|
||||||
/** Send a string to the log output */
|
/** Send a string to the log output */
|
||||||
int LogPrintStr(const std::string &str);
|
int LogPrintStr(const std::string &str);
|
||||||
|
|
||||||
/** Returns whether logs will be written to any output */
|
/** Returns whether logs will be written to any output */
|
||||||
bool Enabled() const { return fPrintToConsole || fPrintToDebugLog; }
|
bool Enabled() const { return m_print_to_console || m_print_to_file; }
|
||||||
|
|
||||||
fs::path GetDebugLogPath() const;
|
fs::path GetDebugLogPath() const;
|
||||||
bool OpenDebugLog();
|
bool OpenDebugLog();
|
||||||
void ShrinkDebugFile();
|
void ShrinkDebugFile();
|
||||||
|
|
||||||
uint32_t GetCategoryMask() const { return logCategories.load(); }
|
uint32_t GetCategoryMask() const { return m_categories.load(); }
|
||||||
|
|
||||||
void EnableCategory(LogFlags flag);
|
void EnableCategory(LogFlags flag);
|
||||||
bool EnableCategory(const std::string& str);
|
bool EnableCategory(const std::string& str);
|
||||||
|
|
|
@ -47,7 +47,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
|
||||||
SetupNetworking();
|
SetupNetworking();
|
||||||
InitSignatureCache();
|
InitSignatureCache();
|
||||||
InitScriptExecutionCache();
|
InitScriptExecutionCache();
|
||||||
g_logger->fPrintToDebugLog = false; // don't want to write to debug.log file
|
g_logger->m_print_to_file = false; // don't want to write to debug.log file
|
||||||
fCheckBlockIndex = true;
|
fCheckBlockIndex = true;
|
||||||
SelectParams(chainName);
|
SelectParams(chainName);
|
||||||
noui_connect();
|
noui_connect();
|
||||||
|
|
Loading…
Reference in a new issue