-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlogging.hpp
More file actions
93 lines (74 loc) · 1.39 KB
/
logging.hpp
File metadata and controls
93 lines (74 loc) · 1.39 KB
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
#ifndef LOGGING_HPP_INCLUDED
#define LOGGING_HPP_INCLUDED
#include <string>
#include <fstream>
#include <iostream>
namespace lg
{
extern std::ofstream* output;
extern std::string logfile;
void set_logfile(const std::string& file);
//void log(const std::string& txt);
/*template<typename T>
void logn(T val);*/
template<typename T>
inline
void
log_b(const T& dat)
{
*output << std::to_string(dat);
}
///I think there's a better sfinae solution to this, but
template<>
inline
void
log_b(const std::string& dat)
{
*output << dat;
}
template<>
inline
void
log_b(const char* const& dat)
{
log_b(std::string(dat));
}
template<>
inline
void
log_b(char* const& dat)
{
log_b(std::string(dat));
}
template<typename T>
inline
void
log_d(T&& param)
{
using decay_t = typename std::decay<T>::type;
log_b<decay_t>(param);
}
//template<typename T>
inline
void
log_r()
{
}
template<typename T, typename... U>
inline
void
log_r(T&& param, U&&... params)
{
log_d(param);
log_r(params...);
}
template<typename... T>
inline
void
log(T&&... param)
{
log_r(param...);
*output << std::endl;
}
};
#endif // LOGGING_HPP_INCLUDED