53 static void Debug(
const char *format, ...) {
55 va_start(val, format);
56 Write(LogLevel::Debug,
"Debug", format, val);
59 static void Info(
const char *format, ...) {
61 va_start(val, format);
62 Write(LogLevel::Info,
"Info", format, val);
65 static void Warning(
const char *format, ...) {
67 va_start(val, format);
68 Write(LogLevel::Warning,
"Warning", format, val);
71 static void Fatal(
const char *format, ...) {
74 va_start(val, format);
76 vsprintf_s(str_buf, format, val);
78 vsprintf(str_buf, format, val);
81 fprintf(stderr,
"[LightGBM] [Fatal] %s\n", str_buf);
83 throw std::runtime_error(std::string(str_buf));
87 static void Write(LogLevel level,
const char* level_str,
const char *format, va_list val) {
88 if (level <= GetLevel()) {
90 printf(
"[LightGBM] [%s] ", level_str);
99 static LogLevel& GetLevel() {
static THREAD_LOCAL LogLevel level = LogLevel::Info;
return level; }