Treelite
Classes | Macros | Typedefs | Functions
logging.h File Reference

logging facility for Treelite More...

#include <treelite/thread_local.h>
#include <iostream>
#include <stdexcept>
#include <string>
#include <sstream>
#include <memory>
#include <cstdio>
#include <ctime>
Include dependency graph for logging.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Error
 Exception class that will be thrown by Treelite. More...
 
class  DateLogger
 
class  LogMessageFatal
 
class  LogMessage
 
class  LogCallbackRegistry
 

Macros

#define TREELITE_ALWAYS_INLINE   inline
 
#define DEFINE_CHECK_FUNC(name, op)
 
#define TREELITE_CHECK_BINARY_OP(name, op, x, y)
 
#define TREELITE_CHECK(x)
 
#define TREELITE_CHECK_LT(x, y)   TREELITE_CHECK_BINARY_OP(_LT, <, x, y)
 
#define TREELITE_CHECK_GT(x, y)   TREELITE_CHECK_BINARY_OP(_GT, >, x, y)
 
#define TREELITE_CHECK_LE(x, y)   TREELITE_CHECK_BINARY_OP(_LE, <=, x, y)
 
#define TREELITE_CHECK_GE(x, y)   TREELITE_CHECK_BINARY_OP(_GE, >=, x, y)
 
#define TREELITE_CHECK_EQ(x, y)   TREELITE_CHECK_BINARY_OP(_EQ, ==, x, y)
 
#define TREELITE_CHECK_NE(x, y)   TREELITE_CHECK_BINARY_OP(_NE, !=, x, y)
 
#define TREELITE_LOG_INFO   ::treelite::LogMessage(__FILE__, __LINE__)
 
#define TREELITE_LOG_ERROR   TREELITE_LOG_INFO
 
#define TREELITE_LOG_FATAL   ::treelite::LogMessageFatal(__FILE__, __LINE__)
 
#define TREELITE_LOG(severity)   TREELITE_LOG_##severity.stream()
 

Typedefs

using LogCallbackRegistryStore = ThreadLocalStore< LogCallbackRegistry >
 

Functions

template<typename X , typename Y >
std::unique_ptr< std::string > LogCheckFormat (const X &x, const Y &y)
 

Detailed Description

logging facility for Treelite

Copyright (c) 2017-2021 by Contributors

Author
Hyunsu Cho

Definition in file logging.h.

Macro Definition Documentation

◆ DEFINE_CHECK_FUNC

#define DEFINE_CHECK_FUNC (   name,
  op 
)
Value:
template <typename X, typename Y> \
TREELITE_ALWAYS_INLINE std::unique_ptr<std::string> LogCheck##name(const X& x, const Y& y) { \
if (x op y) return nullptr; \
return LogCheckFormat(x, y); \
} \
TREELITE_ALWAYS_INLINE std::unique_ptr<std::string> LogCheck##name(int x, int y) { \
return LogCheck##name<int, int>(x, y); \
}

Definition at line 44 of file logging.h.

◆ TREELITE_CHECK

#define TREELITE_CHECK (   x)
Value:
if (!(x)) \
::treelite::LogMessageFatal(__FILE__, __LINE__).stream() \
<< "Check failed: " #x << ": "

Definition at line 69 of file logging.h.

◆ TREELITE_CHECK_BINARY_OP

#define TREELITE_CHECK_BINARY_OP (   name,
  op,
  x,
 
)
Value:
if (auto __treelite__log__err = ::treelite::LogCheck##name(x, y)) \
::treelite::LogMessageFatal(__FILE__, __LINE__).stream() \
<< "Check failed: " << #x " " #op " " #y << *__treelite__log__err << ": "

Definition at line 65 of file logging.h.