7#ifndef LOGICALACCESS_LOGS_HPP
8#define LOGICALACCESS_LOGS_HPP
14#define EXCEPTION(type, ...) \
20#define EXCEPTION_ASSERT(condition, type, msg) \
23 throw EXCEPTION(type, msg); \
26#include <logicalaccess/plugins/llacommon/lla_common_api.hpp>
62LLA_COMMON_API std::ostream &
operator<<(std::ostream &ss,
63 const std::vector<bool> &bytebuff);
68template <
long unsigned int Size>
69std::ostream &
operator<<(std::ostream &ss,
const std::array<uint8_t, Size> &bytearray)
71 ss <<
ByteVector(bytearray.begin(), bytearray.end());
92 Logs(
const char *file,
const char *func,
int line,
enum LogLevel level);
115 static std::string pretty_context_infos();
143#pragma SWIG nowarn=302
154LLA_COMMON_API std::ostream &
operator<<(std::ostream &ss,
155 const std::vector<bool> &bytebuff);
157LLA_COMMON_API std::ostream &
operator<<(std::ostream &ss,
158 const std::vector<bool> &bytebuff);
160#define LOG(x) logicalaccess::Logs(__FILE__, __FUNCTION__, __LINE__, x)
170template <
typename Current,
typename... T>
171typename std::enable_if<!std::is_same<
172 unsigned char,
typename std::remove_reference<Current>::type>::value>::type
173trace_print_helper(std::stringstream &ss,
const char *param_names,
int idx, Current &&c,
179template <
typename Current,
typename... T>
180typename std::enable_if<std::is_same<
181 unsigned char,
typename std::remove_reference<Current>::type>::value>::type
182trace_print_helper(std::stringstream &ss,
const char *param_names,
int idx, Current &&c,
186template <
typename Current,
typename... T>
187typename std::enable_if<std::is_same<
188 unsigned char,
typename std::remove_reference<Current>::type>::value>::type
196template <
typename Current,
typename... T>
197typename std::enable_if<!std::is_same<
198 unsigned char,
typename std::remove_reference<Current>::type>::value>::type
207template <
typename... T>
208void trace_print(std::stringstream &ss,
const char *param_names, T &&... params)
218 std::stringstream trace_stringstream; \
219 trace_print(trace_stringstream, #__VA_ARGS__, ##__VA_ARGS__); \
220 LOG(TRACE) << trace_stringstream.str();
227#define LLA_LOG_CTX(param) \
228 LogContext lla_log_ctx([&](void) { \
229 std::stringstream logger_macro_ss__; \
230 logger_macro_ss__ << param; \
231 return logger_macro_ss__.str(); \
237#define THROW_EXCEPTION_WITH_LOG(type, msg, ...) \
239 LOG(logicalaccess::LogLevel::ERRORS) << msg; \
240 throw EXCEPTION(type, msg, ##__VA_ARGS__); \
246#define EXCEPTION_ASSERT_WITH_LOG(condition, type, msg, ...) \
249 THROW_EXCEPTION_WITH_LOG(type, msg, ##__VA_ARGS__); \
std::stringstream _stream
Definition: logs.hpp:118
Logs & operator<<(const T &arg)
Definition: logs.hpp:97
static bool logToStderr
Definition: logs.hpp:109
static std::map< LogLevel, std::string > logLevelMsg
Definition: logs.hpp:119
static std::ofstream logfile
Definition: logs.hpp:103
enum LogLevel d_level
Definition: logs.hpp:117
std::vector< uint8_t > ByteVector
Definition: lla_fwd.hpp:80
LogLevel
Definition: logs.hpp:38
@ WARNINGS
Definition: logs.hpp:42
@ ALERTS
Definition: logs.hpp:47
@ DEBUGS
Definition: logs.hpp:48
@ NONE
Definition: logs.hpp:39
@ COMS
Definition: logs.hpp:49
@ EMERGENSYS
Definition: logs.hpp:45
@ CRITICALS
Definition: logs.hpp:46
@ PLUGINS_ERROR
Definition: logs.hpp:51
@ NOTICES
Definition: logs.hpp:43
@ PLUGINS
Definition: logs.hpp:50
@ ERRORS
Definition: logs.hpp:44
@ TRACE
Definition: logs.hpp:40
@ INFOS
Definition: logs.hpp:41
std::string get_nth_param_name(const char *param_names, int idx)
Definition: logs.cpp:162
LLA_CORE_API std::ostream & operator<<(std::ostream &os, const Key &key)
Output to stream operator.
Definition: key.cpp:298
void trace_print(std::stringstream &ss, const char *param_names, T &&... params)
Definition: logs.hpp:208
void trace_print_helper(std::stringstream &ss, const char *param_names, int)
Definition: logs.cpp:186
bool old_
Definition: logs.hpp:135