This section details the API for interacting with LIEF’s logging engine.
LIEF uses spdlog for its logging mechanism, and this API provides an abstraction over that implementation. Globally disable the logging module. Globally enable the logging module. Change the logger to a file-based logging and set its path. Hierarchical logging level From a given level set, all levels below this level are enabled For example, if LEVEL::INFO is enabled then LEVEL::WARN, LEVEL::ERR are also enabled Values: Change logging level Enable the logger globally Disable the logger globally Change the logger as a file-base logging and set its path Log a message with the LIEF’s logger Bases: API¶
C++¶
void LIEF::logging::log(LEVEL level, const std::string &fmt, const Args&... args)¶Example¶
// Set global level to ERROR
LIEF::logging::set_level(LIEF::logging::LEVEL::ERR);
{
// Temporarily set global level to DEBUG (RAII)
LIEF::logging::Scoped _(LIEF::logging::LEVEL::DEBUG);
LIEF::logging::log(LIEF::logging::LEVEL::DEBUG, "This is a debug message");
}
Python¶
objectExample¶
# Set global level to ERROR
lief.logging.set_level(lief.logging.LEVEL.ERROR)
# Temporarily set global level to DEBUG
with lief.logging.level_scope(lief.logging.LEVEL.DEBUG):
lief.logging.log(lief.logging.LEVEL.DEBUG, "This is a debug message")
Rust¶
Example¶
// Set global level to ERROR
lief::logging::set_level(lief::logging::Level::ERR);
{
// Temporarily set global level to DEBUG (RAII)
let _scoped = lief::logging::Scoped::new(lief::logging::Level::DEBUG);
lief::logging::log(lief::logging::Level::DEBUG, "This is a debug message");
}