-
Notifications
You must be signed in to change notification settings - Fork 0
/
logging.hpp
52 lines (42 loc) · 1010 Bytes
/
logging.hpp
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
#ifndef SHADOW_CAST_LOGGING_HPP_INCLUDED
#define SHADOW_CAST_LOGGING_HPP_INCLUDED
#include <string>
#include <string_view>
#include <utility>
namespace sc::log
{
template <typename T>
concept StringLike =
std::is_convertible_v<std::remove_cvref_t<T>, std::string> ||
std::is_convertible_v<std::remove_cvref_t<T>, std::string_view>;
enum struct Level
{
debug,
info,
warning,
error
};
auto write(Level, std::string const&) -> void;
auto write(Level, std::string_view) -> void;
template <StringLike Msg>
auto debug(Msg&& msg) -> void
{
write(Level::debug, std::forward<Msg>(msg));
}
template <StringLike Msg>
auto info(Msg&& msg) -> void
{
write(Level::info, std::forward<Msg>(msg));
}
template <StringLike Msg>
auto warn(Msg&& msg) -> void
{
write(Level::warning, std::forward<Msg>(msg));
}
template <StringLike Msg>
auto error(Msg&& msg) -> void
{
write(Level::error, std::forward<Msg>(msg));
}
} // namespace sc::log
#endif // SHADOW_CAST_LOGGING_HPP_INCLUDED