MDL SDK API nvidia_logo_transpbg.gif Up
Logging

Logger interface and severity levels. More...

Namespaces

namespace  mi::base::details
 Namespace for details of the Base API.
 

Classes

struct  mi::base::Message_details
 Structured details to log messages. More...
 
class  mi::base::ILogger
 The ILogger interface class supports logging of messages. More...
 
class  mi::base::Log_stream
 Adapts mi::base::ILogger to a standard streaming interface. More...
 

Enumerations

enum  mi::base::details::Message_severity {
  mi::base::details::MESSAGE_SEVERITY_FATAL = 0 ,
  mi::base::details::MESSAGE_SEVERITY_ERROR = 1 ,
  mi::base::details::MESSAGE_SEVERITY_WARNING = 2 ,
  mi::base::details::MESSAGE_SEVERITY_INFO = 3 ,
  mi::base::details::MESSAGE_SEVERITY_VERBOSE = 4 ,
  mi::base::details::MESSAGE_SEVERITY_DEBUG = 5 ,
  MESSAGE_SEVERITY_FORCE_32_BIT = 0xffffffffU
}
 Constants for possible message severities. More...
 
enum  mi::base::details::Message_tag {
  mi::base::details::TAG_NONE = 0u ,
  mi::base::details::TAG_COMPATIBILITY = 1u << 0 ,
  mi::base::details::TAG_UNRECOVERABLE = 1u << 1 ,
  mi::base::details::TAG_API_INPUT = 1u << 2 ,
  mi::base::details::TAG_API_USAGE = 1u << 3 ,
  mi::base::details::TAG_VERSIONING = 1u << 4 ,
  mi::base::details::TAG_SYSTEM_RESOURCE = 1u << 5 ,
  mi::base::details::TAG_MEMORY = 1u << 6 ,
  mi::base::details::TAG_FILE = 1u << 7 ,
  mi::base::details::TAG_STATS = 1u << 8 ,
  mi::base::details::TAG_UNAVAILABLE = 1u << 9
}
 Tags which help categorize log messages. More...
 

Functions

bool mi::base::Message_details::is_device () const
 Checks if this event pertains to a CUDA device or the CPU. More...
 
bool mi::base::Message_details::is_tagged (const Uint32 required_tags) const
 Checks if all required_tags are present. More...
 
Message_detailsmi::base::Message_details::host (const Uint32 id)
 Named constructor. More...
 
Message_detailsmi::base::Message_details::device (const Sint32 id)
 Named constructor. More...
 
Message_detailsmi::base::Message_details::tag (const Uint32 t)
 Named constructor. More...
 
Message_detailsmi::base::Message_details::tag (const Uint32 t, const Uint32 code)
 Named constructor. More...
 
Message_detailsmi::base::Message_details::code (const Uint32 c)
 Named constructor. More...
 
virtual void mi::base::ILogger::message (Message_severity level, const char *module_category, const char *message)
 Emits a message to the application's log. More...
 
virtual void mi::base::ILogger::message (Message_severity level, const char *module_category, const Message_details &, const char *message)=0
 Emits a message to the application's log. More...
 
void mi::base::ILogger::printf (Message_severity level, const char *module_category, const char *message,...) __attribute__((format(printf
 Emits a message to the application's log. More...
 
void mi::base::ILogger::printf (Message_severity level, const char *module_category, const Message_details &details, const char *message,...) __attribute__((format(printf
 Emits a message to the application's log. More...
 
 mi::base::Log_stream::Log_stream (ILogger *logger, const char *module_category, Message_severity default_level=MESSAGE_SEVERITY_INFO, const Message_details &default_details=Message_details())
 Constructor. More...
 
 mi::base::Log_stream::Log_stream (ILogger *logger, const std::string &module_category, Message_severity default_level=MESSAGE_SEVERITY_INFO, const Message_details &default_details=Message_details())
 Constructor. More...
 
 mi::base::Log_stream::~Log_stream () throw ()
 Destructor. More...
 
void mi::base::Log_stream::set_log_level (Message_severity level)
 Flushes the buffer if not empty, and sets the log level of the next message to the given log level. More...
 
void mi::base::Log_stream::set_details (const Message_details &details)
 Flushes the buffer if not empty, and sets the message details of the next message. More...
 
template<typename C , typename T>
std::basic_ostream<C, T> & mi::base::fatal (std::basic_ostream<C, T> &ostream)
 Manipulator for mi::base::Log_stream. More...
 
template<typename C , typename T>
std::basic_ostream<C, T> & mi::base::error (std::basic_ostream<C, T> &ostream)
 Manipulator for mi::base::Log_stream. More...
 
template<typename C , typename T>
std::basic_ostream<C, T> & mi::base::warning (std::basic_ostream<C, T> &ostream)
 Manipulator for mi::base::Log_stream. More...
 
template<typename C , typename T>
std::basic_ostream<C, T> & mi::base::info (std::basic_ostream<C, T> &ostream)
 Manipulator for mi::base::Log_stream. More...
 
template<typename C , typename T>
std::basic_ostream<C, T> & mi::base::verbose (std::basic_ostream<C, T> &ostream)
 Manipulator for mi::base::Log_stream. More...
 
template<typename C , typename T>
std::basic_ostream<C, T> & mi::base::debug (std::basic_ostream<C, T> &ostream)
 Manipulator for mi::base::Log_stream. More...
 
template<typename C , typename T>
std::basic_ostream<C, T> & mi::base::operator<< (std::basic_ostream<C, T> &ostream, const Message_details &md)
 Manipulator for mi::base::Log_stream. More...
 

Variables

Uint32 mi::base::Message_details::host_id
 The cluster ID of the host on which the message originated. More...
 
Sint32 mi::base::Message_details::device_id
 DEVICE_ID_XXX or a CUDA device ID. More...
 
Uint32 mi::base::Message_details::tags
 A set of tags. More...
 
Uint32 mi::base::Message_details::message_id
 An additional message identifier. More...
 

Detailed Description

Logger interface and severity levels.

Include File:
#include <mi/base/ilogger.h>

Enumeration Type Documentation

 Message_severity

Constants for possible message severities.

See also
mi::base::ILogger::message()
Enumerator
MESSAGE_SEVERITY_FATAL 

A fatal error has occurred.

MESSAGE_SEVERITY_ERROR 

An error has occurred.

MESSAGE_SEVERITY_WARNING 

A warning has occurred.

MESSAGE_SEVERITY_INFO 

This is a normal operational message.

MESSAGE_SEVERITY_VERBOSE 

This is a more verbose message.

MESSAGE_SEVERITY_DEBUG 

This is debug message.

 Message_tag

Tags which help categorize log messages.

Enumerator
TAG_NONE 

no tags

TAG_COMPATIBILITY 

hardware or library compatibility

TAG_UNRECOVERABLE 

unrecoverable issue, e.g. fatal CUDA errors

TAG_API_INPUT 

e.g. invalid value

TAG_API_USAGE 

e.g. wrong order of operations

TAG_VERSIONING 

e.g. library version info, mismatch

TAG_SYSTEM_RESOURCE 

non-memory, e.g. device assignment, disk space, ...

TAG_MEMORY 

memory resource

TAG_FILE 

File not found, etc.

TAG_STATS 

e.g. timing, memory usage

TAG_UNAVAILABLE 

device or resource not available; possibly temporary

Function Documentation

 code()

Message_details & mi::base::Message_details::code ( const Uint32  c)
inline

Named constructor.

 debug()

template<typename C , typename T>
std::basic_ostream<C, T> & mi::base::debug ( std::basic_ostream<C, T> &  ostream)

Manipulator for mi::base::Log_stream.

Flushes the buffer if not empty, and sets the log level of the next message to mi::base::details::MESSAGE_SEVERITY_DEBUG.

Note
If you are using a C++ standard older than C++14, make sure to use the manipulator only if the stream is an instance of mi::base::Log_stream, otherwise your program will crash. With C++14 and later, these manipulators will be ignored if the stream is not an instance of mi::base::Log_stream.

 device()

Message_details & mi::base::Message_details::device ( const Sint32  id)
inline

Named constructor.

 error()

template<typename C , typename T>
std::basic_ostream<C, T> & mi::base::error ( std::basic_ostream<C, T> &  ostream)

Manipulator for mi::base::Log_stream.

Flushes the buffer if not empty, and sets the log level of the next message to mi::base::details::MESSAGE_SEVERITY_ERROR.

Note
If you are using a C++ standard older than C++14, make sure to use the manipulator only if the stream is an instance of mi::base::Log_stream, otherwise your program will crash. With C++14 and later, these manipulators will be ignored if the stream is not an instance of mi::base::Log_stream.

 fatal()

template<typename C , typename T>
std::basic_ostream<C, T> & mi::base::fatal ( std::basic_ostream<C, T> &  ostream)

Manipulator for mi::base::Log_stream.

Flushes the buffer if not empty, and sets the log level of the next message to mi::base::details::MESSAGE_SEVERITY_FATAL.

Note
If you are using a C++ standard older than C++14, make sure to use the manipulator only if the stream is an instance of mi::base::Log_stream, otherwise your program will crash. With C++14 and later, these manipulators will be ignored if the stream is not an instance of mi::base::Log_stream.

 host()

Message_details & mi::base::Message_details::host ( const Uint32  id)
inline

Named constructor.

 info()

template<typename C , typename T>
std::basic_ostream<C, T> & mi::base::info ( std::basic_ostream<C, T> &  ostream)

Manipulator for mi::base::Log_stream.

Flushes the buffer if not empty, and sets the log level of the next message to mi::base::details::MESSAGE_SEVERITY_INFO.

Note
If you are using a C++ standard older than C++14, make sure to use the manipulator only if the stream is an instance of mi::base::Log_stream, otherwise your program will crash. With C++14 and later, these manipulators will be ignored if the stream is not an instance of mi::base::Log_stream.

 is_device()

bool mi::base::Message_details::is_device ( ) const
inline

Checks if this event pertains to a CUDA device or the CPU.

 is_tagged()

bool mi::base::Message_details::is_tagged ( const Uint32  required_tags) const
inline

Checks if all required_tags are present.

 Log_stream() [1/2]

mi::base::Log_stream::Log_stream ( ILogger logger,
const char *  module_category,
Message_severity  default_level = MESSAGE_SEVERITY_INFO,
const Message_details default_details = Message_details() 
)
inline

Constructor.

Parameters
loggerThe logger object used by this stream.
module_categoryThe module and the category which specify the origin and the functional area of this message. See mi::base::ILogger::message() for details.
default_levelThe default log level. Used if no other log level is selected by one of the manipulators.
default_detailsThe default message details.

 Log_stream() [2/2]

mi::base::Log_stream::Log_stream ( ILogger logger,
const std::string &  module_category,
Message_severity  default_level = MESSAGE_SEVERITY_INFO,
const Message_details default_details = Message_details() 
)
inline

Constructor.

Parameters
loggerThe logger object used by this stream.
module_categoryThe module and the category which specify the origin and the functional area of this message. See mi::base::ILogger::message() for details.
default_levelThe default log level. Used if no other log level is selected by one of the manipulators.
default_detailsThe default message details.

 message() [1/2]

virtual void mi::base::ILogger::message ( Message_severity  level,
const char *  module_category,
const char *  message 
)
inlinevirtual

Emits a message to the application's log.

The application can decide to output the message to any channel or to drop it.

This function can be called at any time from any thread, including concurrent calls from several threads at the same time.

Note
Severity mi::base::details::MESSAGE_SEVERITY_FATAL indicates that the caller is unable to recover from the error condition. Therefore, the process will be terminated after a fatal log message has been delivered. To avoid the process termination logger implementations might choose not to return from this method for fatal log messages. This severity should only be used in exceptional cases.
Parameters
levelThe log level which specifies the severity of the message.
module_categoryThe module and the category which specify the origin and the functional area of this message. The format of string parameter is "module:category". Both names are optional. The module name must not contain any colons. See above for valid category names.
messageThe log message.

 message() [2/2]

virtual void mi::base::ILogger::message ( Message_severity  level,
const char *  module_category,
const Message_details ,
const char *  message 
)
pure virtual

Emits a message to the application's log.

This overload receives additional details which applications may use to react to certain events.

 operator<<()

template<typename C , typename T>
std::basic_ostream<C, T> & mi::base::operator<< ( std::basic_ostream<C, T> &  ostream,
const Message_details md 
)

Manipulator for mi::base::Log_stream.

Flushes the buffer if not empty, and sets the log details of the next message.

Note
If you are using a C++ standard older than C++14, make sure to use the manipulator only if the stream is an instance of mi::base::Log_stream, otherwise your program will crash. With C++14 and later, these manipulators will be ignored if the stream is not an instance of mi::base::Log_stream.

 printf() [1/2]

void mi::base::ILogger::printf ( Message_severity  level,
const char *  module_category,
const char *  message,
  ... 
)
inline

Emits a message to the application's log.

The application can decide to output the message to any channel or to drop it.

This function can be called at any time from any thread, including concurrent calls from several threads at the same time.

Note
Severity mi::base::details::MESSAGE_SEVERITY_FATAL indicates that the caller is unable to recover from the error condition. Therefore, the process will be terminated after a fatal log message has been delivered. To avoid the process termination logger implementations might choose not to return from this method for fatal log messages. This severity should only be used in exceptional cases.
Parameters
levelThe log level which specifies the severity of the message.
module_categoryThe module and the category which specify the origin and the functional area of this message. The format of string parameter is "module:category". Both names are optional. The module name must not contain any colons. See above for valid category names.
messageThe log message using printf()-like format specifiers, followed by matching arguments. The formatted message is limited to 1023 characters.

 printf() [2/2]

void mi::base::ILogger::printf ( Message_severity  level,
const char *  module_category,
const Message_details details,
const char *  message,
  ... 
)
inline

Emits a message to the application's log.

This overload receives additional details which applications may use to react to certain events.

 set_details()

void mi::base::Log_stream::set_details ( const Message_details details)
inline

Flushes the buffer if not empty, and sets the message details of the next message.

 set_log_level()

void mi::base::Log_stream::set_log_level ( Message_severity  level)
inline

Flushes the buffer if not empty, and sets the log level of the next message to the given log level.

 tag() [1/2]

Message_details & mi::base::Message_details::tag ( const Uint32  t)
inline

Named constructor.

 tag() [2/2]

Message_details & mi::base::Message_details::tag ( const Uint32  t,
const Uint32  code 
)
inline

Named constructor.

 verbose()

template<typename C , typename T>
std::basic_ostream<C, T> & mi::base::verbose ( std::basic_ostream<C, T> &  ostream)

Manipulator for mi::base::Log_stream.

Flushes the buffer if not empty, and sets the log level of the next message to mi::base::details::MESSAGE_SEVERITY_VERBOSE.

Note
If you are using a C++ standard older than C++14, make sure to use the manipulator only if the stream is an instance of mi::base::Log_stream, otherwise your program will crash. With C++14 and later, these manipulators will be ignored if the stream is not an instance of mi::base::Log_stream.

 warning()

template<typename C , typename T>
std::basic_ostream<C, T> & mi::base::warning ( std::basic_ostream<C, T> &  ostream)

Manipulator for mi::base::Log_stream.

Flushes the buffer if not empty, and sets the log level of the next message to mi::base::details::MESSAGE_SEVERITY_WARNING.

Note
If you are using a C++ standard older than C++14, make sure to use the manipulator only if the stream is an instance of mi::base::Log_stream, otherwise your program will crash. With C++14 and later, these manipulators will be ignored if the stream is not an instance of mi::base::Log_stream.

 ~Log_stream()

mi::base::Log_stream::~Log_stream ( )
throw (
)
inline

Destructor.

Flushes the buffer.

Variable Documentation

 device_id

Sint32 mi::base::Message_details::device_id

DEVICE_ID_XXX or a CUDA device ID.

 host_id

Uint32 mi::base::Message_details::host_id

The cluster ID of the host on which the message originated.

Callers will not need to set this field; it is populated automatically by the logging module. Note that a value of HOST_ID_LOCAL may be replaced by the host's ID.

 message_id

Uint32 mi::base::Message_details::message_id

An additional message identifier.

 tags

Uint32 mi::base::Message_details::tags

A set of tags.

See also
Message_tag.