#include <Logger.h>
Classes | |
struct | State |
Public Types | |
enum | Level { LEVEL_INFO = 0, LEVEL_WARN = 1, LEVEL_ERROR = 2 } |
Static Public Member Functions | |
static void | log (Level level, const char *message,...) |
static bool | isEnabled (Level level) |
static void | setEnabled (Level level, bool enabled) |
static void | set (Level level, void(*logFunction)(Level, const char *)) |
static void | set (Level level, const char *logFunction) |
Defines a class providing a basic logging system for a game.
By default, this class logs messages using the gameplay::print function, which is implemented in a platform dependent manner and typically prints to stderr as well as to other possibly platform specific locations. Logging behavior can be modified for a specific log level by passing a custom C or Lua logging function to the Logger::set method. Logging can also be toggled using the setEnabled method.
Enumeration of valid log levels.
static bool gameplay::Logger::isEnabled | ( | Level | level | ) | [static] |
Determines if logging is currently enabled for the given level.
level | Log level. |
static void gameplay::Logger::log | ( | Level | level, |
const char * | message, | ||
... | |||
) | [static] |
Logs a message at the specified log level.
This method accepts a variable argument list with the same formatting specification as printf. Therefore, the message parameter can include any format specifiers that are supported by printf.
level | Log level. |
message | Log message. |
static void gameplay::Logger::set | ( | Level | level, |
void(*)(Level, const char *) | logFunction | ||
) | [static] |
Sets a C callback function to handle logging requests for the specified log level.
When a call to log is made with the given level, the specified C function will be called to handle the request.
Passing NULL for logFunction restores the default log behavior for this level.
level | Log level to set logging callback for. |
logFunction | Pointer to a C function to call for each log request at the given log level. |
static void gameplay::Logger::set | ( | Level | level, |
const char * | logFunction | ||
) | [static] |
Sets a Lua function as the log handler for the specified log level.
When a call to log is made with the given level, the specified Lua function will be called to handle the request.
Passing NULL for logFunction restores the default log behavior for this level.
level | Log level. |
logFunction | The Lua function to call for each log request at the given log level. |
static void gameplay::Logger::setEnabled | ( | Level | level, |
bool | enabled | ||
) | [static] |
Enables or disables logging at the given level.
level | Log level to enable or disable. |
enabled | True to enable the logger for the given level, false to disable it. |