aboutsummaryrefslogtreecommitdiff
path: root/src/logging.h
AgeCommit message (Collapse)Author
2024-04-02Merge bitcoin/bitcoin#29419: log: deduplicate category names and improve ↵Ryan Ofsky
logging.cpp b0344c219a641b759fb0cc4f53afebe675b8ca27 logging: remove unused BCLog::UTIL (Vasil Dimov) d3b3af90343b7671231afd7dff87e87ff86d31d7 log: deduplicate category names and improve logging.cpp (Vasil Dimov) Pull request description: The code in `logging.cpp` needs to: * Get the category name given the flag (e.g. `BCLog::PRUNE` -> `"prune"`) * Get the flag given the category name (e.g. `"prune"` -> `BCLog::PRUNE`) * Get the list of category names sorted in alphabetical order Achieve this by using the proper std containers. The result is * less code (the diff of the first commit is +62 / -129) * faster code (to linear search and no copy+sort) * more maintainable code (the categories are no longer duplicated in `LogCategories[]` and `LogCategoryToStr()`) This behavior is preserved: `BCLog::NONE` -> `""` (lookup by `LogCategoryToStr()`) `""` -> `BCLog::ALL` (lookup by `GetLogCategory("")`) --- Also remove unused `BCLog::UTIL`. --- These changes (modulo the `BCLog::UTIL` removal) are part of https://github.com/bitcoin/bitcoin/pull/29415 but they make sense on their own and would be good to have them, regardless of the fate of https://github.com/bitcoin/bitcoin/pull/29415. Also, if this is merged, that would reduce the size of https://github.com/bitcoin/bitcoin/pull/29415, thus the current standalone PR. ACKs for top commit: davidgumberg: crACK https://github.com/bitcoin/bitcoin/pull/29419/commits/b0344c219a641b759fb0cc4f53afebe675b8ca27 pinheadmz: ACK b0344c219a641b759fb0cc4f53afebe675b8ca27 ryanofsky: Code review ACK b0344c219a641b759fb0cc4f53afebe675b8ca27. Nice cleanup! Having to maintain multiple copies of the same mapping seemed messy and a like a possible footgun. I checked old and new mappings in both directions and confirmed no behavior should be changing. Tree-SHA512: 57f87a090932f9b33dc8e075d1855dba9b71a3243a0758511745483dec2d9c46d3b532eadab297e78164c9b7caba370986ee380696a45f0778a841082f8e21a7
2024-03-12log: Remove error() referenceFabian Jahr
2024-03-11refactor: Remove unused error()MarcoFalke
2024-03-11refactor: Make error() return type voidMarcoFalke
This is needed for the next commit to compile.
2024-02-11logging: remove unused BCLog::UTILVasil Dimov
Suggested by: David Gumberg (https://github.com/bitcoin/bitcoin/pull/29415#discussion_r1485310634)
2023-12-20logging: add LogError, LogWarning, LogInfo, LogDebug, LogTraceAnthony Towns
These provide simple and clear ways to write the most common logging operations: LogInfo("msg"); LogDebug(BCLog::LogFlags::NET, "msg"); LogError("msg"); LogWarning("msg"); LogTrace(BCLog::LogFlags::NET, "msg"); For cases where the level cannot be hardcoded, LogPrintLevel(category, level, ...) remains available.
2023-12-15logging: add -loglevelalways=1 optionAnthony Towns
This option tells the logging system to always include a "[cat:level]" prefix, so [net] becomes [net:debug], LogInfo/LogPrint statements will have an [all:info] prefix, and LogWarning and LogError logs will become [all:warning] and [all:error]. This may be easier for automated parsing of logs, particularly if additional prefixes such as thread or source location are enabled.
2023-12-15logging: Drop BCLog::Level::NoneAnthony Towns
Now that Info-level logging is always logged, there is no further need for the "None" level, so remove it.
2023-12-15logging: refactor: pull prefix code outAnthony Towns
2023-08-29[log] add category TXPACKAGES for orphanage and package relayglozow
2023-06-15refactor: rename BCLog::BLOCKSTORE to BLOCKSTORAGEJon Atack
so the enum name is the same as its value, like the other BCLog enums.
2023-03-23refactor: Move fs.* to util/fs.*TheCharlatan
The fs.* files are already part of the libbitcoin_util library. With the introduction of the fs_helpers.* it makes sense to move fs.* into the util/ directory as well.
2023-03-13refactor: Move error() from util/system.h to logging.hBen Woosley
error is a low-level function with a sole dependency on LogPrintf, which is defined in logging.h The background of this commit is an ongoing effort to decouple the libbitcoinkernel library from the ArgsManager defined in system.h. Moving the function out of system.h allows including it from a separate source file without including the ArgsManager definitions from system.h.
2022-12-24scripted-diff: Bump copyright headersHennadii Stepanov
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: - 2021: f47dda2c58b5d8d623e0e7ff4e74bc352dfa83d7 - 2020: fa0074e2d82928016a43ca408717154a1c70a4db - 2019: aaaaad6ac95b402fe18d019d67897ced6b316ee0
2022-10-25wallet: fast rescan: show log message for every non-skipped blockSebastian Falbesoner
For that purpose, a new logging category BCLog::SCAN is introduced.
2022-10-17log: Add tx reconciliation log categoryGleb Naumenko
2022-08-20Create BCLog::Level::Trace log severity levelJon Atack
for verbose log messages for development or debugging only, as bitcoind may run more slowly, that are more granular/frequent than the Debug log level, i.e. for very high-frequency, low-level messages to be logged distinctly from higher-level, less-frequent debug logging that could still be usable in production. An example would be to log higher-level peer events (connection, disconnection, misbehavior, eviction) as Debug, versus Trace for low-level, high-volume p2p messages in the BCLog::NET category. This will enable the user to log only the former without the latter, in order to focus on high-level peer management events. With respect to the name, "trace" is suggested as the most granular level in resources like the following: - https://sematext.com/blog/logging-levels - https://howtodoinjava.com/log4j2/logging-levels Update the test framework and add test coverage.
2022-08-20Create -loglevel configuration optionklementtan
- add a -loglevel=<level>|<category:level> config option to allow users to set a global -loglevel and category-specific log levels. LogPrintLevel messages with a higher severity level than -loglevel will not be printed in the debug log. - for now, this config option is debug-only during the migration to severity-based logging - update unit and functional tests Co-authored-by: "Jon Atack <jon@atack.com>"
2022-08-20Create BCLog::Logger::LogLevelsString() helper functionklementtan
Co-authored-by: "Jon Atack <jon@atack.com>"
2022-08-20Update LogAcceptCategory() and unit tests with log severity levelsklementtan
Co-authored-by: "Jon Atack <jon@atack.com>"
2022-08-20Add BCLog::Logger::SetLogLevel()/SetCategoryLogLevel() for string inputsklementtan
and remove unnecessary param constness in LogPrintStr() Co-authored-by: jonatack <jon@atack.com>
2022-08-20Add BCLog::Logger::m_category_log_levels data member and getter/setterJon Atack
Co-authored-by: "klementtan <klementtan@gmail.com>"
2022-08-20Add BCLog::Logger::m_log_level data member and getter/setterJon Atack
Co-authored-by: "klementtan <klementtan@gmail.com>"
2022-08-18Simplify BCLog::Level enum class and LogLevelToStr() functionJon Atack
- simplify the BCLog::Level enum class (and future changes to it) by only setting the value of the first enumerator - move the BCLog::Level:None enumerator to the end of the BCLog::Level enum class and LogLevelToStr() member function, as the None enumerator is only used internally, and by being the highest BCLog::Level value it can be used to iterate over the enumerators - replace the unused BCLog::Level:None string "none" with an empty string as the case will never be hit - add documentation
2022-06-08logging: add LogPrintfCategory to log unconditionally with categoryJon Atack
prefixing the output with the passed category name. - add documentation - add a unit test - update lint-logs.py - update lint-format-strings.py
2022-05-25refactor: Change LogPrintLevel order to category, severitylaanwj
This is more consistent with the other functions, as well as with the logging output itself. If we want to make this change, we should do it before it's all over the place.
2022-05-25logging: Unconditionally log levels >= WARNlaanwj
Messages with level `WARN` or higher should be logged even when the category is not provided with `-debug=`, to make sure important warnings are not lost.
2022-05-19logging: Add severity level to logs.klementtan
2022-04-05Put lock logging behind DEBUG_LOCKCONTENTION preprocessor directiveJon Atack
2022-02-03refactor: replace boost::filesystem with std::filesystemKiminuo
Warning: Replacing fs::system_complete calls with fs::absolute calls in this commit may cause minor changes in behaviour because fs::absolute no longer strips trailing slashes; however these changes are believed to be safe. Co-authored-by: Russell Yanofsky <russ@yanofsky.org> Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2021-12-30scripted-diff: Bump copyright headersHennadii Stepanov
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: * 2020: fa0074e2d82928016a43ca408717154a1c70a4db * 2019: aaaaad6ac95b402fe18d019d67897ced6b316ee0
2021-10-11blockstorage: use debug log categoryAnthony Towns
2021-10-01Add syscall sandboxing (seccomp-bpf)practicalswift
2021-08-18log, sync: add LOCK logging category, apply it to lock contentionJon Atack
2021-07-22log: sort LogCategoriesList and LogCategoriesString alphabeticallyJon Atack
2021-04-23multiprocess: Add Ipc interface implementationRussell Yanofsky
2021-03-01net: implement the necessary parts of the I2P SAM protocolVasil Dimov
Implement the following commands from the I2P SAM protocol: * HELLO: needed for all of the remaining ones * DEST GENERATE: to generate our private key and destination * NAMING LOOKUP: to convert .i2p addresses to destinations * SESSION CREATE: needed for STREAM CONNECT and STREAM ACCEPT * STREAM CONNECT: to make outgoing connections * STREAM ACCEPT: to accept incoming connections
2021-01-15log: Prefix log messages with function name if -logsourcelocations is setpracticalswift
2020-12-06Don't declare de facto const member functions as non-constpracticalswift
2020-05-28refactor: Rename LockGuard to StdLockGuard for consistency with StdMutexHennadii Stepanov
2020-05-28Add thread safety annotated wrapper for std::mutexHennadii Stepanov
Co-authored-by: Anthony Towns <aj@erisian.com.au>
2020-05-27logging: thread safety annotationsAnthony Towns
Adds LockGuard helper in threadsafety.h to replace lock_guard<mutex> when LOCK(Mutex) isn't available for use.
2020-04-16log: Use Join() helper when listing log categoriesMarcoFalke
2020-01-15scripted-diff: Bump copyright of files changed in 2020MarcoFalke
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
2020-01-09Merge #16688: log: Add validation interface loggingWladimir J. van der Laan
f9abf4ab6d3d3e4d4b7e90723020b5422a141a6f Add logging for CValidationInterface events (Jeffrey Czyz) 6edebacb2191373e76d79a4972d6192300976096 Refactor FormatStateMessage for clarity (Jeffrey Czyz) 72f3227c83810936e7a334304e5fd7c6dab8e91b Format CValidationState properly in all cases (Jeffrey Czyz) 428ac70095253225f64462ee15c595644747f376 Add VALIDATION to BCLog::LogFlags (Jeffrey Czyz) Pull request description: Add logging of `CValidationInterface` callbacks using a new `VALIDATIONINTERFACE` log flag (see #12994). A separate flag is desirable as the logging can be noisy and thus may need to be disabled without affecting other logging. This could help debug issues where there may be race conditions at play, such as #12978. ACKs for top commit: jnewbery: ACK f9abf4ab6d3d3e4d4b7e90723020b5422a141a6f hebasto: ACK f9abf4ab6d3d3e4d4b7e90723020b5422a141a6f ariard: ACK f9abf4a, only changes since 0cadb12 are replacing log indication `VALIDATIONINTERFACE` by `VALIDATION` and avoiding a forward declaration with a new include ryanofsky: Code review ACK f9abf4ab6d3d3e4d4b7e90723020b5422a141a6f. Just suggested changes since last review (thanks!) Tree-SHA512: 3e0f6e2c8951cf46fbad3ff440971d95d526df2a52a2e4d6452a82785c63d53accfdabae66b0b30e2fe0b00737f8d5cb717edbad1460b63acb11a72c8f5d4236
2020-01-03Add VALIDATION to BCLog::LogFlagsJeffrey Czyz
This flag is for logging from within CValidationInterface (see #12994). A separate flag is desirable as the logging can be noisy and thus may need to be disabled without affecting other logging.
2019-12-30scripted-diff: Bump copyright of files changed in 2019MarcoFalke
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
2019-11-08scripted-diff: Change `BCLog::DB` to `BCLog::WALLETDB`Wladimir J. van der Laan
-BEGIN VERIFY SCRIPT- git grep -l "BCLog::DB" src | xargs sed -i "s/BCLog::DB/BCLog::WALLETDB/g" sed -i "s/DB =/WALLETDB =/g" src/logging.h -END VERIFY SCRIPT-
2019-11-04logging: Add member for arbitrary print callbacksMarcoFalke
2019-10-22Replace the LogPrint function with a macroJeffrey Czyz
Calling LogPrint with a category that is not enabled results in evaluating the remaining function arguments, which may be arbitrarily complex (and possibly expensive) expressions. Defining LogPrint as a macro prevents this unnecessary expression evaluation. This is a partial revert of #14209. The decision to revert is discussed in #16688, which adds verbose logging for validation event notification.