44 lines
952 B
C++
44 lines
952 B
C++
/* ================================================================
|
|
Log
|
|
----------------
|
|
This header file describes the Log class
|
|
================================================================ */
|
|
#ifndef LOG_HPP
|
|
#define LOG_HPP
|
|
|
|
#include "SDL.h"
|
|
#include <iostream>
|
|
#include <sstream>
|
|
#include <ctime>
|
|
#include <time.h>
|
|
#include <string>
|
|
|
|
#ifdef _MSC_VER // Visual Studio
|
|
#define FUNC_NAME __FUNCSIG__
|
|
#else // GCC/clang
|
|
#define FUNC_NAME __PRETTY_FUNCTION__
|
|
#endif
|
|
|
|
extern void (*logHook)(const char*, const char*);
|
|
|
|
enum LogLevel { LOG_INFO, LOG_ERROR, LOG_WARNING, LOG_DEBUG };
|
|
|
|
class Log {
|
|
public:
|
|
Log();
|
|
virtual ~Log();
|
|
std::ostringstream& Get(LogLevel level = LOG_DEBUG);
|
|
protected:
|
|
std::ostringstream os;
|
|
private:
|
|
int l;
|
|
Log(const Log&);
|
|
Log& operator =(const Log&);
|
|
};
|
|
|
|
#ifndef MAX_LOG_LEVEL
|
|
#define MAX_LOG_LEVEL LOG_ERROR
|
|
#endif
|
|
#define LOG(level) if (level > MAX_LOG_LEVEL) ; else Log().Get(level)
|
|
|
|
#endif |