mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-01 03:01:09 +02:00
logging: Add DisableLogging()
This commit is contained in:
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <consensus/validation.h>
|
#include <consensus/validation.h>
|
||||||
#include <core_io.h>
|
#include <core_io.h>
|
||||||
|
#include <logging.h>
|
||||||
#include <node/blockstorage.h>
|
#include <node/blockstorage.h>
|
||||||
#include <node/caches.h>
|
#include <node/caches.h>
|
||||||
#include <node/chainstate.h>
|
#include <node/chainstate.h>
|
||||||
@ -42,6 +43,12 @@
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
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
|
// SETUP: Argument parsing and handling
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
std::cerr
|
std::cerr
|
||||||
|
@ -96,6 +96,18 @@ void BCLog::Logger::DisconnectTestLogger()
|
|||||||
m_print_callbacks.clear();
|
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)
|
void BCLog::Logger::EnableCategory(BCLog::LogFlags flag)
|
||||||
{
|
{
|
||||||
m_categories |= flag;
|
m_categories |= flag;
|
||||||
|
@ -157,6 +157,14 @@ namespace BCLog {
|
|||||||
/** Only for testing */
|
/** Only for testing */
|
||||||
void DisconnectTestLogger() EXCLUSIVE_LOCKS_REQUIRED(!m_cs);
|
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();
|
void ShrinkDebugFile();
|
||||||
|
|
||||||
std::unordered_map<LogFlags, Level> CategoryLevels() const EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
|
std::unordered_map<LogFlags, Level> CategoryLevels() const EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
|
||||||
|
Reference in New Issue
Block a user