All Classes Functions Variables Typedefs Enumerations Groups
Classes | Typedefs | Enumerations
Debugging, Logging, and Error Handling

Classes

struct  GPU_ErrorObject
 

Typedefs

typedef struct GPU_ErrorObject GPU_ErrorObject
 

Enumerations

enum  GPU_ErrorEnum {
  GPU_ERROR_NONE = 0, GPU_ERROR_BACKEND_ERROR = 1, GPU_ERROR_DATA_ERROR = 2, GPU_ERROR_USER_ERROR = 3,
  GPU_ERROR_UNSUPPORTED_FUNCTION = 4, GPU_ERROR_NULL_ARGUMENT = 5, GPU_ERROR_FILE_NOT_FOUND = 6
}
 
enum  GPU_DebugLevelEnum {
  GPU_DEBUG_LEVEL_0 = 0, GPU_DEBUG_LEVEL_1 = 1, GPU_DEBUG_LEVEL_2 = 2, GPU_DEBUG_LEVEL_3 = 3,
  GPU_DEBUG_LEVEL_MAX = 3
}
 
enum  GPU_LogLevelEnum { GPU_LOG_INFO = 0, GPU_LOG_WARNING, GPU_LOG_ERROR }
 
DECLSPEC void SDLCALL GPU_SetDebugLevel (GPU_DebugLevelEnum level)
 
DECLSPEC GPU_DebugLevelEnum SDLCALL GPU_GetDebugLevel (void)
 
DECLSPEC void SDLCALL GPU_LogInfo (const char *format,...)
 
DECLSPEC void SDLCALL GPU_LogWarning (const char *format,...)
 
DECLSPEC void SDLCALL GPU_LogError (const char *format,...)
 
DECLSPEC void SDLCALL GPU_SetLogCallback (int(*callback)(GPU_LogLevelEnum log_level, const char *format, va_list args))
 
DECLSPEC void SDLCALL GPU_PushErrorCode (const char *function, GPU_ErrorEnum error, const char *details,...)
 
DECLSPEC GPU_ErrorObject SDLCALL GPU_PopErrorCode (void)
 
DECLSPEC const char *SDLCALL GPU_GetErrorString (GPU_ErrorEnum error)
 
DECLSPEC void SDLCALL GPU_SetErrorQueueMax (unsigned int max)
 

Detailed Description

Use GPU_Log() for normal logging output (e.g. to replace printf). Other logging priorities are handled by GPU_LogWarning() and GPU_LogError().

SDL_gpu stores an error queue that you can read and manipulate using GPU_PopErrorCode() and GPU_PushErrorCode(). If you set the debug level using GPU_SetDebugLevel(), you can have any errors automatically logged as they are generated.

Typedef Documentation

Enumeration Type Documentation

Type enumeration for debug levels.

See Also
GPU_SetDebugLevel()
GPU_GetDebugLevel()

Type enumeration for error codes.

See Also
GPU_PushErrorCode()
GPU_PopErrorCode()

Type enumeration for logging levels.

See Also
GPU_SetLogCallback()

Function Documentation

DECLSPEC GPU_DebugLevelEnum SDLCALL GPU_GetDebugLevel ( void  )

Returns the current global debug level.

DECLSPEC const char* SDLCALL GPU_GetErrorString ( GPU_ErrorEnum  error)

Gets the string representation of an error code.

DECLSPEC void SDLCALL GPU_LogError ( const char *  format,
  ... 
)

Prints an error log message.

DECLSPEC void SDLCALL GPU_LogInfo ( const char *  format,
  ... 
)

Prints an informational log message.

DECLSPEC void SDLCALL GPU_LogWarning ( const char *  format,
  ... 
)

Prints a warning log message.

DECLSPEC GPU_ErrorObject SDLCALL GPU_PopErrorCode ( void  )

Pops an error object from the error queue and returns it. If the error queue is empty, it returns an error object with NULL function, GPU_ERROR_NONE error, and NULL details.

DECLSPEC void SDLCALL GPU_PushErrorCode ( const char *  function,
GPU_ErrorEnum  error,
const char *  details,
  ... 
)

Pushes a new error code into the error queue. If the queue is full, the queue is not modified.

Parameters
functionThe name of the function that pushed the error
errorThe error code to push on the error queue
detailsAdditional information string, can be NULL.
DECLSPEC void SDLCALL GPU_SetDebugLevel ( GPU_DebugLevelEnum  level)

Sets the global debug level. GPU_DEBUG_LEVEL_0: Normal GPU_DEBUG_LEVEL_1: Prints messages when errors are pushed via GPU_PushErrorCode() GPU_DEBUG_LEVEL_2: Elevates warning logs to error priority GPU_DEBUG_LEVEL_3: Elevates info logs to error priority

DECLSPEC void SDLCALL GPU_SetErrorQueueMax ( unsigned int  max)

Changes the maximum number of error objects that SDL_gpu will store. This deletes all currently stored errors.

DECLSPEC void SDLCALL GPU_SetLogCallback ( int(*)(GPU_LogLevelEnum log_level, const char *format, va_list args)  callback)

Sets a custom callback for handling logging. Use stdio's vsnprintf() to process the va_list into a string. Passing NULL as the callback will reset to the default internal logging.