overview wiki api reference download
 All Classes Functions Variables Typedefs Enumerations Enumerator
Classes | Public Types | Static Public Member Functions
gameplay::Logger Class Reference

#include <Logger.h>

List of all members.

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)

Detailed Description

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.


Member Enumeration Documentation

Enumeration of valid log levels.


Member Function Documentation

static bool gameplay::Logger::isEnabled ( Level  level) [static]

Determines if logging is currently enabled for the given level.

Parameters:
levelLog level.
Returns:
True if logging is enabled for this level, or false if it is disabled.
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.

Parameters:
levelLog level.
messageLog 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.

Parameters:
levelLog level to set logging callback for.
logFunctionPointer 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.

Parameters:
levelLog level.
logFunctionThe 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.

Parameters:
levelLog level to enable or disable.
enabledTrue to enable the logger for the given level, false to disable it.
 All Classes Functions Variables Typedefs Enumerations Enumerator