16#ifndef LLAMA_UTILS__LOGS_HPP
17#define LLAMA_UTILS__LOGS_HPP
39typedef void (*
LogFunction)(
const char *file,
const char *function,
int line,
40 const char *text, ...);
88 const char *filename = std::strrchr(path,
'/');
90 filename = std::strrchr(path,
'\\');
92 return filename ? filename + 1 : path;
95#define LLAMA_LOG_ERROR(text, ...) \
96 if (llama_utils::log_level >= llama_utils::ERROR) \
97 llama_utils::log_error(llama_utils::extract_filename(__FILE__), \
98 __FUNCTION__, __LINE__, text, ##__VA_ARGS__)
100#define LLAMA_LOG_WARN(text, ...) \
101 if (llama_utils::log_level >= llama_utils::WARN) \
102 llama_utils::log_warn(llama_utils::extract_filename(__FILE__), __FUNCTION__, \
103 __LINE__, text, ##__VA_ARGS__)
105#define LLAMA_LOG_INFO(text, ...) \
106 if (llama_utils::log_level >= llama_utils::INFO) \
107 llama_utils::log_info(llama_utils::extract_filename(__FILE__), __FUNCTION__, \
108 __LINE__, text, ##__VA_ARGS__)
110#define LLAMA_LOG_DEBUG(text, ...) \
111 if (llama_utils::log_level >= llama_utils::DEBUG) \
112 llama_utils::log_debug(llama_utils::extract_filename(__FILE__), \
113 __FUNCTION__, __LINE__, text, ##__VA_ARGS__)
Definition llama_params.hpp:37
LogLevel
Enum representing different log levels for controlling log verbosity.
Definition logs.hpp:56
@ ERROR
Log level for error messages. Only critical errors should be logged.
Definition logs.hpp:58
@ WARN
Definition logs.hpp:61
@ INFO
Definition logs.hpp:64
@ DEBUG
Definition logs.hpp:67
LogLevel log_level
The current log level for the application.
Definition logs.cpp:119
void(* LogFunction)(const char *file, const char *function, int line, const char *text,...)
Type definition for a logging function.
Definition logs.hpp:39
void set_log_level(LogLevel log_level)
Sets the log level for the logs.
Definition logs.cpp:121
LogFunction log_warn
Pointer to the warning logging function.
Definition logs.cpp:114
const char * extract_filename(const char *path)
Extracts the filename from a given file path.
Definition logs.hpp:87
LogFunction log_info
Pointer to the info logging function.
Definition logs.cpp:115
LogFunction log_error
Pointer to the error logging function.
Definition logs.cpp:113
LogFunction log_debug
Pointer to the debug logging function.
Definition logs.cpp:116