Assimp v5.2.2 (January 2022)
The Asset-Importer-Lib API documentation.
Assimp::DefaultLogger Class Reference

CPP-API: Primary logging facility of Assimp. More...

#include <DefaultLogger.hpp>

Inherits Assimp::Logger.

Public Member Functions

bool attachStream (LogStream *pStream, unsigned int severity) override
 Attach a new log-stream.
More...
 
bool detachStream (LogStream *pStream, unsigned int severity) override
 Detach a still attached stream from the logger (or modify the filter flags bits) More...
 
- Public Member Functions inherited from Assimp::Logger
virtual bool attachStream (LogStream *pStream, unsigned int severity=Debugging|Err|Warn|Info)=0
 Attach a new log-stream. More...
 
void debug (const char *message)
 Writes a debug message. More...
 
template<typename... T>
void debug (T &&... args)
 
virtual bool detachStream (LogStream *pStream, unsigned int severity=Debugging|Err|Warn|Info)=0
 Detach a still attached stream from the logger (or modify the filter flags bits) More...
 
void error (const char *message)
 Writes an error message. More...
 
template<typename... T>
void error (T &&... args)
 
LogSeverity getLogSeverity () const
 Get the current log severity. More...
 
void info (const char *message)
 Writes a info message. More...
 
template<typename... T>
void info (T &&... args)
 
void setLogSeverity (LogSeverity log_severity)
 Set a new log severity. More...
 
void verboseDebug (const char *message)
 Writes a debug message. More...
 
template<typename... T>
void verboseDebug (T &&... args)
 
void warn (const char *message)
 Writes a warning message. More...
 
template<typename... T>
void warn (T &&... args)
 
virtual ~Logger ()
 Virtual destructor. More...
 

Static Public Member Functions

static Loggercreate (const char *name=ASSIMP_DEFAULT_LOG_NAME, LogSeverity severity=NORMAL, unsigned int defStreams=aiDefaultLogStream_DEBUGGER|aiDefaultLogStream_FILE, IOSystem *io=nullptr)
 Creates a logging instance. More...
 
static Loggerget ()
 Getter for singleton instance. More...
 
static bool isNullLogger ()
 Return whether a #NullLogger is currently active. More...
 
static void kill ()
 Kills the current singleton logger and replaces it with a #NullLogger instance. More...
 
static void set (Logger *logger)
 Setup a custom Logger implementation. More...
 

Additional Inherited Members

- Public Types inherited from Assimp::Logger
enum  ErrorSeverity { Debugging = 1 , Info = 2 , Warn = 4 , Err = 8 }
 Description for severity of a log message. More...
 
enum  LogSeverity { NORMAL , DEBUGGING , VERBOSE }
 Log severity to describe the granularity of logging. More...
 
- Protected Member Functions inherited from Assimp::Logger
std::string formatMessage (Assimp::Formatter::format f)
 
template<typename... T, typename U >
std::string formatMessage (Assimp::Formatter::format f, U &&u, T &&... args)
 
 Logger () AI_NO_EXCEPT
 Default constructor. More...
 
 Logger (LogSeverity severity)
 Construction with a given log severity. More...
 
virtual void OnDebug (const char *message)=0
 Called as a request to write a specific debug message. More...
 
virtual void OnError (const char *message)=0
 Called as a request to write a specific error message. More...
 
virtual void OnInfo (const char *message)=0
 Called as a request to write a specific info message. More...
 
virtual void OnVerboseDebug (const char *message)=0
 Called as a request to write a specific verbose debug message. More...
 
virtual void OnWarn (const char *essage)=0
 Called as a request to write a specific warn message. More...
 
- Protected Attributes inherited from Assimp::Logger
LogSeverity m_Severity
 

Detailed Description

CPP-API: Primary logging facility of Assimp.

The library stores its primary Logger as a static member of this class. get() returns this primary logger. By default the underlying implementation is just a #NullLogger which rejects all log messages. By calling create(), logging is turned on. To capture the log output multiple log streams (#LogStream) can be attach to the logger. Some default streams for common streaming locations (such as a file, std::cout, OutputDebugString()) are also provided.

If you wish to customize the logging at an even deeper level supply your own implementation of Logger to set().

Note
The whole logging stuff causes a small extra overhead for all imports.

Member Function Documentation

◆ attachStream()

bool Assimp::DefaultLogger::attachStream ( LogStream pStream,
unsigned int  severity 
)
overridevirtual

Attach a new log-stream.

The logger takes ownership of the stream and is responsible for its destruction (which is done using ::delete when the logger itself is destroyed). Call detachStream to detach a stream and to gain ownership of it again.

Parameters
pStreamLog-stream to attach
severityMessage filter, specified which types of log messages are dispatched to the stream. Provide a bitwise combination of the ErrorSeverity flags.
Returns
true if the stream has been attached, false otherwise.

Implements Assimp::Logger.

◆ create()

static Logger * Assimp::DefaultLogger::create ( const char *  name = ASSIMP_DEFAULT_LOG_NAME,
LogSeverity  severity = NORMAL,
unsigned int  defStreams = aiDefaultLogStream_DEBUGGER|aiDefaultLogStream_FILE,
IOSystem io = nullptr 
)
static

Creates a logging instance.

Parameters
nameName for log file. Only valid in combination with the aiDefaultLogStream_FILE flag.
severityLog severity, DEBUG turns on debug messages and VERBOSE turns on all messages.
defStreamsDefault log streams to be attached. Any bitwise combination of the aiDefaultLogStream enumerated values. If aiDefaultLogStream_FILE is specified but an empty string is passed for 'name', no log file is created at all.
ioIOSystem to be used to open external files (such as the log file). Pass nullptr to rely on the default implementation. This replaces the default #NullLogger with a #DefaultLogger instance.

◆ detachStream()

bool Assimp::DefaultLogger::detachStream ( LogStream pStream,
unsigned int  severity 
)
overridevirtual

Detach a still attached stream from the logger (or modify the filter flags bits)

Parameters
pStreamLog-stream instance for detaching
severityProvide a bitwise combination of the ErrorSeverity flags. This value is &~ed with the current flags of the stream, if the result is 0 the stream is detached from the Logger and the caller retakes the possession of the stream.
Returns
true if the stream has been detached, false otherwise.

Implements Assimp::Logger.

◆ get()

static Logger * Assimp::DefaultLogger::get ( )
static

Getter for singleton instance.

Returns
Only instance. This is never null, but it could be a NullLogger. Use isNullLogger to check this.

◆ isNullLogger()

static bool Assimp::DefaultLogger::isNullLogger ( )
static

Return whether a #NullLogger is currently active.

Returns
true if the current logger is a #NullLogger. Use create() or set() to setup a logger that does actually do something else than just rejecting all log messages.

◆ kill()

static void Assimp::DefaultLogger::kill ( )
static

Kills the current singleton logger and replaces it with a #NullLogger instance.

◆ set()

static void Assimp::DefaultLogger::set ( Logger logger)
static

Setup a custom Logger implementation.

Use this if the provided #DefaultLogger class doesn't fit into your needs. If the provided message formatting is OK for you, it's much easier to use create() and to attach your own custom output streams to it.

Parameters
loggerPass NULL to setup a default NullLogger

The documentation for this class was generated from the following file: