summaryrefslogtreecommitdiffstats
path: root/src/LoggerSimple.h
blob: 8e51ddedf5d3ca53166f9b67c11e4f9e005b6f69 (plain) (blame)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96

// Logging free functions defined in Logger.cpp
#pragma once

enum class eLogLevel
{
	Regular,
	Info,
	Warning,
	Error,
};

namespace Logger
{

extern void LogFormat(
	std::string_view a_Format, eLogLevel a_LogLevel, fmt::format_args a_ArgList
);
extern void LogPrintf(
	std::string_view a_Format, eLogLevel a_LogLevel, fmt::printf_args a_ArgList
);
extern void LogSimple(std::string_view a_Message, eLogLevel a_LogLevel);

}  // namespace Logger

// python style format specified logging

template <typename... Args>
void FLOG(std::string_view a_Format, const Args & ... args)
{
	Logger::LogFormat(a_Format, eLogLevel::Regular, fmt::make_format_args(args...));
}

template <typename... Args>
void FLOGINFO(std::string_view a_Format, const Args & ... args)
{
	Logger::LogFormat(a_Format, eLogLevel::Info, fmt::make_format_args(args...));
}

template <typename... Args>
void FLOGWARNING(std::string_view a_Format, const Args & ... args)
{
	Logger::LogFormat(a_Format, eLogLevel::Warning, fmt::make_format_args(args...));
}

template <typename... Args>
void FLOGERROR(std::string_view a_Format, const Args & ... args)
{
	Logger::LogFormat(a_Format, eLogLevel::Error, fmt::make_format_args(args...));
}

// printf style format specified logging (DEPRECATED)

template <typename... Args>
void LOG(std::string_view a_Format, const Args & ... args)
{
	Logger::LogPrintf(a_Format, eLogLevel::Regular, fmt::make_printf_args(args...));
}

template <typename... Args>
void LOGINFO(std::string_view a_Format, const Args & ... args)
{
	Logger::LogPrintf(a_Format, eLogLevel::Info, fmt::make_printf_args(args...));
}

template <typename... Args>
void LOGWARNING(std::string_view a_Format, const Args & ... args)
{
	Logger::LogPrintf(a_Format, eLogLevel::Warning, fmt::make_printf_args(args...));
}

template <typename... Args>
void LOGERROR(std::string_view a_Format, const Args & ... args)
{
	Logger::LogPrintf(a_Format, eLogLevel::Error, fmt::make_printf_args(args...));
}


// Macro variants

// In debug builds, translate LOGD to LOG, otherwise leave it out altogether:
#if defined(_DEBUG) || defined(TEST_GLOBALS)
	#define LOGD LOG
#else
	#define LOGD(...)
#endif  // _DEBUG

#define LOGWARN LOGWARNING

#if defined(_DEBUG) || defined(TEST_GLOBALS)
	#define FLOGD FLOG
#else
	#define FLOGD(...)
#endif  // _DEBUG

#define FLOGWARN FLOGWARNING