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
LuaLogging.cpp
Go to the documentation of this file.
1
7
8
#include <sol/sol.hpp>
9
10
#include "
galaxy/logging/Log.hpp
"
11
12
namespace
galaxy
13
{
14
namespace
lua
15
{
16
void
log_wrapper
(
logging::LogLevel
error_level, std::string_view message)
17
{
18
switch
(error_level)
19
{
20
case
logging::LogLevel::_INFO_
:
21
GALAXY_LOG
(
GALAXY_INFO
,
"{0}"
, message);
22
break
;
23
24
case
logging::LogLevel::_DEBUG_
:
25
GALAXY_LOG
(
GALAXY_DEBUG
,
"{0}"
, message);
26
break
;
27
28
case
logging::LogLevel::_WARNING_
:
29
GALAXY_LOG
(
GALAXY_WARNING
,
"{0}"
, message);
30
break
;
31
32
case
logging::LogLevel::_ERROR_
:
33
GALAXY_LOG
(
GALAXY_ERROR
,
"{0}"
, message);
34
break
;
35
36
case
logging::LogLevel::_FATAL_
:
37
GALAXY_LOG
(
GALAXY_FATAL
,
"{0}"
, message);
38
break
;
39
}
40
}
41
42
void
inject_logging
()
43
{
44
auto
& lua = entt::locator<sol::state>::value();
45
46
// clang-format off
47
lua.new_enum<
logging::LogLevel
>(
"LogLevels"
,
48
{
49
{
"INFO"
,
logging::LogLevel::_INFO_
},
50
{
"DEBUG"
,
logging::LogLevel::_DEBUG_
},
51
{
"WARNING"
,
logging::LogLevel::_WARNING_
},
52
{
"ERROR"
,
logging::LogLevel::_ERROR_
},
53
{
"FATAL"
,
logging::LogLevel::_FATAL_
}
54
});
55
// clang-format on
56
57
lua.set_function(
"galaxy_log"
, &
log_wrapper
);
58
}
59
}
// namespace lua
60
}
// namespace galaxy
Log.hpp
GALAXY_DEBUG
#define GALAXY_DEBUG
Definition
Log.hpp:23
GALAXY_INFO
#define GALAXY_INFO
Log.hpp galaxy.
Definition
Log.hpp:22
GALAXY_WARNING
#define GALAXY_WARNING
Definition
Log.hpp:24
GALAXY_LOG
#define GALAXY_LOG(level, msg,...)
Definition
Log.hpp:29
GALAXY_FATAL
#define GALAXY_FATAL
Definition
Log.hpp:26
GALAXY_ERROR
#define GALAXY_ERROR
Definition
Log.hpp:25
galaxy::logging::LogLevel
LogLevel
Used to determine filtering and colouring of log messages.
Definition
LogLevel.hpp:19
galaxy::logging::LogLevel::_DEBUG_
@ _DEBUG_
Debug Log Level.
galaxy::logging::LogLevel::_ERROR_
@ _ERROR_
Error Log Level.
galaxy::logging::LogLevel::_FATAL_
@ _FATAL_
Fatal Log Level.
galaxy::logging::LogLevel::_INFO_
@ _INFO_
Info Log Level.
galaxy::logging::LogLevel::_WARNING_
@ _WARNING_
Warning Log Level.
galaxy::lua::inject_logging
void inject_logging()
Injects logging into Lua.
Definition
LuaLogging.cpp:42
galaxy::lua::log_wrapper
void log_wrapper(logging::LogLevel error_level, std::string_view message)
Definition
LuaLogging.cpp:16
galaxy
Timer.hpp galaxy.
Definition
Async.hpp:17
galaxy
src
galaxy
scripting
lua
LuaLogging.cpp
Generated on Sat Mar 1 2025 14:49:36 for galaxy by
1.12.0