Skip to content

Commit f07a554

Browse files
committed
fix: support non format_string
1 parent 9302a1c commit f07a554

1 file changed

Lines changed: 66 additions & 5 deletions

File tree

  • CommonLibF4/include/REX/REX

CommonLibF4/include/REX/REX/LOG.h

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ namespace REX
3131
}
3232
};
3333

34+
template <>
35+
struct TRACE<void>
36+
{
37+
TRACE() = delete;
38+
39+
explicit TRACE(const std::string_view a_fmt, const std::source_location a_loc = std::source_location::current())
40+
{
41+
LOG(a_loc, LOG_LEVEL::TRACE, a_fmt);
42+
}
43+
};
44+
3445
template <class... T>
3546
struct DEBUG
3647
{
@@ -42,6 +53,17 @@ namespace REX
4253
}
4354
};
4455

56+
template <>
57+
struct DEBUG<void>
58+
{
59+
DEBUG() = delete;
60+
61+
explicit DEBUG(const std::string_view a_fmt, const std::source_location a_loc = std::source_location::current())
62+
{
63+
LOG(a_loc, LOG_LEVEL::DEBUG, a_fmt);
64+
}
65+
};
66+
4567
template <class... T>
4668
struct INFO
4769
{
@@ -53,6 +75,17 @@ namespace REX
5375
}
5476
};
5577

78+
template <>
79+
struct INFO<void>
80+
{
81+
INFO() = delete;
82+
83+
explicit INFO(const std::string_view a_fmt, const std::source_location a_loc = std::source_location::current())
84+
{
85+
LOG(a_loc, LOG_LEVEL::INFO, a_fmt);
86+
}
87+
};
88+
5689
template <class... T>
5790
struct WARN
5891
{
@@ -64,6 +97,17 @@ namespace REX
6497
}
6598
};
6699

100+
template <>
101+
struct WARN<void>
102+
{
103+
WARN() = delete;
104+
105+
explicit WARN(const std::string_view a_fmt, const std::source_location a_loc = std::source_location::current())
106+
{
107+
LOG(a_loc, LOG_LEVEL::WARN, a_fmt);
108+
}
109+
};
110+
67111
template <class... T>
68112
struct ERROR
69113
{
@@ -75,6 +119,17 @@ namespace REX
75119
}
76120
};
77121

122+
template <>
123+
struct ERROR<void>
124+
{
125+
ERROR() = delete;
126+
127+
explicit ERROR(const std::string_view a_fmt, const std::source_location a_loc = std::source_location::current())
128+
{
129+
LOG(a_loc, LOG_LEVEL::ERROR, a_fmt);
130+
}
131+
};
132+
78133
template <class... T>
79134
struct CRITICAL
80135
{
@@ -86,32 +141,38 @@ namespace REX
86141
}
87142
};
88143

89-
template <class... T>
90-
struct FAIL
144+
template <>
145+
struct CRITICAL<void>
91146
{
92-
FAIL() = delete;
147+
CRITICAL() = delete;
93148

94-
explicit FAIL(const std::format_string<T...> a_fmt, T&&... a_args, const std::source_location a_loc = std::source_location::current())
149+
explicit CRITICAL(const std::string_view a_fmt, const std::source_location a_loc = std::source_location::current())
95150
{
96-
LOG(a_loc, LOG_LEVEL::CRITICAL, a_fmt, std::forward<T>(a_args)...);
151+
LOG(a_loc, LOG_LEVEL::CRITICAL, a_fmt);
97152
}
98153
};
99154

100155
template <class... T>
101156
TRACE(const std::format_string<T...>, T&&...) -> TRACE<T...>;
157+
TRACE(const std::string_view) -> TRACE<void>;
102158

103159
template <class... T>
104160
DEBUG(const std::format_string<T...>, T&&...) -> DEBUG<T...>;
161+
DEBUG(const std::string_view) -> DEBUG<void>;
105162

106163
template <class... T>
107164
INFO(const std::format_string<T...>, T&&...) -> INFO<T...>;
165+
INFO(const std::string_view) -> INFO<void>;
108166

109167
template <class... T>
110168
WARN(const std::format_string<T...>, T&&...) -> WARN<T...>;
169+
WARN(const std::string_view) -> WARN<void>;
111170

112171
template <class... T>
113172
ERROR(const std::format_string<T...>, T&&...) -> ERROR<T...>;
173+
ERROR(const std::string_view) -> ERROR<void>;
114174

115175
template <class... T>
116176
CRITICAL(const std::format_string<T...>, T&&...) -> CRITICAL<T...>;
177+
CRITICAL(const std::string_view) -> CRITICAL<void>;
117178
}

0 commit comments

Comments
 (0)