![]() |
Bitcoin Core
26.99.0
P2P Digital Currency
|
#include <logging.h>
Public Member Functions | |
void | LogPrintStr (const std::string &str, const std::string &logging_function, const std::string &source_file, int source_line, BCLog::LogFlags category, BCLog::Level level) |
Send a string to the log output. More... | |
bool | Enabled () const |
Returns whether logs will be written to any output. More... | |
std::list< std::function< void(const std::string &)> >::iterator | PushBackCallback (std::function< void(const std::string &)> fun) |
Connect a slot to the print signal and return the connection. More... | |
void | DeleteCallback (std::list< std::function< void(const std::string &)>>::iterator it) |
Delete a connection. More... | |
bool | StartLogging () |
Start logging (and flush all buffered messages) More... | |
void | DisconnectTestLogger () |
Only for testing. More... | |
void | ShrinkDebugFile () |
std::unordered_map< LogFlags, Level > | CategoryLevels () const |
void | SetCategoryLogLevel (const std::unordered_map< LogFlags, Level > &levels) |
bool | SetCategoryLogLevel (const std::string &category_str, const std::string &level_str) |
Level | LogLevel () const |
void | SetLogLevel (Level level) |
bool | SetLogLevel (const std::string &level) |
uint32_t | GetCategoryMask () const |
void | EnableCategory (LogFlags flag) |
bool | EnableCategory (const std::string &str) |
void | DisableCategory (LogFlags flag) |
bool | DisableCategory (const std::string &str) |
bool | WillLogCategory (LogFlags category) const |
bool | WillLogCategoryLevel (LogFlags category, Level level) const |
std::vector< LogCategory > | LogCategoriesList () const |
Returns a vector of the log categories in alphabetical order. More... | |
std::string | LogCategoriesString () const |
Returns a string with the log categories in alphabetical order. More... | |
std::string | LogLevelsString () const |
Returns a string with all user-selectable log levels. More... | |
std::string | LogLevelToStr (BCLog::Level level) const |
Returns the string representation of a log level. More... | |
bool | DefaultShrinkDebugFile () const |
Public Attributes | |
bool | m_print_to_console = false |
bool | m_print_to_file = false |
bool | m_log_timestamps = DEFAULT_LOGTIMESTAMPS |
bool | m_log_time_micros = DEFAULT_LOGTIMEMICROS |
bool | m_log_threadnames = DEFAULT_LOGTHREADNAMES |
bool | m_log_sourcelocations = DEFAULT_LOGSOURCELOCATIONS |
fs::path | m_file_path |
std::atomic< bool > | m_reopen_file {false} |
Private Member Functions | |
FILE *m_fileout | GUARDED_BY (m_cs) |
std::list< std::string > m_msgs_before_open | GUARDED_BY (m_cs) |
bool m_buffering | GUARDED_BY (m_cs) |
Buffer messages before logging can be started. More... | |
std::unordered_map< LogFlags, Level > m_category_log_levels | GUARDED_BY (m_cs) |
Category-specific log level. Overrides m_log_level . More... | |
std::string | LogTimestampStr (const std::string &str) |
std::list< std::function< void(const std::string &)> > m_print_callbacks | GUARDED_BY (m_cs) |
Slots that connect to the print signal. More... | |
Private Attributes | |
StdMutex | m_cs |
std::atomic_bool | m_started_new_line {true} |
m_started_new_line is a state variable that will suppress printing of the timestamp when multiple calls are made that don't end in a newline. More... | |
std::atomic< Level > | m_log_level {DEFAULT_LOG_LEVEL} |
If there is no category-specific log level, all logs with a severity level lower than m_log_level will be ignored. More... | |
std::atomic< uint32_t > | m_categories {0} |
Log categories bitfield. More... | |
bool BCLog::Logger::DefaultShrinkDebugFile | ( | ) | const |
Definition at line 140 of file logging.cpp.
|
inline |
bool BCLog::Logger::DisableCategory | ( | const std::string & | str | ) |
void BCLog::Logger::DisableCategory | ( | BCLog::LogFlags | flag | ) |
void BCLog::Logger::DisconnectTestLogger | ( | ) |
Only for testing.
Definition at line 87 of file logging.cpp.
bool BCLog::Logger::EnableCategory | ( | const std::string & | str | ) |
void BCLog::Logger::EnableCategory | ( | BCLog::LogFlags | flag | ) |
|
inline |
|
inline |
|
private |
|
private |
|
private |
Buffer messages before logging can be started.
|
private |
Category-specific log level. Overrides m_log_level
.
|
inlineprivate |
std::vector< LogCategory > BCLog::Logger::LogCategoriesList | ( | ) | const |
Returns a vector of the log categories in alphabetical order.
Definition at line 317 of file logging.cpp.
|
inline |
std::string BCLog::Logger::LogLevelsString | ( | ) | const |
Returns a string with all user-selectable log levels.
Definition at line 341 of file logging.cpp.
std::string BCLog::Logger::LogLevelToStr | ( | BCLog::Level | level | ) | const |
Returns the string representation of a log level.
Definition at line 205 of file logging.cpp.
void BCLog::Logger::LogPrintStr | ( | const std::string & | str, |
const std::string & | logging_function, | ||
const std::string & | source_file, | ||
int | source_line, | ||
BCLog::LogFlags | category, | ||
BCLog::Level | level | ||
) |
Send a string to the log output.
Definition at line 395 of file logging.cpp.
|
private |
|
inline |
bool BCLog::Logger::SetCategoryLogLevel | ( | const std::string & | category_str, |
const std::string & | level_str | ||
) |
bool BCLog::Logger::SetLogLevel | ( | const std::string & | level | ) |
|
inline |
void BCLog::Logger::ShrinkDebugFile | ( | ) |
Definition at line 464 of file logging.cpp.
bool BCLog::Logger::StartLogging | ( | ) |
Start logging (and flush all buffered messages)
Definition at line 48 of file logging.cpp.
bool BCLog::Logger::WillLogCategory | ( | BCLog::LogFlags | category | ) | const |
Definition at line 122 of file logging.cpp.
bool BCLog::Logger::WillLogCategoryLevel | ( | BCLog::LogFlags | category, |
BCLog::Level | level | ||
) | const |
|
private |
|
private |
bool BCLog::Logger::m_log_sourcelocations = DEFAULT_LOGSOURCELOCATIONS |
bool BCLog::Logger::m_log_threadnames = DEFAULT_LOGTHREADNAMES |
bool BCLog::Logger::m_log_time_micros = DEFAULT_LOGTIMEMICROS |
bool BCLog::Logger::m_log_timestamps = DEFAULT_LOGTIMESTAMPS |
|
private |