![]() |
Bitcoin Core 30.99.0
P2P Digital Currency
|
#include <logging.h>
Classes | |
| struct | BufferedLog |
Public Member Functions | |
| void | LogPrintStr (std::string_view str, std::source_location &&source_loc, BCLog::LogFlags category, BCLog::Level level, bool should_ratelimit) EXCLUSIVE_LOCKS_REQUIRED(!m_cs) |
| Send a string to the log output. More... | |
| bool | Enabled () const EXCLUSIVE_LOCKS_REQUIRED(!m_cs) |
| Returns whether logs will be written to any output. More... | |
| std::list< std::function< void(conststd::string &)> >::iterator | PushBackCallback (std::function< void(const std::string &)> fun) EXCLUSIVE_LOCKS_REQUIRED(!m_cs) |
| Connect a slot to the print signal and return the connection. More... | |
| void | DeleteCallback (std::list< std::function< void(const std::string &)> >::iterator it) EXCLUSIVE_LOCKS_REQUIRED(!m_cs) |
| Delete a connection. More... | |
| size_t | NumConnections () |
| bool | StartLogging () EXCLUSIVE_LOCKS_REQUIRED(!m_cs) |
| Start logging (and flush all buffered messages) More... | |
| void | DisconnectTestLogger () EXCLUSIVE_LOCKS_REQUIRED(!m_cs) |
| Only for testing. More... | |
| void | SetRateLimiting (std::shared_ptr< LogRateLimiter > limiter) EXCLUSIVE_LOCKS_REQUIRED(!m_cs) |
| void | DisableLogging () 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. More... | |
| void | ShrinkDebugFile () |
| std::unordered_map< LogFlags, Level > | CategoryLevels () const EXCLUSIVE_LOCKS_REQUIRED(!m_cs) |
| void | SetCategoryLogLevel (const std::unordered_map< LogFlags, Level > &levels) EXCLUSIVE_LOCKS_REQUIRED(!m_cs) |
| void | AddCategoryLogLevel (LogFlags category, Level level) |
| bool | SetCategoryLogLevel (std::string_view category_str, std::string_view level_str) EXCLUSIVE_LOCKS_REQUIRED(!m_cs) |
| Level | LogLevel () const |
| void | SetLogLevel (Level level) |
| bool | SetLogLevel (std::string_view level) |
| CategoryMask | GetCategoryMask () const |
| void | EnableCategory (LogFlags flag) |
| bool | EnableCategory (std::string_view str) |
| void | DisableCategory (LogFlags flag) |
| bool | DisableCategory (std::string_view str) |
| bool | WillLogCategory (LogFlags category) const |
| bool | WillLogCategoryLevel (LogFlags category, Level level) const EXCLUSIVE_LOCKS_REQUIRED(!m_cs) |
| 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... | |
| bool | DefaultShrinkDebugFile () const |
Static Public Member Functions | |
| static std::string | LogLevelToStr (BCLog::Level level) |
| Returns the string representation of a log level. More... | |
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 |
| bool | m_always_print_category_level = DEFAULT_LOGLEVELALWAYS |
| fs::path | m_file_path |
| std::atomic< bool > | m_reopen_file {false} |
Private Member Functions | |
| FILE *m_fileout | GUARDED_BY (m_cs) |
| std::list< BufferedLog > m_msgs_before_open | GUARDED_BY (m_cs) |
| bool m_buffering | GUARDED_BY (m_cs) |
| Buffer messages before logging can be started. More... | |
| size_t m_max_buffer_memusage | GUARDED_BY (m_cs) |
| size_t m_cur_buffer_memusage | GUARDED_BY (m_cs) |
| size_t m_buffer_lines_discarded | GUARDED_BY (m_cs) |
| std::shared_ptr< LogRateLimiter > m_limiter | GUARDED_BY (m_cs) |
| Manages the rate limiting of each log location. More... | |
| std::unordered_map< LogFlags, Level > m_category_log_levels | GUARDED_BY (m_cs) |
Category-specific log level. Overrides m_log_level. More... | |
| void | FormatLogStrInPlace (std::string &str, LogFlags category, Level level, const std::source_location &source_loc, std::string_view threadname, SystemClock::time_point now, std::chrono::seconds mocktime) const |
| std::string | LogTimestampStr (SystemClock::time_point now, std::chrono::seconds mocktime) const |
| std::list< std::function< void(const std::string &)> > m_print_callbacks | GUARDED_BY (m_cs) |
| Slots that connect to the print signal. More... | |
| void | LogPrintStr_ (std::string_view str, std::source_location &&source_loc, BCLog::LogFlags category, BCLog::Level level, bool should_ratelimit) EXCLUSIVE_LOCKS_REQUIRED(m_cs) |
| Send a string to the log output (internal) More... | |
| std::string | GetLogPrefix (LogFlags category, Level level) const |
Private Attributes | |
| StdMutex | m_cs |
| 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< CategoryMask > | m_categories {BCLog::NONE} |
| Log categories bitfield. More... | |
| bool BCLog::Logger::DefaultShrinkDebugFile | ( | ) | const |
Definition at line 167 of file logging.cpp.
|
inline |
| void BCLog::Logger::DisableCategory | ( | BCLog::LogFlags | flag | ) |
| bool BCLog::Logger::DisableCategory | ( | std::string_view | str | ) |
| void BCLog::Logger::DisableLogging | ( | ) |
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().
Definition at line 111 of file logging.cpp.
| void BCLog::Logger::DisconnectTestLogger | ( | ) |
Only for testing.
Definition at line 98 of file logging.cpp.
| void BCLog::Logger::EnableCategory | ( | BCLog::LogFlags | flag | ) |
| bool BCLog::Logger::EnableCategory | ( | std::string_view | str | ) |
|
inline |
|
private |
Definition at line 406 of file logging.cpp.
|
inline |
|
private |
|
private |
|
private |
|
private |
Buffer messages before logging can be started.
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
private |
Manages the rate limiting of each log location.
|
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 277 of file logging.cpp.
|
inline |
| std::string BCLog::Logger::LogLevelsString | ( | ) | const |
Returns a string with all user-selectable log levels.
Definition at line 293 of file logging.cpp.
|
static |
Returns the string representation of a log level.
Definition at line 233 of file logging.cpp.
| void BCLog::Logger::LogPrintStr | ( | std::string_view | str, |
| std::source_location && | source_loc, | ||
| BCLog::LogFlags | category, | ||
| BCLog::Level | level, | ||
| bool | should_ratelimit | ||
| ) |
Send a string to the log output.
Definition at line 423 of file logging.cpp.
|
private |
Send a string to the log output (internal)
Definition at line 430 of file logging.cpp.
|
private |
|
inline |
| bool BCLog::Logger::SetCategoryLogLevel | ( | std::string_view | category_str, |
| std::string_view | level_str | ||
| ) |
|
inline |
| bool BCLog::Logger::SetLogLevel | ( | std::string_view | level | ) |
|
inline |
| void BCLog::Logger::ShrinkDebugFile | ( | ) |
Definition at line 513 of file logging.cpp.
| bool BCLog::Logger::StartLogging | ( | ) |
Start logging (and flush all buffered messages)
Definition at line 54 of file logging.cpp.
| bool BCLog::Logger::WillLogCategory | ( | BCLog::LogFlags | category | ) | const |
Definition at line 149 of file logging.cpp.
| bool BCLog::Logger::WillLogCategoryLevel | ( | BCLog::LogFlags | category, |
| BCLog::Level | level | ||
| ) | const |
| bool BCLog::Logger::m_always_print_category_level = DEFAULT_LOGLEVELALWAYS |
|
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 |