-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLog.h
More file actions
49 lines (38 loc) · 967 Bytes
/
Log.h
File metadata and controls
49 lines (38 loc) · 967 Bytes
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
#ifndef UTIL_LOG_H_
#define UTIL_LOG_H_
#pragma once
#include <iostream>
#include <string>
#include <sstream>
enum LogLevel {
INFO,
WARNING,
ERR,
};
/** A simple log message
*
* @author: welbon
*
* @date 2012-08-14
*/
class LogMessage {
public:
LogMessage(int fake_level,
const std::string& file_name,
const int line);
virtual ~LogMessage();
static void Initialize(const std::wstring file, bool log);
std::ostringstream& stream() { return stream_; }
protected:
std::string FormatInt64ToTimeString();
std::string GetLevel();
protected:
LogLevel fake_level_;
int line_;
std::string file_;
std::ostringstream stream_;
};
#define LOG(level) LogMessage(level, __FILE__, __LINE__).stream()
extern std::ostream& operator<<(std::ostream& out, const wchar_t* wstr);
extern std::ostream& operator<<(std::ostream& out, const std::wstring& wstr);
#endif //UTIL_LOG_H_