file
Logging.h
Namespaces
- namespace esp
- Root namespace.
- namespace esp::logging
- logging library
- namespace esp::gfx
- GFX library.
- namespace esp::scene
- namespace esp::sim
- core physics simulation namespace
- namespace esp::physics
- Physics library.
- namespace esp::nav
- NavMesh namespace.
- namespace esp::metadata
- Metadata management.
- namespace esp::geo
- namespace esp::io
- namespace esp::core
- Core Habitat functionality.
- namespace esp::assets
- Assets library.
- namespace esp::sensor
- namespace esp::metadata::URDF
- URDF parsing library.
- namespace esp::logging::impl
Classes
- class esp::logging::LoggingContext
- Logging context that tracks which logging statements are enabled.
- class esp::logging::impl::LogMessageVoidify
Enums
- enum class Subsystem: uint8_t { Default, gfx, scene, sim, physics, nav, metadata, geo, io, URDF, core, assets, sensor, NumSubsystems }
- Habitat-Sim logging subsystems.
- enum class LoggingLevel: uint8_t { VeryVerbose, Debug, Warning, Error, Verbose = Debug, Default = Warning, Quiet = Error }
- Habitat-Sim logging levels. If the logging level for log macro is greater than or equal to the logging level within that subsystem, the log will be printed.
Functions
-
auto subsystemFromName(Corrade::
Containers:: StringView name) -> Subsystem -
auto espLoggingSubsystem() -> esp::
logging:: Subsystem - Top level logging subsystem function allowing logging macros to work outside the esp namespace.
- auto espLoggingSubsystem() -> logging::Subsystem
- auto espLoggingSubsystem() -> logging::Subsystem
- auto espLoggingSubsystem() -> logging::Subsystem
- auto espLoggingSubsystem() -> logging::Subsystem
- auto espLoggingSubsystem() -> logging::Subsystem
- auto espLoggingSubsystem() -> logging::Subsystem
- auto espLoggingSubsystem() -> logging::Subsystem
- auto espLoggingSubsystem() -> logging::Subsystem
- auto espLoggingSubsystem() -> logging::Subsystem
- auto espLoggingSubsystem() -> logging::Subsystem
- auto espLoggingSubsystem() -> logging::Subsystem
- auto espLoggingSubsystem() -> logging::Subsystem
-
auto levelFromName(Corrade::
Containers:: StringView name) -> LoggingLevel - auto isLevelEnabled(Subsystem subsystem, LoggingLevel level) -> bool
- Determine if the specified logging level is enabled within a given subsystem.
-
auto buildMessagePrefix(Subsystem subsystem,
const std::
string& msgLevel, const std:: string& filename, const std:: string& function, int line) -> Corrade:: Containers:: String - Build appropriate prefix for logging messages, including subsystem/namespace, file, line number and function name.
Variables
- const char* subsystemNames constexpr
Defines
- #define ESP_ADD_SUBSYSTEM_FN(subsystemName)
- Helper macro to add functions for determining the current subsystem.
- #define ESP_LOG_IF(condition, output)
- Magic macro that creates a conditional logging statement.
- #define ESP_SUBSYS_LOG_IF(subsystem, level, output, levelMsg)
- #define ESP_LOG_LEVEL_ENABLED(level)
- #define ESP_VERY_VERBOSE(...)
- Very verbose level logging macro.
- #define ESP_DEBUG(...)
- Debug level logging macro.
- #define ESP_WARNING(...)
- Warning level logging macro.
- #define ESP_ERROR(...)
- Error level logging macro.
Function documentation
esp:: logging:: Subsystem espLoggingSubsystem()
Top level logging subsystem function allowing logging macros to work outside the esp namespace.
Uses c style namespacing that way logging can work outside our namespace.
There will be many of these functions in different namespaces as we use namespace resolution to determine the logging subsystem for a given logging macro.
Define documentation
#define ESP_ADD_SUBSYSTEM_FN(subsystemName)
Helper macro to add functions for determining the current subsystem.
This macro assumes that the namespace for a subsystem is esp::<subsystemName>
#define ESP_LOG_IF(condition, output)
Magic macro that creates a conditional logging statement.
The intent of this macro is actually rather simple (although the implementation is quite opaque). This macro is just
if (condition) output
This is a "so simple it's obvious" way to implement a conditional logging macro. However, the if statement implementation would potentially interact with other parts of the code. While certianly an edge case, the following should not be valid code:
ESP_DEBUG() << ... ; else { ... }
So instead, a ternary is used to encapsulate everything as a single expression. Since a ternary requires both a true and false clause and the false clause comes second, the condition is negated.
The final piece of the puzzle is how to have both the true and false clause return the same thing (a return of void is used to avoid unused value compiler warnings). The LogMessageVoidify{} & output
does this as LogMessageVoidify
has an operator&
overload that returns void. Any operator that is lower precedence than operator<<
and higher than ?:
would work for this overload. That way the logging statements get evaluated first, then the voidify, then the ternary.