-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.hpp
75 lines (61 loc) · 1.94 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
64
65
66
67
68
69
70
71
72
73
74
75
/* Copyright (c) 2024-2024 Harry Le (avble.harry at gmail dot com)
It can be used, modified.
*/
// #include "av_connect.hpp"
template <typename... Args>
static void avllm_Log(const char *format, Args... args)
{
printf(format, args...);
}
template <typename... Args>
static void AVLLM_LOG(const char *format, Args... args)
{
avllm_Log(format, args...);
}
template <typename... Args>
static void llamacpp_log(log_level level, const char *format, Args... args)
{
static log_level log_level_ = LOG_TRACE;
if (level >= log_level_)
avllm_Log(format, args...);
}
template <typename... Args>
static void AVLLM_LOG_TRACE(const char *format, Args... args)
{
llamacpp_log(LOG_TRACE, format, args...);
}
template <typename... Args>
static void AVLLM_LOG_DEBUG(const char *format, Args... args)
{
llamacpp_log(LOG_DEBUG, format, args...);
}
template <typename... Args>
static void AVLLM_LOG_INFO(const char *format, Args... args)
{
llamacpp_log(LOG_INFO, format, args...);
}
template <typename... Args>
static void AVLLM_LOG_WARN(const char *format, Args... args)
{
llamacpp_log(LOG_WARN, format, args...);
}
template <typename... Args>
static void AVLLM_LOG_ERROR(const char *format, Args... args)
{
llamacpp_log(LOG_ERROR, format, args...);
}
class logger_function_trace_llamacpp
{
public:
logger_function_trace_llamacpp(std::string cls_, std::string func_) : cls(cls_), func(func_)
{
AVLLM_LOG_TRACE("%s:%s ENTER\n", cls.c_str(), func.c_str());
}
~logger_function_trace_llamacpp() { AVLLM_LOG_TRACE("%s:%s LEAVE\n", cls.c_str(), func.c_str()); }
private:
const std::string cls;
const std::string func;
};
#define AVLLM_LOG_TRACE_FUNCTION logger_function_trace_llamacpp x_trace_123_("", __FUNCTION__);
#define AVLLM_TRACE_CLS_FUNC_TRACE logger_function_trace_llamacpp x_trace_123_(typeid(this).name(), __FUNCTION__);
#define AVLLM_LOG_TRACE_SCOPE(xxx) logger_function_trace_llamacpp x_trace_123_("", xxx);