Gamedev Framework (gf)  0.3.0
A C++11 framework for 2D games
Public Types | Public Member Functions | Static Public Member Functions | List of all members
gf::Log Class Reference

Logging functions. More...

#include <gf/Log.h>

Public Types

enum  Level : int {
  Debug,
  Info,
  Warn,
  Error,
  Fatal
}
 The severity level of the log. More...
 
enum  Category : int {
  General,
  Graphics,
  Network,
  Physics,
  Resources
}
 The category of the log. More...
 

Public Member Functions

 Log ()=delete
 Deleted constructor. More...
 

Static Public Member Functions

static void setLevel (Level level)
 Set a global severity level. More...
 
static void setLevel (Category category, Level level)
 Set a severity level for a category. More...
 
static void debug (Category category, const char *fmt,...)
 Print a debug message. More...
 
static void info (Category category, const char *fmt,...)
 Print an info message. More...
 
static void warning (Category category, const char *fmt,...)
 Print a warning message. More...
 
static void error (Category category, const char *fmt,...)
 Print an error message. More...
 
static void fatal (Category category, const char *fmt,...)
 Print a fatal message and quit. More...
 
static void print (const char *fmt,...)
 Print a message without any level or category. More...
 

Detailed Description

Logging functions.

Logging functions are used to report some events that have happened in the system. These functions print messages to the standard error. It uses printf-like format strings.

A message is associated to a severity level and a category. The severity level indicates the severity of the message and range from a simple debug message to a fatal message. The category of the message indicates the origin of the message in the library.

You can set the minimum severity for which messages are displayed either globally or for each category. By default, the minimum severity level is gf::Log::Warning (or gf::Log::Debug if debug mode is activated at build time).

Example:

int entity = ...;
gf::Log::warning(gf::Log::General, "Something weird happened to entity %i!\n", entity);

Constructor & Destructor Documentation

gf::Log::Log ( )
delete

Deleted constructor.

Member Function Documentation

static void gf::Log::debug ( Category  category,
const char *  fmt,
  ... 
)
inlinestatic

Print a debug message.

Parameters
categoryThe category
fmtThe format string
static void gf::Log::error ( Category  category,
const char *  fmt,
  ... 
)
inlinestatic

Print an error message.

Parameters
categoryThe category
fmtThe format string
static void gf::Log::fatal ( Category  category,
const char *  fmt,
  ... 
)
inlinestatic

Print a fatal message and quit.

Parameters
categoryThe category
fmtThe format string
static void gf::Log::info ( Category  category,
const char *  fmt,
  ... 
)
inlinestatic

Print an info message.

Parameters
categoryThe category
fmtThe format string
static void gf::Log::print ( const char *  fmt,
  ... 
)
static

Print a message without any level or category.

This function can be used for printing messages during the development.

Parameters
fmtThe format string
static void gf::Log::setLevel ( Level  level)
static

Set a global severity level.

Parameters
levelThe severity level
static void gf::Log::setLevel ( Category  category,
Level  level 
)
static

Set a severity level for a category.

Parameters
categoryThe category
levelThe severity level
static void gf::Log::warning ( Category  category,
const char *  fmt,
  ... 
)
inlinestatic

Print a warning message.

Parameters
categoryThe category
fmtThe format string