Saga
Saga Game Engine
Loading...
Searching...
No Matches
logger.h
Go to the documentation of this file.
1#pragma once
2#include "../defines.h"
3#include <string>
4
5// from https://www.youtube.com/watch?v=l9e8PJskYnI&list=PLv8Ddw9K0JPg1BEO-RS-0MYs423cvLVtj&index=5
6
7namespace Saga {
8
9#define LOG_WARN_ENABLED 1
10#define LOG_INFO_ENABLED 1
11#define LOG_DEBUG_ENABLED 1
12#define LOG_TRACE_ENABLED 1
13
14#if SAGA_RELEASE == 1
15#define LOG_DEBUG_ENABLED 0
16#define LOG_TRACE_ENABLED 0
17#endif
18
24 FATAL = 0,
25 ERROR = 1,
26 WARN = 2,
27 INFO = 3,
28 DEBUG = 4,
29 TRACE = 5
30};
31
38bool initializeLogger();
39
48void logOutput(LogLevel level, const char* message, ...);
49
53void shutDownLogger();
54
55#ifndef SFATAL
60#define SFATAL(message, ...) logOutput(Saga::LogLevel::FATAL, message, ##__VA_ARGS__)
61#endif
62
63#ifndef SERROR
68#define SERROR(message, ...) logOutput(Saga::LogLevel::ERROR, message, ##__VA_ARGS__)
69#endif
70
71#if LOG_WARN_ENABLED == 1
72#ifndef SWARN
77#define SWARN(message, ...) logOutput(Saga::LogLevel::WARN, message, ##__VA_ARGS__)
78#endif
79#else
80#define SWARN(message, ...)
81#endif
82
83#if LOG_INFO_ENABLED == 1
84#ifndef SINFO
89#define SINFO(message, ...) logOutput(Saga::LogLevel::INFO, message, ##__VA_ARGS__)
90#endif
91#else
92#define SINFO(message, ...)
93#endif
94
95#if LOG_DEBUG_ENABLED == 1
96#ifndef SDEBUG
101#define SDEBUG(message, ...) logOutput(Saga::LogLevel::DEBUG, message, ##__VA_ARGS__)
102#endif
103#else
104#define SDEBUG(message, ...)
105#endif
106
107#if LOG_TRACE_ENABLED == 1
108#ifndef STRACE
113#define STRACE(message, ...) logOutput(Saga::LogLevel::TRACE, message, ##__VA_ARGS__)
114#endif
115#else
116#define STRACE(message, ...)
117#endif
118
119}
Definition: app.cpp:8
void shutDownLogger()
Shut down the logger, and flush any buffered output.
Definition: logger.cpp:30
LogLevel
Define multiple levels of logging. Fatal and Error are always enabled, and debug and traced are left ...
Definition: logger.h:23
@ INFO
Generally useful information to log, like successful initialization or completion of significant task...
Definition: logger.h:27
@ ERROR
Reserved for anything that will cause the application to crash, or create undefined behaviour....
Definition: logger.h:25
@ WARN
Anything that can cause oddities with the application's execution. This might or might not result in ...
Definition: logger.h:26
@ DEBUG
Fine-grained information events that is useful to debug the application.
Definition: logger.h:28
@ FATAL
Reserved for anything that would cause the core engine to crash. This should force a shutdown to prev...
Definition: logger.h:24
@ TRACE
Finer-grained information, typically targetted towards one part of the application.
Definition: logger.h:29
void logOutput(LogLevel level, const char *message,...)
Log an output.
Definition: logger.cpp:37
bool initializeLogger()
Initialize the logger. Neccessary to call before any logging.
Definition: logger.cpp:24