galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
Log.cpp
Go to the documentation of this file.
1
7
8#include <SDL3/SDL_log.h>
9
10#include "Log.hpp"
11
12namespace galaxy
13{
14 void sdl_log_callback(void* userdata, int category, SDL_LogPriority priority, const char* message)
15 {
16 switch (priority)
17 {
18 case SDL_LOG_PRIORITY_INVALID:
19 case SDL_LOG_PRIORITY_TRACE:
20 case SDL_LOG_PRIORITY_VERBOSE:
21 case SDL_LOG_PRIORITY_DEBUG:
22 case SDL_LOG_PRIORITY_INFO:
23 GALAXY_LOG(GALAXY_INFO, message);
24 break;
25 case SDL_LOG_PRIORITY_WARN:
26 GALAXY_LOG(GALAXY_WARN, message);
27 break;
28 case SDL_LOG_PRIORITY_ERROR:
29 case SDL_LOG_PRIORITY_CRITICAL:
30 GALAXY_LOG(GALAXY_ERROR, message);
31 break;
32 default:
33 GALAXY_LOG(GALAXY_INFO, message);
34 break;
35 }
36 }
37
38 Log::Log() noexcept
39 : m_min_level {LogLevel::INFO}
40 {
41 m_sinks.reserve(2);
42 SDL_SetLogOutputFunction(&sdl_log_callback, nullptr);
43 }
44
45 Log::~Log() noexcept
46 {
47 // We reset min level because logging is done as a singleton.
49 m_sinks.clear();
50 }
51} // namespace galaxy
#define GALAXY_INFO
Log.hpp galaxy.
Definition Log.hpp:22
#define GALAXY_LOG(level, msg,...)
Definition Log.hpp:28
#define GALAXY_WARN
Definition Log.hpp:23
#define GALAXY_ERROR
Definition Log.hpp:24
Log() noexcept
Constructor.
Definition Log.cpp:38
~Log() noexcept
Destructor.
Definition Log.cpp:45
std::vector< std::unique_ptr< Sink > > m_sinks
List of sinks.
Definition Log.hpp:118
LogLevel m_min_level
Minimum level for a message to be logged.
Definition Log.hpp:113
Animated.cpp galaxy.
Definition Animated.cpp:16
@ INFO
Info Log Level.
void sdl_log_callback(void *userdata, int category, SDL_LogPriority priority, const char *message)
Definition Log.cpp:14