spacebox/src/Log.hpp

73 lines
2.0 KiB
C++

/* /\ +--------------------------------------------------------------+
____/ \____ /| - zlib/MIT/Unlicenced game framework licensed to freely use, |
\ / / | copy, modify and sell without restriction |
+--\ ^__^ /--+ | |
| ~/ \~ | | - originally created at [http://nugget.fun] |
| ~~~~~~~~~~~~ | +--------------------------------------------------------------+
| SPACE ~~~~~ | /
| ~~~~~~~ BOX |/
+--------------+
[Log.hpp]
Log messages of specified priority through the SDL logging method, which is overridden in
the Game class to write to stdout, file, or both, depending on the user's configuration
settings.
*/
#ifndef SB_LOG_H_
#define SB_LOG_H_
/* include Open GL */
#if defined(__EMSCRIPTEN__)
#include <GL/glew.h>
#elif defined(__ANDROID__) && defined(ANDROID)
#include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>
#else
#include "glew/glew.h"
#endif
#include <iostream>
#include <sstream>
#include <functional>
#include <SDL.h>
/* #include "filesystem.hpp" */
namespace sb
{
class Log
{
public:
/* These definitions are equivalent to SDL's SDL_LOG_PRIORITY_* values */
enum Level
{
VERBOSE = 1,
DEBUG,
INFO,
WARN,
ERROR,
CRITICAL,
};
static const int DEFAULT_CATEGORY = SDL_LOG_CATEGORY_CUSTOM;
Log(std::function<void(void*, int, SDL_LogPriority, const char*)>);
static void log(const std::string&, const Level = INFO, const int = DEFAULT_CATEGORY);
static void log(const std::ostringstream&, const Level = INFO, const int = DEFAULT_CATEGORY);
static bool gl_errors(const std::string& = "");
static void sdl_error(const std::string&);
/* static void record(void*, int, SDL_LogPriority, const char*); */
};
/* Log log = Log(&Log::record); */
}
#endif