Category & priority message logging API.
More...
#include <SDL2Logger.hpp>
|
|
| SDL2Logger () |
| | Default constructor; initialize the log category to NOM and the log priority to LogPriority::NOM_LOG_PRIORITY_INFO.
|
| | SDL2Logger (int cat, nom::LogPriority prio) |
| | Construct a logging object.
|
| | ~SDL2Logger () |
| | Destructor; the logging category, logging priority level and output stream is sent to the underlying implementation at this time. Care must be taken when using this interface outside the provided macros, as the message is not output until this point.
|
| template<typename Type, typename ... Args> |
| void | write (const Type &f, const Args &... rest) |
| | Write one or more log messages to the output stream.
|
| template<typename Type> |
| void | write (const Type &f) |
| | Write a log message to the output stream.
|
| void | write (uint8_t f) |
| void | write () |
| | Write a log message to the output stream.
|
|
int | category () const |
| | Get the logging category.
|
|
LogPriority | priority () const |
| | Get the logging priority level.
|
| std::ostringstream & | output_stream () |
| | Get the log message.
|
|
|
static bool | initialized (void) |
| | Get initialization status of the default logging category priorities.
|
| static void | initialize () |
| | Set the default logging category priority levels.
|
| static LogPriority | priority (SDL_LogPriority prio) |
| | Convert an underlying implementation's logging priority level.
|
|
static SDL_LogPriority | SDL_priority (LogPriority prio) |
| | Convert the logging priority level to the underlying implementation's type.
|
| static void | set_logging_priorities (LogPriority prio) |
| | Set the logging priority for all logging categories.
|
| static void | set_logging_priority (int cat, LogPriority prio) |
| | Set the logging priority for a log category.
|
|
| static const std::string | priority_prefixes_ [NOM_NUM_LOG_PRIORITIES] |
| | Human-friendly descriptions of the logging priorities.
|
|
| | SDL2Logger (const self_type &rhs)=delete |
| | Copy constructor.
|
| self_type & | operator= (const self_type &rhs)=delete |
| | Copy assignment constructor.
|
|
| int | category_ |
| | The logging category of the log message.
|
| nom::LogPriority | priority_ |
| | The logging priority of the log message.
|
| std::ostringstream | os_ |
| | The log message stream.
|
|
| static bool | initialized_ |
| | Ensure one-time initialization of the setting of logging category priorities.
|
Category & priority message logging API.
A simple category & priority based logging facility.
If you are debugging nomlib, you might want to call:
static void set_logging_priorities(LogPriority prio)
Set the logging priority for all logging categories.
- Note
- This implementation is a C++ wrapper for SDL2's logging facilities, and is intended to be fully compatible & consistent with except where explicitly stated otherwise.
- See also
- SDL2 Logging API
-
This implementation was inspired by a Q&A blog and by a SDL2 C++ wrapper.
-
Convenience logging macros – NOM_LOG_* – for the primary usage API.
Definition at line 189 of file SDL2Logger.hpp.
◆ self_type
◆ SDL2Logger() [1/2]
| nom::SDL2Logger::SDL2Logger |
( |
int | cat, |
|
|
nom::LogPriority | prio ) |
Construct a logging object.
- Parameters
-
| cat | The logging category to assign. |
| prio | A nom::LogPriority enumeration value to use as the logging priority. |
- See also
- ::write.
◆ ~SDL2Logger()
| nom::SDL2Logger::~SDL2Logger |
( |
| ) |
|
Destructor; the logging category, logging priority level and output stream is sent to the underlying implementation at this time. Care must be taken when using this interface outside the provided macros, as the message is not output until this point.
If you wish to set a custom log output function for logging, you should do so before destruction occurs.
◆ SDL2Logger() [2/2]
| nom::SDL2Logger::SDL2Logger |
( |
const self_type & | rhs | ) |
|
|
privatedelete |
Copy constructor.
- Note
- The object cannot be copied because of the usage of std::ostringstream.
◆ initialize()
| void nom::SDL2Logger::initialize |
( |
| ) |
|
|
static |
Set the default logging category priority levels.
- See also
- NOM_LOG_CATEGORY enumeration.
◆ operator=()
| self_type & nom::SDL2Logger::operator= |
( |
const self_type & | rhs | ) |
|
|
privatedelete |
Copy assignment constructor.
- Note
- The object cannot be copied because of the usage of std::ostringstream.
◆ output_stream()
| std::ostringstream & nom::SDL2Logger::output_stream |
( |
| ) |
|
Get the log message.
- Returns
- A reference to the logger's C++ output stream.
◆ priority()
| LogPriority nom::SDL2Logger::priority |
( |
SDL_LogPriority | prio | ) |
|
|
static |
Convert an underlying implementation's logging priority level.
- Returns
- The equivalent nom::LogPriority enumeration type.
◆ set_logging_priorities()
| void nom::SDL2Logger::set_logging_priorities |
( |
LogPriority | prio | ) |
|
|
static |
Set the logging priority for all logging categories.
◆ set_logging_priority()
| void nom::SDL2Logger::set_logging_priority |
( |
int | cat, |
|
|
LogPriority | prio ) |
|
static |
Set the logging priority for a log category.
◆ write() [1/4]
| void nom::SDL2Logger::write |
( |
| ) |
|
Write a log message to the output stream.
- See also
- ::write( const Type&, const Args& )
◆ write() [2/4]
template<typename Type>
| void nom::SDL2Logger::write |
( |
const Type & | f | ) |
|
|
inline |
Write a log message to the output stream.
- See also
- ::write( const Type&, const Args& )
Definition at line 249 of file SDL2Logger.hpp.
◆ write() [3/4]
template<typename Type, typename ... Args>
| void nom::SDL2Logger::write |
( |
const Type & | f, |
|
|
const Args &... | rest ) |
|
inline |
Write one or more log messages to the output stream.
- Parameters
-
| rest | Variable list of std::ostringstream compatible arguments. |
Definition at line 233 of file SDL2Logger.hpp.
◆ write() [4/4]
| void nom::SDL2Logger::write |
( |
uint8_t | f | ) |
|
|
inline |
◆ category_
| int nom::SDL2Logger::category_ |
|
private |
The logging category of the log message.
Definition at line 315 of file SDL2Logger.hpp.
◆ initialized_
| bool nom::SDL2Logger::initialized_ |
|
staticprivate |
Ensure one-time initialization of the setting of logging category priorities.
- See also
- NOM_LOG_CATEGORY_* enumeration.
Definition at line 327 of file SDL2Logger.hpp.
◆ os_
| std::ostringstream nom::SDL2Logger::os_ |
|
private |
◆ priority_
| nom::LogPriority nom::SDL2Logger::priority_ |
|
private |
The logging priority of the log message.
Definition at line 318 of file SDL2Logger.hpp.
◆ priority_prefixes_
| const std::string nom::SDL2Logger::priority_prefixes_[NOM_NUM_LOG_PRIORITIES] |
|
static |
Human-friendly descriptions of the logging priorities.
Definition at line 195 of file SDL2Logger.hpp.
The documentation for this class was generated from the following file: