Medial Code Documentation
Loading...
Searching...
No Matches
Data Structures | Namespaces | Macros | Functions
logging.h File Reference

defines logging macros of dmlc allows use of GLOG, fall back to internal implementation when disabled More...

#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <stdexcept>
#include <memory>
#include "./base.h"
#include <assert.h>
#include <iostream>
#include <sstream>
#include <ctime>

Go to the source code of this file.

Data Structures

struct  dmlc::Error
 exception class that will be thrown by default logger if DMLC_LOG_FATAL_THROW == 1 More...
 
class  dmlc::DateLogger
 
class  dmlc::LogMessage
 
class  dmlc::CustomLogMessage
 
class  dmlc::LogMessageFatal
 
class  dmlc::LogMessageVoidify
 

Namespaces

namespace  dmlc
 namespace for dmlc
 

Macros

#define DEFINE_CHECK_FUNC(name, op)
 
#define CHECK_BINARY_OP(name, op, x, y)
 
#define CHECK(x)
 
#define CHECK_LT(x, y)   CHECK_BINARY_OP(_LT, <, x, y)
 
#define CHECK_GT(x, y)   CHECK_BINARY_OP(_GT, >, x, y)
 
#define CHECK_LE(x, y)   CHECK_BINARY_OP(_LE, <=, x, y)
 
#define CHECK_GE(x, y)   CHECK_BINARY_OP(_GE, >=, x, y)
 
#define CHECK_EQ(x, y)   CHECK_BINARY_OP(_EQ, ==, x, y)
 
#define CHECK_NE(x, y)   CHECK_BINARY_OP(_NE, !=, x, y)
 
#define CHECK_NOTNULL(x)    ((x) == NULL ? dmlc::LogMessageFatal(__FILE__, __LINE__).stream() << "Check notnull: " #x << ' ', (x) : (x))
 
#define DCHECK(x)    while (false) CHECK(x)
 
#define DCHECK_LT(x, y)    while (false) CHECK((x) < (y))
 
#define DCHECK_GT(x, y)    while (false) CHECK((x) > (y))
 
#define DCHECK_LE(x, y)    while (false) CHECK((x) <= (y))
 
#define DCHECK_GE(x, y)    while (false) CHECK((x) >= (y))
 
#define DCHECK_EQ(x, y)    while (false) CHECK((x) == (y))
 
#define DCHECK_NE(x, y)    while (false) CHECK((x) != (y))
 
#define LOG_INFO   dmlc::LogMessage(__FILE__, __LINE__)
 
#define LOG_ERROR   LOG_INFO
 
#define LOG_WARNING   LOG_INFO
 
#define LOG_FATAL   dmlc::LogMessageFatal(__FILE__, __LINE__)
 
#define LOG_QFATAL   LOG_FATAL
 
#define VLOG(x)   LOG_INFO.stream()
 
#define LOG(severity)   LOG_##severity.stream()
 
#define LG   LOG_INFO.stream()
 
#define LOG_IF(severity, condition)    !(condition) ? (void)0 : dmlc::LogMessageVoidify() & LOG(severity)
 
#define LOG_DFATAL   LOG_FATAL
 
#define DFATAL   FATAL
 
#define DLOG(severity)   LOG_IF(severity, ::dmlc::DebugLoggingEnabled())
 
#define DLOG_IF(severity, condition)   LOG_IF(severity, ::dmlc::DebugLoggingEnabled() && (condition))
 
#define LOG_EVERY_N(severity, n)   LOG(severity)
 

Functions

size_t dmlc::LogStackTraceLevel ()
 
std::string dmlc::demangle (char const *msg_str)
 
std::string dmlc::StackTrace (size_t start_frame=1, const size_t stack_size=0)
 
void dmlc::InitLogging (const char *)
 
bool dmlc::DebugLoggingEnabled ()
 
template<typename X , typename Y >
std::unique_ptr< std::string > dmlc::LogCheckFormat (const X &x, const Y &y)
 

Detailed Description

defines logging macros of dmlc allows use of GLOG, fall back to internal implementation when disabled

Copyright (c) 2015 by Contributors

Macro Definition Documentation

◆ CHECK

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

◆ CHECK_BINARY_OP

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

◆ DEFINE_CHECK_FUNC

#define DEFINE_CHECK_FUNC (   name,
  op 
)
Value:
template <typename X, typename Y> \
DMLC_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); \
} \
DMLC_ALWAYS_INLINE std::unique_ptr<std::string> LogCheck##name(int x, int y) { \
return LogCheck##name<int, int>(x, y); \
}