forked from crosire/reshade
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlog.hpp
63 lines (53 loc) · 1.23 KB
/
log.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
53
54
55
56
57
58
59
60
61
62
63
/**
* Copyright (C) 2014 Patrick Mours. All rights reserved.
* License: https://github.com/crosire/reshade#license
*/
#pragma once
#include <fstream>
#include <iomanip>
#include "unicode.hpp"
#include "filesystem.hpp"
#define LOG(LEVEL) LOG_##LEVEL()
#define LOG_INFO() reshade::log::message(reshade::log::level::info)
#define LOG_ERROR() reshade::log::message(reshade::log::level::error)
#define LOG_WARNING() reshade::log::message(reshade::log::level::warning)
namespace reshade::log
{
enum class level
{
info,
error,
warning,
};
extern std::ofstream stream;
struct message
{
message(level level);
~message();
template <typename T>
inline message &operator<<(const T &value)
{
stream << value;
return *this;
}
inline message &operator<<(const char *message)
{
stream << message;
return *this;
}
template <>
inline message &operator<<(const std::wstring &message)
{
return operator<<(utf16_to_utf8(message));
}
inline message &operator<<(const wchar_t *message)
{
return operator<<(utf16_to_utf8(message));
}
};
/// <summary>
/// Open a log file for writing.
/// </summary>
/// <param name="path">The path to the log file.</param>
bool open(const filesystem::path &path);
}