1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 15:49:56 +00:00
openmw-tes3mp/components/openmw-mp/Log.hpp

63 lines
1.7 KiB
C++
Raw Normal View History

2016-08-14 23:45:42 +00:00
//
// Created by koncord on 15.08.16.
//
#ifndef OPENMW_LOG_HPP
#define OPENMW_LOG_HPP
2016-12-18 04:43:30 +00:00
#include <boost/filesystem.hpp>
2016-11-17 04:39:35 +00:00
#ifdef __GNUC__
#pragma GCC system_header
#endif
2016-08-14 23:45:42 +00:00
#if defined(NOLOGS)
#define LOG_INIT(logLevel)
#define LOG_QUIT()
#define LOG_MESSAGE(level, msg, ...)
#define LOG_MESSAGE_SIMPLE(level, msg, ...)
#else
#define LOG_INIT(logLevel) Log::Create(logLevel)
#define LOG_QUIT() Log::Delete()
2016-11-17 12:51:03 +00:00
#if defined(_MSC_VER)
#define LOG_MESSAGE(level, msg, ...) Log::Get().print((level), (1), (__FILE__), (__LINE__), (msg), __VA_ARGS__)
#define LOG_MESSAGE_SIMPLE(level, msg, ...) Log::Get().print((level), (1), (0), (0), (msg), __VA_ARGS__)
#define LOG_APPEND(level, msg, ...) Log::Get().print((level), (0), (0), (0), (msg), __VA_ARGS__)
#else
2016-11-17 04:39:35 +00:00
#define LOG_MESSAGE(level, msg, args...) Log::Get().print((level), (1), (__FILE__), (__LINE__), (msg), ##args)
#define LOG_MESSAGE_SIMPLE(level, msg, args...) Log::Get().print((level), (1), (0), (0), (msg), ##args)
#define LOG_APPEND(level, msg, args...) Log::Get().print((level), (0), (0), (0), (msg), ##args)
2016-08-14 23:45:42 +00:00
#endif
2016-11-17 12:51:03 +00:00
#endif
2016-08-14 23:45:42 +00:00
class Log
{
2016-11-17 04:39:35 +00:00
public:
enum
{
LOG_VERBOSE = 0,
LOG_INFO,
LOG_WARN,
LOG_ERROR,
LOG_FATAL
};
static void Create(int logLevel);
static void Delete();
static const Log &Get();
static void SetLevel(int level);
void print(int level, bool hasPrefix, const char *file, int line, const char *message, ...) const;
static std::string getFilenameTimestamp();
2016-11-17 04:39:35 +00:00
private:
Log(int logLevel);
/// Not implemented
2017-06-27 14:56:02 +00:00
Log(const Log &) = delete;
2016-11-17 04:39:35 +00:00
/// Not implemented
2017-06-27 14:56:02 +00:00
Log &operator=(Log &) = delete;
2016-11-17 04:39:35 +00:00
static Log *sLog;
int logLevel;
2016-08-14 23:45:42 +00:00
};
#endif //OPENMW_LOG_HPP