mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-09 19:37:27 -03:00
logging: Add DisableLogging()
This commit is contained in:
parent
6bbc2dd6c5
commit
0b1960f1b2
3 changed files with 27 additions and 0 deletions
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include <consensus/validation.h>
|
||||
#include <core_io.h>
|
||||
#include <logging.h>
|
||||
#include <node/blockstorage.h>
|
||||
#include <node/caches.h>
|
||||
#include <node/chainstate.h>
|
||||
|
@ -42,6 +43,12 @@
|
|||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// We do not enable logging for this app, so explicitly disable it.
|
||||
// To enable logging instead, replace with:
|
||||
// LogInstance().m_print_to_console = true;
|
||||
// LogInstance().StartLogging();
|
||||
LogInstance().DisableLogging();
|
||||
|
||||
// SETUP: Argument parsing and handling
|
||||
if (argc != 2) {
|
||||
std::cerr
|
||||
|
|
|
@ -96,6 +96,18 @@ void BCLog::Logger::DisconnectTestLogger()
|
|||
m_print_callbacks.clear();
|
||||
}
|
||||
|
||||
void BCLog::Logger::DisableLogging()
|
||||
{
|
||||
{
|
||||
StdLockGuard scoped_lock(m_cs);
|
||||
assert(m_buffering);
|
||||
assert(m_print_callbacks.empty());
|
||||
}
|
||||
m_print_to_file = false;
|
||||
m_print_to_console = false;
|
||||
StartLogging();
|
||||
}
|
||||
|
||||
void BCLog::Logger::EnableCategory(BCLog::LogFlags flag)
|
||||
{
|
||||
m_categories |= flag;
|
||||
|
|
|
@ -157,6 +157,14 @@ namespace BCLog {
|
|||
/** Only for testing */
|
||||
void DisconnectTestLogger() EXCLUSIVE_LOCKS_REQUIRED(!m_cs);
|
||||
|
||||
/** Disable logging
|
||||
* This offers a slight speedup and slightly smaller memory usage
|
||||
* compared to leaving the logging system in its default state.
|
||||
* Mostly intended for libbitcoin-kernel apps that don't want any logging.
|
||||
* Should be used instead of StartLogging().
|
||||
*/
|
||||
void DisableLogging() EXCLUSIVE_LOCKS_REQUIRED(!m_cs);
|
||||
|
||||
void ShrinkDebugFile();
|
||||
|
||||
std::unordered_map<LogFlags, Level> CategoryLevels() const EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
|
||||
|
|
Loading…
Reference in a new issue