Logging module

Butano logging system.

It allows to print information on the console of multiple emulators.

It can be enabled or disabled by overloading the definition of BN_CFG_LOG_ENABLED.

It supports printing on only one emulator at once. The supported emulator can be changed by overloading the definition of BN_CFG_LOG_BACKEND.

Files

file bn_config_log.h
file bn_log.h
file bn_log_backend.h
file bn_log_level.h

Enums

enum class log_level: uint8_t { FATAL, ERROR, WARN, INFO, DEBUG }
Specifies the level of a log message.

Functions

void log(const istring_base& message)
Prints in one line of text the given message with the default log level (bn::log_level::WARN).
void log(log_level level, const istring_base& message)
Prints in one line of text the given message.

Defines

#define BN_CFG_LOG_ENABLED
#define BN_CFG_LOG_BACKEND
#define BN_CFG_LOG_MAX_SIZE
#define BN_LOG(...)
#define BN_LOG_LEVEL(level, ...)
#define BN_LOG_BACKEND_MGBA
#define BN_LOG_BACKEND_NOCASHGBA
#define BN_LOG_BACKEND_VBA

Enum documentation

enum class log_level: uint8_t

Specifies the level of a log message.

Most emulators ignore this log level.

Enumerators
FATAL

Fatal. A message with this level stops the execution.

ERROR

Error.

WARN

Warn (default).

INFO

Info.

DEBUG

Debug.

Function documentation

void log(const istring_base& message)
#include <bn_log.h>

Prints in one line of text the given message with the default log level (bn::log_level::WARN).

void log(log_level level, const istring_base& message)
#include <bn_log.h>

Prints in one line of text the given message.

Parameters
level Message level.
message Message to print.

Define documentation

#define BN_CFG_LOG_ENABLED

Specifies if logging is enabled or not.

#define BN_CFG_LOG_BACKEND

Specifies the log backend to use.

Values not specified in BN_LOG_BACKEND_* macros are not allowed.

#define BN_CFG_LOG_MAX_SIZE

Specifies the maximum number of characters that can be logged with one BN_LOG call.

#define BN_LOG(...)
#include <bn_log.h>

Prints in one line of text the representation of the given parameters with the default log level (bn::log_level::WARN).

Example:

BN_LOG("Invalid integer: ", integer);

Custom parameter types are supported by overloading bn::ostringstream::operator<<.

Example:

bn::ostringstream& operator<<(bn::ostringstream& stream, const custom_type& custom_value)
{
    stream.append("custom_type: ");
    stream.append(custom_value.data);
    return stream;
}

#define BN_LOG_LEVEL(level, ...)
#include <bn_log.h>

Prints in one line of text the representation of the given parameters with the specified log level.

Example:

BN_LOG_LEVEL(bn::log_level::ERROR, "Invalid integer: ", integer);

Custom parameter types are supported by overloading bn::ostringstream::operator<<.

Example:

bn::ostringstream& operator<<(bn::ostringstream& stream, const custom_type& custom_value)
{
    stream.append("custom_type: ");
    stream.append(custom_value.data);
    return stream;
}

#define BN_LOG_BACKEND_MGBA

mGBA log backend.

It also works with NanoBoyAdvance and Mesen.

#define BN_LOG_BACKEND_NOCASHGBA

No$gba log backend.

#define BN_LOG_BACKEND_VBA

VisualBoyAdvance log backend.

It crashes on hardware and on other emulators!