ifw-fnd logging abstraction. More...
#include <chrono>#include <memory>#include <string>#include <string_view>#include <vector>#include <fmt/format.h>Go to the source code of this file.
Classes | |
| class | ifw::fnd::Logger |
| Abstract logger; downstream supplies an implementation. More... | |
| class | ifw::fnd::ScopedTracer |
RAII tracer used by FNDTRACE. More... | |
Namespaces | |
| namespace | ifw |
| namespace | ifw::fnd |
| This source file contains definitions of the types and constants to handle data types. | |
Macros | |
Logging macros | |
| #define | FND_LOG_IMPL_(level_, fmt_str_, ...) |
| #define | FND_TRACE_NAME_(line) |
| Scoped trace macro. | |
| #define | FND_TRACE_NAME(line) |
| #define | FNDTRACE(...) |
| #define | FNDDEBUG(fmt_str, ...) |
| #define | FNDINFO(fmt_str, ...) |
| #define | FNDWARNING(fmt_str, ...) |
| #define | FNDERROR(fmt_str, ...) |
| #define | FNDTHROW(fmt_str, ...) |
Enumerations | |
| enum class | ifw::fnd::LogLevel : int { ifw::fnd::TRACE = 0 , ifw::fnd::DEBUG = 10 , ifw::fnd::INFO = 20 , ifw::fnd::WARNING = 30 , ifw::fnd::ERROR = 40 , ifw::fnd::OFF = 100 } |
| Log severity, lowest to highest. More... | |
Functions | |
| void | ifw::fnd::InstallLogger (std::unique_ptr< Logger > logger) noexcept |
| Install the process-wide logger. | |
| Logger & | ifw::fnd::Log () |
| Access the installed logger. | |
| bool | ifw::fnd::HasLogger () noexcept |
true iff a logger has been installed. | |
| std::unique_ptr< Logger > | ifw::fnd::MakeStdoutLogger () |
| Factory: a logger that prints to stdout. | |
| std::unique_ptr< Logger > | ifw::fnd::MakeNullLogger () |
| Factory: a logger that discards everything. | |
| std::string_view | ifw::fnd::LogLevelName (LogLevel level) noexcept |
Render a LogLevel as a short uppercase string. | |
| std::string | ifw::fnd::TraceExtra () |
Helper used by FNDTRACE. | |
| template<typename... Args> | |
| std::string | ifw::fnd::TraceExtra (fmt::string_view fmt_str, Args &&... args) |
ifw-fnd logging abstraction.
ifw-fnd is meant to build on both ELT and VLTSW environments and must not impose a specific logging backend. This header defines an abstract Logger interface. Downstream applications subclass it, instantiate one logger object, and hand ownership to ifw-fnd at startup via InstallLogger(). Until a logger has been installed, calls to Log() throw — ifw-fnd refuses to silently swallow log output. Two ready-made implementations are provided as convenience: a stdout logger and a null (silent) logger.
Call sites use the FNDTRACE / FNDDEBUG / FNDINFO / FNDWARNING / FNDERROR / FNDTHROW macros. Each macro is fmt-style and includes an early-out test on the configured log level, so disabled-level calls cost a single integer compare.
Note: this header is dependency-free (stdlib + fmt only). It does NOT pull in log4cplus, CII, or any other ESO-only library. The point of the abstraction is that consumers of ifw-fnd inherit that freedom.
| #define FND_LOG_IMPL_ | ( | level_, | |
| fmt_str_, | |||
| ... ) |
| #define FND_TRACE_NAME | ( | line | ) |
| #define FND_TRACE_NAME_ | ( | line | ) |
Scoped trace macro.
Emits ENTERING on the line and LEAVING + elapsed time when the enclosing scope ends. Both lines log at LogLevel::TRACE and include the calling function (via __PRETTY_FUNCTION__). Optional format string + args append an extra note that appears on BOTH lines so a reader can correlate them in interleaved multi-thread output.
Place at the top of any function whose enter/leave timing you want captured. The macro expands to an RAII object held by the enclosing scope. Nested traces in the same thread indent visually.
COST CONTRACT: when TRACE is disabled, the cost is one atomic load (HasLogger) plus one integer compare (level). The FNDLOC expansion (which calls IsoTimeNow + ThreadName, both syscalls) and the formatting of any extra args are SKIPPED entirely. Without this short-circuit, leaving FNDTRACE in hot paths stalled the data plane at the millisecond scale.
| #define FNDDEBUG | ( | fmt_str, | |
| ... ) |
| #define FNDERROR | ( | fmt_str, | |
| ... ) |
| #define FNDINFO | ( | fmt_str, | |
| ... ) |
| #define FNDTHROW | ( | fmt_str, | |
| ... ) |
| #define FNDTRACE | ( | ... | ) |
| #define FNDWARNING | ( | fmt_str, | |
| ... ) |