Skip to content

Class endstone::Logger

ClassList > endstone > Logger

Logger class which can format and output varies levels of logs.

  • #include <endstone/logger.h>

Public Types

Type Name
enum std::uint8_t Level
Specifies the log level.

Public Functions

Type Name
Logger () = default
void critical (const std::string_view message) const
Log a message at the Critical level.
void critical (const std::format_string< Args... > format, Args &&... args) const
Log a formatted message at the Critical level.
void debug (const std::string_view message) const
Log a message at the Debug level.
void debug (const std::format_string< Args... > format, Args &&... args) const
Log a formatted message at the Debug level.
void error (const std::string_view message) const
Log a message at the Error level.
void error (const std::format_string< Args... > format, Args &&... args) const
Log a formatted message at the Error level.
virtual std::string_view getName () const = 0
Get the name of this Logger instance.
void info (const std::string_view message) const
Log a message at the Info level.
void info (const std::format_string< Args... > format, Args &&... args) const
Log a formatted message at the Info level.
virtual bool isEnabledFor (Level level) const = 0
Check if the Logger instance is enabled for the given logLevel .
virtual void log (Level level, std::string_view message) const = 0
Log a message at the given level.
void log (Level level, const std::format_string< Args... > format, Args &&... args) const
Log a formatted message at the given level.
virtual void setLevel (Level level) = 0
Set the logging level for this Logger instance.
void trace (const std::string_view message) const
Log a message at the Trace level.
void trace (const std::format_string< Args... > format, Args &&... args) const
Log a formatted message at the Trace level.
void warning (const std::string_view message) const
Log a message at the Warning level.
void warning (const std::format_string< Args... > format, Args &&... args) const
Log a formatted message at the Warning level.
virtual ~Logger () = default

Public Types Documentation

enum Level

Specifies the log level.

enum endstone::Logger::Level {
    Trace = 0,
    Debug = 1,
    Info = 2,
    Warning = 3,
    Error = 4,
    Critical = 5,
    Off = 6
};


Public Functions Documentation

function Logger

endstone::Logger::Logger () = default

function critical [½]

Log a message at the Critical level.

inline void endstone::Logger::critical (
    const std::string_view message
) const

Parameters:

  • message The message to log.

function critical [2/2]

Log a formatted message at the Critical level.

template<typename... Args, std::enable_if_t<(sizeof...( Args ) > 0), int >>
inline void endstone::Logger::critical (
    const std::format_string< Args... > format,
    Args &&... args
) const

Parameters:

  • format The format string.
  • args The arguments to substitute into the format string.

function debug [½]

Log a message at the Debug level.

inline void endstone::Logger::debug (
    const std::string_view message
) const

Parameters:

  • message The message to log.

function debug [2/2]

Log a formatted message at the Debug level.

template<typename... Args, std::enable_if_t<(sizeof...( Args ) > 0), int >>
inline void endstone::Logger::debug (
    const std::format_string< Args... > format,
    Args &&... args
) const

Parameters:

  • format The format string.
  • args The arguments to substitute into the format string.

function error [½]

Log a message at the Error level.

inline void endstone::Logger::error (
    const std::string_view message
) const

Parameters:

  • message The message to log.

function error [2/2]

Log a formatted message at the Error level.

template<typename... Args, std::enable_if_t<(sizeof...( Args ) > 0), int >>
inline void endstone::Logger::error (
    const std::format_string< Args... > format,
    Args &&... args
) const

Parameters:

  • format The format string.
  • args The arguments to substitute into the format string.

function getName

Get the name of this Logger instance.

virtual std::string_view endstone::Logger::getName () const = 0

Returns:

The name of this Logger instance.


function info [½]

Log a message at the Info level.

inline void endstone::Logger::info (
    const std::string_view message
) const

Parameters:

  • message The message to log.

function info [2/2]

Log a formatted message at the Info level.

template<typename... Args, std::enable_if_t<(sizeof...( Args ) > 0), int >>
inline void endstone::Logger::info (
    const std::format_string< Args... > format,
    Args &&... args
) const

Parameters:

  • format The format string.
  • args The arguments to substitute into the format string.

function isEnabledFor

Check if the Logger instance is enabled for the given logLevel .

virtual bool endstone::Logger::isEnabledFor (
    Level level
) const = 0

Parameters:

  • level The log level to check

Returns:

true if the logger is enabled for the Level, false otherwise.


function log [½]

Log a message at the given level.

virtual void endstone::Logger::log (
    Level level,
    std::string_view message
) const = 0

Parameters:

  • level The level at which the message should be logged.
  • message The message to log.

function log [2/2]

Log a formatted message at the given level.

template<typename... Args, std::enable_if_t<(sizeof...( Args ) > 0), int >>
inline void endstone::Logger::log (
    Level level,
    const std::format_string< Args... > format,
    Args &&... args
) const

Formats the message using std::format and logs the result. If formatting throws, the exception message is logged at the Error level instead.

Parameters:

  • level The level at which the message should be logged.
  • format The format string.
  • args The arguments to substitute into the format string.

function setLevel

Set the logging level for this Logger instance.

virtual void endstone::Logger::setLevel (
    Level level
) = 0

Parameters:

  • level The desired log level

function trace [½]

Log a message at the Trace level.

inline void endstone::Logger::trace (
    const std::string_view message
) const

Parameters:

  • message The message to log.

function trace [2/2]

Log a formatted message at the Trace level.

template<typename... Args, std::enable_if_t<(sizeof...( Args ) > 0), int >>
inline void endstone::Logger::trace (
    const std::format_string< Args... > format,
    Args &&... args
) const

Parameters:

  • format The format string.
  • args The arguments to substitute into the format string.

function warning [½]

Log a message at the Warning level.

inline void endstone::Logger::warning (
    const std::string_view message
) const

Parameters:

  • message The message to log.

function warning [2/2]

Log a formatted message at the Warning level.

template<typename... Args, std::enable_if_t<(sizeof...( Args ) > 0), int >>
inline void endstone::Logger::warning (
    const std::format_string< Args... > format,
    Args &&... args
) const

Parameters:

  • format The format string.
  • args The arguments to substitute into the format string.

function ~Logger

virtual endstone::Logger::~Logger () = default


The documentation for this class was generated from the following file include/endstone/logger.h