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 20
20
21
21
#include < consensus/validation.h>
22
22
#include < core_io.h>
23
+ #include < logging.h>
23
24
#include < node/blockstorage.h>
24
25
#include < node/caches.h>
25
26
#include < node/chainstate.h>
42
43
43
44
int main (int argc, char * argv[])
44
45
{
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
+
45
52
// SETUP: Argument parsing and handling
46
53
if (argc != 2 ) {
47
54
std::cerr
Original file line number Diff line number Diff line change @@ -96,6 +96,18 @@ void BCLog::Logger::DisconnectTestLogger()
96
96
m_print_callbacks.clear ();
97
97
}
98
98
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
+
99
111
void BCLog::Logger::EnableCategory (BCLog::LogFlags flag)
100
112
{
101
113
m_categories |= flag;
Original file line number Diff line number Diff line change @@ -157,6 +157,14 @@ namespace BCLog {
157
157
/* * Only for testing */
158
158
void DisconnectTestLogger () EXCLUSIVE_LOCKS_REQUIRED(!m_cs);
159
159
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
+
160
168
void ShrinkDebugFile ();
161
169
162
170
std::unordered_map<LogFlags, Level> CategoryLevels () const EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
You can’t perform that action at this time.
0 commit comments