Class f3d::log
Definition: log.h (line 23)
Class used to show logs in F3D.
A class to output logs to the standard output. It supports different levels, errors, warnings and info, with associated coloring. A few static methods exists to control the coloring and the verbosity level
Members
- debug
- error
- forward
- forward_fn_t
- getVerboseLevel
- info
- setUseColoring
- setVerboseLevel
- VerboseLevel
- warn
Public types
Enumeration type VerboseLevel
Definition: log.h (line 34)
enum VerboseLevel {
DEBUG = 0,
INFO,
WARN,
ERROR,
QUIET
}
Enumeration of verbose levels
-
DEBUG: All logs are displayed, including from third parties.
-
INFO: Standard logging level, the default.
-
WARN: Only warnings and errors are displayed.
-
ERROR: Only errors are displayed.
-
QUIET: Logging is fully disabled.
Enumerator DEBUG
Enumerator INFO
Enumerator WARN
Enumerator ERROR
Enumerator QUIET
Typedef forward_fn_t
Definition: log.h (line 118)
using f3d::log::forward_fn_t = std::function<void(VerboseLevel, const std::string&)>
Alias for log forwarder callback.
Return type: std::function< void(VerboseLevel, const std::string &)>
Public static functions
Function print
static void f3d::log::print(VerboseLevel level, Args... args)
Log provided args as provided verbose level.
Parameters:
- VerboseLevel level
- Args... args
Return type: void
Function debug
static void f3d::log::debug(Args... args)
Log provided args as a debug.
Parameters:
- Args... args
Return type: void
Function info
static void f3d::log::info(Args... args)
Log provided args as an info.
Parameters:
- Args... args
Return type: void
Function warn
static void f3d::log::warn(Args... args)
Log provided args as a warning.
Parameters:
- Args... args
Return type: void
Function error
static void f3d::log::error(Args... args)
Log provided args as an error.
Parameters:
- Args... args
Return type: void
Function setUseColoring
static void f3d::log::setUseColoring(bool use)
Set the coloring usage, if applicable (eg: console output).
Parameters:
- bool use
Return type: void
Function setVerboseLevel
static void f3d::log::setVerboseLevel(VerboseLevel level, bool forceStdErr=false)
Set the verbose level. By default, only warnings and errors are written to stderr, debug and info are written to stdout. If forceStdErr is true, all messages including debug and info are written to stderr.
Parameters:
- VerboseLevel level
- bool forceStdErr = false
Return type: void
Function getVerboseLevel
static VerboseLevel f3d::log::getVerboseLevel()
Get the current verbose level.
Return type: VerboseLevel
Function forward
static void f3d::log::forward(const forward_fn_t &callback)
Set a callback function to forward log messages. The callback will be invoked with the level and the message string whenever a message is logged, regardless of the verbose level. Set to nullptr to disable forwarding.
Parameters:
- const forward_fn_t & callback
Return type: void