#include <Logger.h>
Simple logger service.
- Each algorithm instance should own a
Logger
instance
- The user may control the log level of each
Logger
, thus the log level of each algorithm
- Errors and warnings print to
stderr
, whereas all other levels print to stdout
Definition at line 30 of file Logger.h.
|
enum | Level {
trace
, debug
, info
, quiet
,
warn
, error
, silent
} |
|
|
| Logger (std::string_view name="log", Level const lev=DEFAULT_LEVEL, bool const enable_style=true) |
|
void | SetLevel (std::string_view lev) |
|
void | SetLevel (Level const lev) |
|
Level | GetLevel () |
|
void | EnableStyle () |
| Enable styled log printouts, with color and emphasis.
|
|
void | DisableStyle () |
| Disable styled log printout color and emphasis.
|
|
template<typename... VALUES> |
void | Trace (std::string_view message, const VALUES... vals) const |
| Printout a log message at the trace level.
|
|
template<typename... VALUES> |
void | Debug (std::string_view message, const VALUES... vals) const |
| Printout a log message at the debug level.
|
|
template<typename... VALUES> |
void | Info (std::string_view message, const VALUES... vals) const |
| Printout a log message at the info level.
|
|
template<typename... VALUES> |
void | Warn (std::string_view message, const VALUES... vals) const |
| Printout a log message at the warn level.
|
|
template<typename... VALUES> |
void | Error (std::string_view message, const VALUES... vals) const |
| Printout a log message at the error level.
|
|
template<typename... VALUES> |
void | Print (Level const lev, std::string_view message, const VALUES... vals) const |
|
|
static std::string | Header (std::string_view message, int const width=50) |
|
◆ Level
These are the available log levels, from lowest to highest:
trace
: the most verbose level, used for fine-grained printouts for each event
debug
: less verbose printout, expected to be less frequent than trace
info
: the least verbose printout; this is the default level
quiet
: use this level to only allow warnings and errors, silencing all other printouts
warn
: an issue that may or may not be critical
error
: an issue that is likely critical
silent
: use this level to silence all printouts (use it at your own risk!)
Definition at line 45 of file Logger.h.
◆ Logger()
iguana::Logger::Logger |
( |
std::string_view | name = "log", |
|
|
Level const | lev = DEFAULT_LEVEL, |
|
|
bool const | enable_style = true ) |
- Parameters
-
name | the name of this logger instance, which will be include in all of its printouts |
lev | the log level |
enable_style | if true, certain printouts will be styled with color and emphasis |
◆ ~Logger()
iguana::Logger::~Logger |
( |
| ) |
|
|
inline |
◆ Debug()
template<typename... VALUES>
void iguana::Logger::Debug |
( |
std::string_view | message, |
|
|
const VALUES... | vals ) const |
|
inline |
Printout a log message at the debug
level.
- See also
Logger::Print
for more details
Definition at line 95 of file Logger.h.
◆ Error()
template<typename... VALUES>
void iguana::Logger::Error |
( |
std::string_view | message, |
|
|
const VALUES... | vals ) const |
|
inline |
Printout a log message at the error
level.
- See also
Logger::Print
for more details
Definition at line 104 of file Logger.h.
◆ GetLevel()
Level iguana::Logger::GetLevel |
( |
| ) |
|
Get the current log level
- Returns
- the log level
◆ Header()
static std::string iguana::Logger::Header |
( |
std::string_view | message, |
|
|
int const | width = 50 ) |
|
static |
Generate a header for a printout
- Parameters
-
message | the header message |
width | the width of the header in number of characters |
- Returns
- the header string
◆ Info()
template<typename... VALUES>
void iguana::Logger::Info |
( |
std::string_view | message, |
|
|
const VALUES... | vals ) const |
|
inline |
Printout a log message at the info
level.
- See also
Logger::Print
for more details
Definition at line 98 of file Logger.h.
◆ Print()
template<typename... VALUES>
void iguana::Logger::Print |
( |
Level const | lev, |
|
|
std::string_view | message, |
|
|
const VALUES... | vals ) const |
|
inline |
Printout a log message at the specified level. The message will only print if lev
is at least as high as the current level of this Logger
instance, as set by Logger::SetLevel
.
- Parameters
-
lev | the log level for this message |
message | the message to print; this may be a format string, as in fmt::format |
vals | values for the format string message |
Definition at line 112 of file Logger.h.
◆ SetLevel() [1/2]
void iguana::Logger::SetLevel |
( |
Level const | lev | ) |
|
Set the log level to this level. Log messages with a lower level will not be printed.
- See also
Logger::Level
for available levels.
- Parameters
-
◆ SetLevel() [2/2]
void iguana::Logger::SetLevel |
( |
std::string_view | lev | ) |
|
Set the log level to this level. Log messages with a lower level will not be printed.
- See also
Logger::Level
for available levels.
- Parameters
-
◆ Trace()
template<typename... VALUES>
void iguana::Logger::Trace |
( |
std::string_view | message, |
|
|
const VALUES... | vals ) const |
|
inline |
Printout a log message at the trace
level.
- See also
Logger::Print
for more details
Definition at line 92 of file Logger.h.
◆ Warn()
template<typename... VALUES>
void iguana::Logger::Warn |
( |
std::string_view | message, |
|
|
const VALUES... | vals ) const |
|
inline |
Printout a log message at the warn
level.
- See also
Logger::Print
for more details
Definition at line 101 of file Logger.h.
◆ Object
◆ DEFAULT_LEVEL
Level const iguana::Logger::DEFAULT_LEVEL = info |
|
static |
The default log level.
Definition at line 56 of file Logger.h.
The documentation for this class was generated from the following file:
- /__w/iguana/iguana/iguana_src/src/iguana/services/Logger.h