26 #ifndef ATSCPPAPI_LOGGER_H_
27 #define ATSCPPAPI_LOGGER_H_
32 #if !defined(ATSCPPAPI_PRINTFLIKE)
33 #if defined(__GNUC__) || defined(__clang__)
41 #define ATSCPPAPI_PRINTFLIKE(fmt, arg) __attribute__((format(printf, fmt, arg)))
43 #define ATSCPPAPI_PRINTFLIKE(fmt, arg)
56 #define LOG_DEBUG(log, fmt, ...) \
58 (log).logDebug("[%s:%d, %s()] " fmt, __FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__); \
65 #define LOG_INFO(log, fmt, ...) \
67 (log).logInfo("[%s:%d, %s()] " fmt, __FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__); \
74 #define LOG_ERROR(log, fmt, ...) \
76 (log).logError("[%s:%d, %s()] " fmt, __FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__); \
86 extern "C" void TSDebug(
const char *tag,
const char *fmt, ...) ATSCPPAPI_PRINTFLIKE(2,3);
95 extern "C"
void TSError(const
char *fmt, ...) ATSCPPAPI_PRINTFLIKE(1,2);
99 #define STRINGIFY0(x) #x
100 #define STRINGIFY(x) STRINGIFY0(x)
101 #define LINE_NO STRINGIFY(__LINE__)
108 #define TS_DEBUG(tag, fmt, ...) \
110 TSDebug(tag "." __FILE__ ":" LINE_NO , "[%s()] " fmt, __FUNCTION__, ## __VA_ARGS__); \
118 #define TS_ERROR(tag, fmt, ...) \
120 TS_DEBUG(tag, "[ERROR] " fmt, ## __VA_ARGS__); \
121 TSError("[%s] [%s:%d, %s()] " fmt, tag, __FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__); \
124 namespace atscppapi {
184 bool init(
const std::string &file,
bool add_timestamp =
true,
bool rename_file =
true,
240 void logDebug(
const char *fmt, ...) ATSCPPAPI_PRINTFLIKE(2,3);
247 void logInfo(const
char *fmt, ...) ATSCPPAPI_PRINTFLIKE(2,3);
254 void logError(const
char *fmt, ...) ATSCPPAPI_PRINTFLIKE(2,3);