-
Notifications
You must be signed in to change notification settings - Fork 125
/
LogManager.cpp
50 lines (42 loc) · 1015 Bytes
/
LogManager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// SPDX-License-Identifier: MIT
/*
$info$
tags: glue|log-manager
$end_info$
*/
#include <FEXCore/Utils/CompilerDefs.h>
#include <FEXCore/Utils/LogManager.h>
#include <FEXCore/fextl/fmt.h>
namespace LogMan {
namespace Throw {
ThrowHandler Handler {};
void InstallHandler(ThrowHandler _Handler) {
Handler = _Handler;
}
void UnInstallHandler() {
Handler = nullptr;
}
void MFmt(const char* fmt, const fmt::format_args& args) {
if (Handler) {
auto msg = fextl::fmt::vformat(fmt, args);
Handler(msg.c_str());
}
FEX_TRAP_EXECUTION;
}
} // namespace Throw
namespace Msg {
MsgHandler Handler {};
void InstallHandler(MsgHandler _Handler) {
Handler = _Handler;
}
void UnInstallHandler() {
Handler = nullptr;
}
void MFmtImpl(DebugLevels level, const char* fmt, const fmt::format_args& args) {
if (Handler) {
const auto msg = fextl::fmt::vformat(fmt, args);
Handler(level, msg.c_str());
}
}
} // namespace Msg
} // namespace LogMan