logging.h
2.07 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
#ifndef ETRADECLIENT_UTILITY_LOGGING_H_INCLUDED
#define ETRADECLIENT_UTILITY_LOGGING_H_INCLUDED
#include <string>
#include <cstdint>
#include <boost/log/trivial.hpp>
namespace Logging
{
namespace trivial = boost::log::trivial;
enum class Level
{
kTrace = trivial::trace,
kDebug = trivial::debug,
kInfo = trivial::info,
kWarning = trivial::warning,
kError = trivial::error,
kFatal = trivial::fatal
};
void Init(const Level& filter_level, const std::string& log_file_name_prefix, uint32_t max_log_file_size_kb);
void Log(const Level& message_level, const std::wstring& message);
} // Logging
// Here this macro will add "FILE" "FUNCTION" and "LINE" infomation.
#define LOCATION L"{FILE:" + std::wstring(__FILEW__) + \
L" LINE:" + std::to_wstring(__LINE__) + \
L" FUNC:" + std::wstring(__FUNCTIONW__) + \
L"} "
#define LOG_TRACE(Messages) Logging::Log(Logging::Level::kTrace, Messages)
#define LOG_DEBUG(Messages) Logging::Log(Logging::Level::kDebug, Messages)
#define LOG_INFO(Messages) Logging::Log(Logging::Level::kInfo, Messages)
#define LOG_WARNING(Messages) Logging::Log(Logging::Level::kWarning, Messages)
#define LOG_ERROR(Messages) Logging::Log(Logging::Level::kError, Messages)
#define LOG_FATAL(Messages) Logging::Log(Logging::Level::kFatal, Messages)
/*
inline std::wstring LogLocation()
{
return L"{FILE:" + std::wstring(__FILEW__) +
L" LINE:" + std::to_wstring(__LINE__) +
L" FUNC:" + std::wstring(__FUNCTIONW__)
+ L"} ";
}
inline void LogTrace(const std::wstring& msg) { Logging::Log(Logging::Level::kTrace, msg); }
inline void LogDebug(const std::wstring& msg) { Logging::Log(Logging::Level::kDebug, msg); }
inline void LogInfo(const std::wstring& msg) { Logging::Log(Logging::Level::kInfo, msg); }
inline void LogWarning(const std::wstring& msg) { Logging::Log(Logging::Level::kWarning, msg); }
inline void LogError(const std::wstring& msg) { Logging::Log(Logging::Level::kError, msg); }
inline void LogFatal(const std::wstring& msg) { Logging::Log(Logging::Level::kFatal, msg); }
*/
#endif // ETRADECLIENT_UTILITY_LOGGING_H_INCLUDED