File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 2020
2121#include < consensus/validation.h>
2222#include < core_io.h>
23+ #include < logging.h>
2324#include < node/blockstorage.h>
2425#include < node/caches.h>
2526#include < node/chainstate.h>
4243
4344int main (int argc, char * argv[])
4445{
46+ // We do not enable logging for this app, so explicitly disable it.
47+ // To enable logging instead, replace with:
48+ // LogInstance().m_print_to_console = true;
49+ // LogInstance().StartLogging();
50+ LogInstance ().DisableLogging ();
51+
4552 // SETUP: Argument parsing and handling
4653 if (argc != 2 ) {
4754 std::cerr
Original file line number Diff line number Diff line change @@ -96,6 +96,18 @@ void BCLog::Logger::DisconnectTestLogger()
9696 m_print_callbacks.clear ();
9797}
9898
99+ void BCLog::Logger::DisableLogging ()
100+ {
101+ {
102+ StdLockGuard scoped_lock (m_cs);
103+ assert (m_buffering);
104+ assert (m_print_callbacks.empty ());
105+ }
106+ m_print_to_file = false ;
107+ m_print_to_console = false ;
108+ StartLogging ();
109+ }
110+
99111void BCLog::Logger::EnableCategory (BCLog::LogFlags flag)
100112{
101113 m_categories |= flag;
Original file line number Diff line number Diff line change @@ -157,6 +157,14 @@ namespace BCLog {
157157 /* * Only for testing */
158158 void DisconnectTestLogger () EXCLUSIVE_LOCKS_REQUIRED(!m_cs);
159159
160+ /* * Disable logging
161+ * This offers a slight speedup and slightly smaller memory usage
162+ * compared to leaving the logging system in its default state.
163+ * Mostly intended for libbitcoin-kernel apps that don't want any logging.
164+ * Should be used instead of StartLogging().
165+ */
166+ void DisableLogging () EXCLUSIVE_LOCKS_REQUIRED(!m_cs);
167+
160168 void ShrinkDebugFile ();
161169
162170 std::unordered_map<LogFlags, Level> CategoryLevels () const EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
You can’t perform that action at this time.
0 commit comments