ifw-fnd 2.0.1
 
Loading...
Searching...
No Matches
ifw::fnd Namespace Reference

This source file contains definitions of the types and constants to handle data types. More...

Namespaces

namespace  datatype
 This source file contains definitions of the types and constants to handle data types.
 
namespace  defs
 
namespace  fits
 This source file contains definitions of the types and constants to handle FITS.
 
namespace  test
 
namespace  tools
 Header file for the IFW Foundation Tools library.
 

Classes

class  Logger
 Abstract logger; downstream supplies an implementation. More...
 
class  ScopedTracer
 RAII tracer used by FNDTRACE. More...
 

Enumerations

enum class  LogLevel : int {
  TRACE = 0 , DEBUG = 10 , INFO = 20 , WARNING = 30 ,
  ERROR = 40 , OFF = 100
}
 Log severity, lowest to highest. More...
 

Functions

void InstallLogger (std::unique_ptr< Logger > logger) noexcept
 Install the process-wide logger.
 
LoggerLog ()
 Access the installed logger.
 
bool HasLogger () noexcept
 true iff a logger has been installed.
 
std::unique_ptr< LoggerMakeStdoutLogger ()
 Factory: a logger that prints to stdout.
 
std::unique_ptr< LoggerMakeNullLogger ()
 Factory: a logger that discards everything.
 
std::string_view LogLevelName (LogLevel level) noexcept
 Render a LogLevel as a short uppercase string.
 
std::string IsoTimeNow (const int8_t precision)
 
std::string ThreadName ()
 Return name of current thread.
 
double TimeSecs ()
 
void SleepSecs (const float sleep_time_in_seconds)
 
std::string IsoTime (const double time_since_epoch, const uint8_t precision)
 
template<typename... Ts>
std::string VariantToString (const std::variant< Ts... > &var)
 
std::string TraceExtra ()
 Helper used by FNDTRACE.
 
template<typename... Args>
std::string TraceExtra (fmt::string_view fmt_str, Args &&... args)
 

Detailed Description

This source file contains definitions of the types and constants to handle data types.

Inline function generating a location identifier: "<file>:<line>:<function>:<thread>".

Enumeration Type Documentation

◆ LogLevel

enum class ifw::fnd::LogLevel : int
strong

Log severity, lowest to highest.

Numeric values are chosen to make (level >= threshold) the natural filter test. The OFF sentinel sits above ERROR so that setting the threshold to OFF disables all output.

Enumerator
TRACE 
DEBUG 
INFO 
WARNING 
ERROR 
OFF 

Function Documentation

◆ HasLogger()

bool ifw::fnd::HasLogger ( )
noexcept

true iff a logger has been installed.

Provided so that low-level code (signal handlers, destructors running during shutdown) can avoid raising on a missing logger.

◆ InstallLogger()

void ifw::fnd::InstallLogger ( std::unique_ptr< Logger > logger)
noexcept

Install the process-wide logger.

Must be called once, early in main(), before any ifw-fnd API call that may log. Ownership is transferred to ifw-fnd. Calling twice replaces the previous logger and destroys it.

◆ IsoTime()

std::string ifw::fnd::IsoTime ( const double time_since_epoch,
const uint8_t precision )
inline

Return the ISO8601 time based on the time since epoch, expressed in seconds/double.

Parameters
[in]time_since_epochTime in seconds/double since epoch.
[in]precisionNumber of decimal places for the fractional part of the second.
Returns
ISO8601 time as a string with the requested precision.
Note
Intentionally NOT instrumented with FNDTRACE: this function is invoked from FNDLOC (via IsoTimeNow), so tracing it would cause infinite recursion when FND* macros are enabled at TRACE level.

◆ IsoTimeNow()

std::string ifw::fnd::IsoTimeNow ( const int8_t precision)
inline

Return the ISO8601 time now.

Parameters
[in]precisionNumber of decimal places for the fractional part of the second.
Returns
ISO8601 time as a string with the requested precision.
Note
Intentionally NOT instrumented with FNDTRACE: FNDLOC expands to this call, so tracing it would cause infinite recursion when FND* macros are enabled at TRACE level.

◆ Log()

Logger & ifw::fnd::Log ( )

Access the installed logger.

Exceptions
std::runtime_errorif no logger has been installed.

◆ LogLevelName()

std::string_view ifw::fnd::LogLevelName ( LogLevel level)
noexcept

Render a LogLevel as a short uppercase string.

Returns "TRACE" / "DEBUG" / "INFO" / "WARNING" / "ERROR" / "OFF". Used by MakeStdoutLogger() and available for downstream implementations.

◆ MakeNullLogger()

std::unique_ptr< Logger > ifw::fnd::MakeNullLogger ( )

Factory: a logger that discards everything.

Useful for unit tests that want ifw-fnd to be silent without having to redirect stdout.

◆ MakeStdoutLogger()

std::unique_ptr< Logger > ifw::fnd::MakeStdoutLogger ( )

Factory: a logger that prints to stdout.

Format: "<level> <message>\n". Intended for standalone tools and unit tests, not for production deployments.

◆ SleepSecs()

void ifw::fnd::SleepSecs ( const float sleep_time_in_seconds)
inline

Sleep for the given period of time specified in seconds/double.

Parameters
[in]sleep_time_in_secondsTime in seconds to sleep.
Returns
Void.

◆ ThreadName()

std::string ifw::fnd::ThreadName ( )
inline

Return name of current thread.

◆ TimeSecs()

double ifw::fnd::TimeSecs ( )
inline

Return the current time since epoch in seconds/double.

Returns
Time in seconds since epoch as a double value.
Note
Intentionally NOT instrumented with FNDTRACE: this function is part of the FNDLOC expansion (via IsoTimeNow), and tracing it would cause infinite recursion when FND* macros are enabled at TRACE level.

◆ TraceExtra() [1/2]

std::string ifw::fnd::TraceExtra ( )
inline

Helper used by FNDTRACE.

FNDTRACE() with no extra args returns "". With a format string (and optional args) returns the formatted result. Variadic templates handle the "first arg is format string" split that the C++ preprocessor can't do cleanly.

◆ TraceExtra() [2/2]

template<typename... Args>
std::string ifw::fnd::TraceExtra ( fmt::string_view fmt_str,
Args &&... args )
inline

◆ VariantToString()

template<typename... Ts>
std::string ifw::fnd::VariantToString ( const std::variant< Ts... > & var)