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
11
12#include "Log.hpp"
13
14#ifdef GALAXY_WIN_PLATFORM
17#endif
18
19namespace galaxy
20{
21 void sdl_log_callback(void* userdata, int category, SDL_LogPriority priority, const char* message)
22 {
23 switch (priority)
24 {
25 case SDL_LOG_PRIORITY_INVALID:
26 case SDL_LOG_PRIORITY_TRACE:
27 case SDL_LOG_PRIORITY_VERBOSE:
28 case SDL_LOG_PRIORITY_DEBUG:
29 case SDL_LOG_PRIORITY_INFO:
30 GALAXY_LOG(GALAXY_INFO, message);
31 break;
32 case SDL_LOG_PRIORITY_WARN:
33 GALAXY_LOG(GALAXY_WARN, message);
34 break;
35 case SDL_LOG_PRIORITY_ERROR:
36 case SDL_LOG_PRIORITY_CRITICAL:
37 GALAXY_LOG(GALAXY_ERROR, message);
38 break;
39 default:
40 GALAXY_LOG(GALAXY_INFO, message);
41 break;
42 }
43 }
44
45 Log::Log() noexcept
47 {
48 m_sinks.reserve(2);
49 SDL_SetLogOutputFunction(&sdl_log_callback, nullptr);
50 }
51
52 Log::~Log() noexcept
53 {
54 // We reset min level because logging is done as a singleton.
56 m_sinks.clear();
57 }
58} // namespace galaxy
59
60#ifdef GALAXY_WIN_PLATFORM
62#endif
#define GALAXY_INFO
Log.hpp galaxy.
Definition Log.hpp:23
#define GALAXY_LOG(level, msg,...)
Definition Log.hpp:29
#define GALAXY_WARN
Definition Log.hpp:24
#define GALAXY_ERROR
Definition Log.hpp:25
#define GALAXY_DISABLE_WARNING_POP
Definition Pragma.hpp:62
#define GALAXY_DISABLE_WARNING(x)
Definition Pragma.hpp:63
#define GALAXY_DISABLE_WARNING_PUSH
Macro for windows platform detection.
Definition Pragma.hpp:61
Log() noexcept
Constructor.
Definition Log.cpp:45
~Log() noexcept
Destructor.
Definition Log.cpp:52
std::vector< std::unique_ptr< Sink > > m_sinks
List of sinks.
Definition Log.hpp:119
LogLevel m_min_level
Minimum level for a message to be logged.
Definition Log.hpp:114
Application.hpp galaxy.
@ INFO
Info Log Level.
Definition LogLevel.hpp:28
void sdl_log_callback(void *userdata, int category, SDL_LogPriority priority, const char *message)
Definition Log.cpp:21