-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.h
executable file
·68 lines (52 loc) · 1.43 KB
/
log.h
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
/**@file log.h
*
* This is part of keylogger, demo project to hook key event of a process
* and do periodic screenshoot of screen.
*
* @author Oky Firmansyah <mail@okyfirmansyah.net>.
*
* @date Created : Apr 03, 2017 okyfirmansyah
*/
#ifndef LOG_H_INCLUDED
#define LOG_H_INCLUDED
#include <string>
#include <fstream>
/** this is implementation of mini-logging mechanism
*/
void logInit(const std::string &filename);
extern std::unique_ptr<std::ofstream> logStream;
void logTime();
static void logOut()
{
}
template<typename First, typename... T>
static void logOut(First&& first, T&&...args)
{
*logStream<<std::forward<First>(first);
logOut(std::forward<T>(args)...);
}
template<typename First, typename... T>
void logInfo(First&& first, T&&...args)
{
logTime();
*logStream<<"[Info]";
logOut(std::forward<First>(first),std::forward<T>(args)...);
*logStream<<std::endl;
}
template<typename First, typename... T>
void logWarning(First&& first, T&&...args)
{
logTime();
*logStream<<"[Warning]";
logOut(std::forward<First>(first),std::forward<T>(args)...);
*logStream<<std::endl;
}
template<typename First, typename... T>
void logError(First&& first, T&&...args)
{
logTime();
*logStream<<"[Error]";
logOut(std::forward<First>(first),std::forward<T>(args)...);
*logStream<<std::endl;
}
#endif // LOG_H_INCLUDED