30 template <
class Mutex>
50 std::string
format(
const char* fmt, va_list& vl);
51 std::string
format(
const char* fmt, ...);
100 void setCallback(
void (*callback)(
int lvl,
const char* msg));
136 void log(
int level,
const char* fmt, ...);
147 std::shared_ptr<spdlog::sinks::callback_sink_mt> sink;
148 std::shared_ptr<spdlog::logger> logger;
149 std::string currPattern;
150 static const std::string DefaultPattern;
178 std::string prevPattern;
185 #if (CUML_ACTIVE_LEVEL >= CUML_LEVEL_TRACE)
186 #define CUML_LOG_TRACE(fmt, ...) \
188 std::stringstream ss; \
189 ss << ML::format("%s:%d ", __FILE__, __LINE__); \
190 ss << ML::format(fmt, ##__VA_ARGS__); \
191 ML::Logger::get().log(CUML_LEVEL_TRACE, ss.str().c_str()); \
194 #define CUML_LOG_TRACE(fmt, ...) void(0)
197 #if (CUML_ACTIVE_LEVEL >= CUML_LEVEL_DEBUG)
198 #define CUML_LOG_DEBUG(fmt, ...) \
200 std::stringstream ss; \
201 ss << ML::format("%s:%d ", __FILE__, __LINE__); \
202 ss << ML::format(fmt, ##__VA_ARGS__); \
203 ML::Logger::get().log(CUML_LEVEL_DEBUG, ss.str().c_str()); \
206 #define CUML_LOG_DEBUG(fmt, ...) void(0)
209 #if (CUML_ACTIVE_LEVEL >= CUML_LEVEL_INFO)
210 #define CUML_LOG_INFO(fmt, ...) ML::Logger::get().log(CUML_LEVEL_INFO, fmt, ##__VA_ARGS__)
212 #define CUML_LOG_INFO(fmt, ...) void(0)
215 #if (CUML_ACTIVE_LEVEL >= CUML_LEVEL_WARN)
216 #define CUML_LOG_WARN(fmt, ...) ML::Logger::get().log(CUML_LEVEL_WARN, fmt, ##__VA_ARGS__)
218 #define CUML_LOG_WARN(fmt, ...) void(0)
221 #if (CUML_ACTIVE_LEVEL >= CUML_LEVEL_ERROR)
222 #define CUML_LOG_ERROR(fmt, ...) ML::Logger::get().log(CUML_LEVEL_ERROR, fmt, ##__VA_ARGS__)
224 #define CUML_LOG_ERROR(fmt, ...) void(0)
227 #if (CUML_ACTIVE_LEVEL >= CUML_LEVEL_CRITICAL)
228 #define CUML_LOG_CRITICAL(fmt, ...) ML::Logger::get().log(CUML_LEVEL_CRITICAL, fmt, ##__VA_ARGS__)
230 #define CUML_LOG_CRITICAL(fmt, ...) void(0)
The main Logging class for cuML library.
Definition: logger.hpp:64
bool shouldLogFor(int level) const
Tells whether messages will be logged for the given log level.
Definition: logger.cpp:83
void setLevel(int level)
Set the logging level.
Definition: logger.cpp:67
static Logger & get()
Singleton method to get the underlying logger object.
Definition: logger.cpp:52
void setCallback(void(*callback)(int lvl, const char *msg))
Register a callback function to be run in place of usual log call.
Definition: logger.cpp:79
void setFlush(void(*flush)())
Register a flush function compatible with the registered callback.
Definition: logger.cpp:81
void log(int level, const char *fmt,...)
Main logging method.
Definition: logger.cpp:96
int getLevel() const
Query for the current log level.
Definition: logger.cpp:90
void setPattern(const std::string &pattern)
Set the logging pattern.
Definition: logger.cpp:73
std::string getPattern() const
Get the current logging pattern.
Definition: logger.hpp:128
void flush()
Flush logs by calling flush on underlying logger.
Definition: logger.cpp:110
RAII based pattern setter for Logger class.
Definition: logger.hpp:163
PatternSetter(const std::string &pattern="%v")
Set the pattern for the rest of the log messages.
Definition: logger.cpp:112
~PatternSetter()
This will restore the previous pattern that was active during the moment this object was created.
Definition: logger.cpp:118
Definition: dbscan.hpp:30
CallbackSink< std::mutex > callback_sink_mt
Definition: callbackSink.hpp:69
Definition: callbackSink.hpp:26