Skip to content

Commit 8e7b961

Browse files
author
Jim Posen
committed
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-
1 parent 1eac317 commit 8e7b961

File tree

5 files changed

+49
-49
lines changed

5 files changed

+49
-49
lines changed

src/bench/bench_bitcoin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ main(int argc, char** argv)
4646
RandomInit();
4747
ECC_Start();
4848
SetupEnvironment();
49-
g_logger->fPrintToDebugLog = false; // don't want to write to debug.log file
49+
g_logger->m_print_to_file = false; // don't want to write to debug.log file
5050

5151
int64_t evaluations = gArgs.GetArg("-evals", DEFAULT_BENCH_EVALUATIONS);
5252
std::string regex_filter = gArgs.GetArg("-filter", DEFAULT_BENCH_FILTER);

src/init.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ static void HandleSIGTERM(int)
305305

306306
static void HandleSIGHUP(int)
307307
{
308-
g_logger->fReopenDebugLog = true;
308+
g_logger->m_reopen_file = true;
309309
}
310310

311311
#ifndef WIN32
@@ -831,10 +831,10 @@ void InitLogging()
831831
// debug.log.
832832
LogPrintf("\n\n\n\n\n");
833833

834-
g_logger->fPrintToConsole = gArgs.GetBoolArg("-printtoconsole", !gArgs.GetBoolArg("-daemon", false));
835-
g_logger->fPrintToDebugLog = !gArgs.IsArgNegated("-debuglogfile");
836-
g_logger->fLogTimestamps = gArgs.GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS);
837-
g_logger->fLogTimeMicros = gArgs.GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS);
834+
g_logger->m_print_to_console = gArgs.GetBoolArg("-printtoconsole", !gArgs.GetBoolArg("-daemon", false));
835+
g_logger->m_print_to_file = !gArgs.IsArgNegated("-debuglogfile");
836+
g_logger->m_log_timestamps = gArgs.GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS);
837+
g_logger->m_log_time_micros = gArgs.GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS);
838838

839839
fLogIPs = gArgs.GetBoolArg("-logips", DEFAULT_LOGIPS);
840840

@@ -1225,7 +1225,7 @@ bool AppInitMain()
12251225
#ifndef WIN32
12261226
CreatePidFile(GetPidFile(), getpid());
12271227
#endif
1228-
if (g_logger->fPrintToDebugLog) {
1228+
if (g_logger->m_print_to_file) {
12291229
if (gArgs.GetBoolArg("-shrinkdebugfile", g_logger->DefaultShrinkDebugFile())) {
12301230
// Do this first since it both loads a bunch of debug.log into memory,
12311231
// and because this needs to happen before any other debug.log printing
@@ -1237,7 +1237,7 @@ bool AppInitMain()
12371237
}
12381238
}
12391239

1240-
if (!g_logger->fLogTimestamps)
1240+
if (!g_logger->m_log_timestamps)
12411241
LogPrintf("Startup time: %s\n", FormatISO8601DateTime(GetTime()));
12421242
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
12431243
LogPrintf("Using data directory %s\n", GetDataDir().string());

src/logging.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,29 @@ fs::path BCLog::Logger::GetDebugLogPath() const
3838

3939
bool BCLog::Logger::OpenDebugLog()
4040
{
41-
std::lock_guard<std::mutex> scoped_lock(mutexDebugLog);
41+
std::lock_guard<std::mutex> scoped_lock(m_file_mutex);
4242

43-
assert(fileout == nullptr);
43+
assert(m_fileout == nullptr);
4444
fs::path pathDebug = GetDebugLogPath();
4545

46-
fileout = fsbridge::fopen(pathDebug, "a");
47-
if (!fileout) {
46+
m_fileout = fsbridge::fopen(pathDebug, "a");
47+
if (!m_fileout) {
4848
return false;
4949
}
5050

51-
setbuf(fileout, nullptr); // unbuffered
51+
setbuf(m_fileout, nullptr); // unbuffered
5252
// dump buffered messages from before we opened the log
53-
while (!vMsgsBeforeOpenLog.empty()) {
54-
FileWriteStr(vMsgsBeforeOpenLog.front(), fileout);
55-
vMsgsBeforeOpenLog.pop_front();
53+
while (!m_msgs_before_open.empty()) {
54+
FileWriteStr(m_msgs_before_open.front(), m_fileout);
55+
m_msgs_before_open.pop_front();
5656
}
5757

5858
return true;
5959
}
6060

6161
void BCLog::Logger::EnableCategory(BCLog::LogFlags flag)
6262
{
63-
logCategories |= flag;
63+
m_categories |= flag;
6464
}
6565

6666
bool BCLog::Logger::EnableCategory(const std::string& str)
@@ -73,7 +73,7 @@ bool BCLog::Logger::EnableCategory(const std::string& str)
7373

7474
void BCLog::Logger::DisableCategory(BCLog::LogFlags flag)
7575
{
76-
logCategories &= ~flag;
76+
m_categories &= ~flag;
7777
}
7878

7979
bool BCLog::Logger::DisableCategory(const std::string& str)
@@ -86,12 +86,12 @@ bool BCLog::Logger::DisableCategory(const std::string& str)
8686

8787
bool BCLog::Logger::WillLogCategory(BCLog::LogFlags category) const
8888
{
89-
return (logCategories.load(std::memory_order_relaxed) & category) != 0;
89+
return (m_categories.load(std::memory_order_relaxed) & category) != 0;
9090
}
9191

9292
bool BCLog::Logger::DefaultShrinkDebugFile() const
9393
{
94-
return logCategories == BCLog::NONE;
94+
return m_categories == BCLog::NONE;
9595
}
9696

9797
struct CLogCategoryDesc
@@ -178,13 +178,13 @@ std::string BCLog::Logger::LogTimestampStr(const std::string &str)
178178
{
179179
std::string strStamped;
180180

181-
if (!fLogTimestamps)
181+
if (!m_log_timestamps)
182182
return str;
183183

184-
if (fStartedNewLine) {
184+
if (m_started_new_line) {
185185
int64_t nTimeMicros = GetTimeMicros();
186186
strStamped = FormatISO8601DateTime(nTimeMicros/1000000);
187-
if (fLogTimeMicros) {
187+
if (m_log_time_micros) {
188188
strStamped.pop_back();
189189
strStamped += strprintf(".%06dZ", nTimeMicros%1000000);
190190
}
@@ -197,9 +197,9 @@ std::string BCLog::Logger::LogTimestampStr(const std::string &str)
197197
strStamped = str;
198198

199199
if (!str.empty() && str[str.size()-1] == '\n')
200-
fStartedNewLine = true;
200+
m_started_new_line = true;
201201
else
202-
fStartedNewLine = false;
202+
m_started_new_line = false;
203203

204204
return strStamped;
205205
}
@@ -210,30 +210,30 @@ int BCLog::Logger::LogPrintStr(const std::string &str)
210210

211211
std::string strTimestamped = LogTimestampStr(str);
212212

213-
if (fPrintToConsole) {
213+
if (m_print_to_console) {
214214
// print to console
215215
ret = fwrite(strTimestamped.data(), 1, strTimestamped.size(), stdout);
216216
fflush(stdout);
217217
}
218-
if (fPrintToDebugLog) {
219-
std::lock_guard<std::mutex> scoped_lock(mutexDebugLog);
218+
if (m_print_to_file) {
219+
std::lock_guard<std::mutex> scoped_lock(m_file_mutex);
220220

221221
// buffer if we haven't opened the log yet
222-
if (fileout == nullptr) {
222+
if (m_fileout == nullptr) {
223223
ret = strTimestamped.length();
224-
vMsgsBeforeOpenLog.push_back(strTimestamped);
224+
m_msgs_before_open.push_back(strTimestamped);
225225
}
226226
else
227227
{
228228
// reopen the log file, if requested
229-
if (fReopenDebugLog) {
230-
fReopenDebugLog = false;
229+
if (m_reopen_file) {
230+
m_reopen_file = false;
231231
fs::path pathDebug = GetDebugLogPath();
232-
if (fsbridge::freopen(pathDebug,"a",fileout) != nullptr)
233-
setbuf(fileout, nullptr); // unbuffered
232+
if (fsbridge::freopen(pathDebug,"a",m_fileout) != nullptr)
233+
setbuf(m_fileout, nullptr); // unbuffered
234234
}
235235

236-
ret = FileWriteStr(strTimestamped, fileout);
236+
ret = FileWriteStr(strTimestamped, m_fileout);
237237
}
238238
}
239239
return ret;

src/logging.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,42 +59,42 @@ namespace BCLog {
5959
class Logger
6060
{
6161
private:
62-
FILE* fileout = nullptr;
63-
std::mutex mutexDebugLog;
64-
std::list<std::string> vMsgsBeforeOpenLog;
62+
FILE* m_fileout = nullptr;
63+
std::mutex m_file_mutex;
64+
std::list<std::string> m_msgs_before_open;
6565

6666
/**
67-
* fStartedNewLine is a state variable that will suppress printing of
67+
* m_started_new_line is a state variable that will suppress printing of
6868
* the timestamp when multiple calls are made that don't end in a
6969
* newline.
7070
*/
71-
std::atomic_bool fStartedNewLine{true};
71+
std::atomic_bool m_started_new_line{true};
7272

7373
/** Log categories bitfield. */
74-
std::atomic<uint32_t> logCategories{0};
74+
std::atomic<uint32_t> m_categories{0};
7575

7676
std::string LogTimestampStr(const std::string& str);
7777

7878
public:
79-
bool fPrintToConsole = false;
80-
bool fPrintToDebugLog = true;
79+
bool m_print_to_console = false;
80+
bool m_print_to_file = true;
8181

82-
bool fLogTimestamps = DEFAULT_LOGTIMESTAMPS;
83-
bool fLogTimeMicros = DEFAULT_LOGTIMEMICROS;
82+
bool m_log_timestamps = DEFAULT_LOGTIMESTAMPS;
83+
bool m_log_time_micros = DEFAULT_LOGTIMEMICROS;
8484

85-
std::atomic<bool> fReopenDebugLog{false};
85+
std::atomic<bool> m_reopen_file{false};
8686

8787
/** Send a string to the log output */
8888
int LogPrintStr(const std::string &str);
8989

9090
/** Returns whether logs will be written to any output */
91-
bool Enabled() const { return fPrintToConsole || fPrintToDebugLog; }
91+
bool Enabled() const { return m_print_to_console || m_print_to_file; }
9292

9393
fs::path GetDebugLogPath() const;
9494
bool OpenDebugLog();
9595
void ShrinkDebugFile();
9696

97-
uint32_t GetCategoryMask() const { return logCategories.load(); }
97+
uint32_t GetCategoryMask() const { return m_categories.load(); }
9898

9999
void EnableCategory(LogFlags flag);
100100
bool EnableCategory(const std::string& str);

src/test/test_bitcoin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
4747
SetupNetworking();
4848
InitSignatureCache();
4949
InitScriptExecutionCache();
50-
g_logger->fPrintToDebugLog = false; // don't want to write to debug.log file
50+
g_logger->m_print_to_file = false; // don't want to write to debug.log file
5151
fCheckBlockIndex = true;
5252
SelectParams(chainName);
5353
noui_connect();

0 commit comments

Comments
 (0)