OpenVDB 14.0.0
Loading...
Searching...
No Matches
Sink Class Referenceabstract

Receives formatted log messages. Subclass this to route OpenVDB diagnostics into a host application. More...

#include <openvdb/util/logging.h>

Public Types

using Ptr = std::shared_ptr<Sink>

Public Member Functions

 Sink (const std::string &name, Level threshold=Level::Debug)
virtual ~Sink ()
const std::string & name () const
Level threshold () const
void setThreshold (Level)
virtual void append (Level level, const std::string &message, const char *file, int line)=0

Detailed Description

Receives formatted log messages. Subclass this to route OpenVDB diagnostics into a host application.

Sinks are called on the thread that logged the message, so an implementation must be thread safe. A sink must not throw.

Example
class MySink: public openvdb::logging::Sink
{
public:
MySink(): Sink("mysink") {}
void append(openvdb::logging::Level level, const std::string& message,
const char* file, int line) override
{
// forward to the host application's own logging system
}
};
openvdb::logging::addSink(std::make_shared<MySink>());
Sink(const std::string &name, Level threshold=Level::Debug)

Member Typedef Documentation

◆ Ptr

using Ptr = std::shared_ptr<Sink>

Constructor & Destructor Documentation

◆ Sink()

Sink ( const std::string & name,
Level threshold = Level::Debug )
explicit
Parameters
nameUnique identifier, used by removeSink() and findSink().
thresholdMessages below this level are not delivered to this sink, in addition to the global threshold from setLevel().

◆ ~Sink()

virtual ~Sink ( )
virtual

Member Function Documentation

◆ append()

virtual void append ( Level level,
const std::string & message,
const char * file,
int line )
pure virtual
Parameters
levelSeverity of the message.
messageThe formatted message text, without a trailing newline.
fileSource file the message was logged from, may be null.
lineLine in file, or 0 if unknown.

Implemented in ConsoleSink.

◆ name()

const std::string & name ( ) const

◆ setThreshold()

void setThreshold ( Level )

◆ threshold()

Level threshold ( ) const