Add LogSystem

This commit is contained in:
Kirigaya Kazuto 2017-03-24 13:50:48 +08:00
parent 813de57b40
commit 32f91125e9
2 changed files with 59 additions and 1 deletions

View File

@ -635,6 +635,54 @@ namespace MiniEngine
return rnd.render(surf);
}
void LogSystem::d(const char* fmt,...)
{
va_list ap;
va_start(ap,fmt);
SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION,SDL_LOG_PRIORITY_DEBUG,fmt,ap);
va_end(ap);
}
void LogSystem::v(const char* fmt,...)
{
va_list ap;
va_start(ap,fmt);
SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION,SDL_LOG_PRIORITY_VERBOSE,fmt,ap);
va_end(ap);
}
void LogSystem::e(const char* fmt,...)
{
va_list ap;
va_start(ap,fmt);
SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION,SDL_LOG_PRIORITY_ERROR,fmt,ap);
va_end(ap);
}
void LogSystem::i(const char* fmt,...)
{
va_list ap;
va_start(ap,fmt);
SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION,SDL_LOG_PRIORITY_INFO,fmt,ap);
va_end(ap);
}
void LogSystem::w(const char* fmt,...)
{
va_list ap;
va_start(ap,fmt);
SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION,SDL_LOG_PRIORITY_WARN,fmt,ap);
va_end(ap);
}
void LogSystem::critical(const char* fmt,...)
{
va_list ap;
va_start(ap,fmt);
SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION,SDL_LOG_PRIORITY_CRITICAL,fmt,ap);
va_end(ap);
}
int SDLSystem::SDLInit()
{
return SDL_Init(SDL_INIT_EVERYTHING);

View File

@ -236,6 +236,16 @@ namespace MiniEngine
enum class Platform { Unknown,Windows,MacOS,Linux,iOS,Android };
enum class PowerState { Unknown,OnBattery,NoBattery,Charging,Charged };
class LogSystem
{
static void v(const char* fmt,...);/// Verbose
static void d(const char* fmt,...);/// Debug
static void i(const char* fmt,...);/// Information
static void w(const char* fmt,...);/// Warning
static void e(const char* fmt,...);/// Error
static void critical(const char* fmt,...);/// Critical
};
class SDLSystem
{
public: