vsg: vsg::ThreadLogger Class Reference

vsg 1.1.13 VulkanSceneGraph library

Loading...
Searching...
No Matches
vsg::ThreadLogger Class Reference

`#include <Logger.h>`

Inheritance diagram for vsg::ThreadLogger:
[legend]
Collaboration diagram for vsg::ThreadLogger:
[legend]

## Public Member Functions
void | setThreadPrefix (std::thread::id id, const std::string &str)
| assign prefix for std::thread::id. The id can be obtained from std::thread::get_id() i.e. thread->get_id() or this_thread::get_id().
void | flush () override
Public Member Functions inherited from vsg::Inherit< vsg::Logger, ThreadLogger >
| Inherit (Args &&... args)
std::size_t | sizeofObject () const noexcept override
const char * | className () const noexcept override
const std::type_info & | type_info () const noexcept override
bool | is_compatible (const std::type_info &type) const noexcept override
int | compare (const Object &rhs) const override
void | accept (Visitor &visitor) override
Public Member Functions inherited from vsg::Logger
| Logger (const Logger &rhs)
virtual void | redirect_std ()
| redirect std::cout and std::cerr output to vsg::Logger at level LOGGER_INFO and LOGGER_ERROR respectively.
void | debug (char *message)
void | debug (const char *message)
void | debug (std::string &message)
void | debug (const std::string &message)
void | debug (const std::string_view &str)
template<typename... Args>
void | debug (Args &&... args)
void | info (char *message)
void | info (const char *message)
void | info (std::string &message)
void | info (const std::string &message)
void | info (const std::string_view &str)
template<typename... Args>
void | info (Args &&... args)
void | warn (char *message)
void | warn (const char *message)
void | warn (std::string &message)
void | warn (const std::string &message)
void | warn (const std::string_view &str)
template<typename... Args>
void | warn (Args &&... args)
void | error (char *message)
void | error (const char *message)
void | error (std::string &message)
void | error (const std::string &message)
void | error (const std::string_view &str)
template<typename... Args>
void | error (Args &&... args)
void | fatal (char *message)
void | fatal (const char *message)
void | fatal (std::string &message)
void | fatal (const std::string &message)
void | fatal (const std::string_view &str)
template<typename... Args>
void | fatal (Args &&... args)
void | debug_stream (PrintToStreamFunction print)
| thread safe access to stream for writing debug output.
void | info_stream (PrintToStreamFunction print)
| thread safe access to stream for writing info output.
void | warn_stream (PrintToStreamFunction print)
| thread safe access to stream for writing warn output.
void | error_stream (PrintToStreamFunction print)
| thread safe access to stream for writing error output.
void | fatal_stream (PrintToStreamFunction print)
| thread safe access to stream for writing fatal output and throwing vsg::Exception
void | log (Level msg_level, char *message)
| pass message to debug()/info()/warn()/error() based on specified level
void | log (Level msg_level, const char *message)
void | log (Level msg_level, std::string &message)
void | log (Level msg_level, const std::string &message)
void | log (Level msg_level, const std::string_view &message)
template<typename... Args>
void | log (Level msg_level, Args... args)
| pass message to debug()/info()/warn()/error() based on specified level
void | log_stream (Level msg_level, PrintToStreamFunction print)
| thread safe access to stream for writing error output.
Public Member Functions inherited from vsg::Object
| Object (const Object &object, const CopyOp &copyop={})
Object & | operator= (const Object &)
template<class T>
T * | cast ()
template<class T>
const T * | cast () const
virtual ref_ptr< Object > | clone (const CopyOp &copyop={}) const
virtual void | traverse (Visitor &)
virtual void | accept (ConstVisitor &visitor) const
virtual void | traverse (ConstVisitor &) const
virtual void | accept (RecordTraversal &visitor) const
virtual void | traverse (RecordTraversal &) const
virtual void | read (Input &input)
virtual void | write (Output &output) const
void | ref () const noexcept
void | unref () const noexcept
void | unref_nodelete () const noexcept
unsigned int | referenceCount () const noexcept
template<typename T>
void | setValue (const std::string &key, const T &value)
void | setValue (const std::string &key, const char *value)
| specialization of setValue to handle passing C strings
template<typename T>
bool | getValue (const std::string &key, T &value) const
| get specified value type, return false if value associated with key is not assigned or is not the correct type
void | setObject (const std::string &key, ref_ptr< Object > object)
| assign an Object associated with key
Object * | getObject (const std::string &key)
| get Object pointer associated with key, return nullptr if no object associated with key has been assigned
const Object * | getObject (const std::string &key) const
| get const Object pointer associated with key, return nullptr if no object associated with key has been assigned
template<class T>
T * | getObject (const std::string &key)
| get object pointer of specified type associated with key, return nullptr if no object associated with key has been assigned
template<class T>
const T * | getObject (const std::string &key) const
| get const object pointer of specified type associated with key, return nullptr if no object associated with key has been assigned
ref_ptr< Object > | getRefObject (const std::string &key)
| get ref_ptr<Object> associated with key, return nullptr if no object associated with key has been assigned
ref_ptr< const Object > | getRefObject (const std::string &key) const
| get ref_ptr<const Object> pointer associated with key, return nullptr if no object associated with key has been assigned
template<class T>
ref_ptr< T > | getRefObject (const std::string &key)
| get ref_ptr<T> of specified type associated with key, return nullptr if no object associated with key has been assigned
template<class T>
const ref_ptr< const T > | getRefObject (const std::string &key) const
| get ref_ptr<const T> of specified type associated with key, return nullptr if no object associated with key has been assigned
void | removeObject (const std::string &key)
| remove meta object or value associated with key
Auxiliary * | getOrCreateAuxiliary ()
Auxiliary * | getAuxiliary ()
const Auxiliary * | getAuxiliary () const

## Public Attributes
std::string | debugPrefix = "debug: "
std::string | infoPrefix = "info: "
std::string | warnPrefix = "Warning: "
std::string | errorPrefix = "ERROR: "
std::string | fatalPrefix = "FATAL: "
Public Attributes inherited from vsg::Logger
Level | level = LOGGER_INFO

## Protected Member Functions
void | print_id (FILE *out, std::thread::id id)
void | debug_implementation (const std::string_view &message) override
void | info_implementation (const std::string_view &message) override
void | warn_implementation (const std::string_view &message) override
void | error_implementation (const std::string_view &message) override
void | fatal_implementation (const std::string_view &message) override
Protected Member Functions inherited from vsg::Object
virtual void | _attemptDelete () const
void | setAuxiliary (Auxiliary *auxiliary)

## Protected Attributes
std::map< std::thread::id, std::string > | _threadPrefixes
Protected Attributes inherited from vsg::Logger
std::mutex | _mutex
std::ostringstream | _stream
std::unique_ptr< std::streambuf > | _override_cout
std::unique_ptr< std::streambuf > | _override_cerr
std::streambuf * | _original_cout = nullptr
std::streambuf * | _original_cerr = nullptr

## Additional Inherited Members
Public Types inherited from vsg::Logger
enum | Level { LOGGER_ALL = 0 , LOGGER_DEBUG = 1 , LOGGER_INFO = 2 , LOGGER_WARN = 3 , LOGGER_ERROR = 4 , LOGGER_FATAL = 5 , LOGGER_OFF = 6 }
using | PrintToStreamFunction = std::function<void(std::ostream&)>
Static Public Member Functions inherited from vsg::Inherit< vsg::Logger, ThreadLogger >
static ref_ptr< ThreadLogger > | create (Args &&... args)
static ref_ptr< ThreadLogger > | create_if (bool flag, Args &&... args)
Static Public Member Functions inherited from vsg::Logger
static ref_ptr< Logger > & | instance ()
| Logger singleton, defaults to using vsg::StdLogger.
Static Public Member Functions inherited from vsg::Object
static ref_ptr< Object > | create ()
static ref_ptr< Object > | create_if (bool flag)
static void * | operator new (std::size_t count)
| provide new and delete to enable custom memory management via the vsg::Allocator singleton, using the MEMORY_AFFINTY_OBJECTS
static void | operator delete (void *ptr)

## Detailed Description

Logger that prefixes message lines with user defined thread prefix, or std::thread::id when none is assigned. To use the ThreadLogger use: vsg::Logger::instance() = ThreadLogger::create();

## Member Function Documentation

## ◆ debug_implementation()

void vsg::ThreadLogger::debug_implementation | ( | const std::string_view & | message | ) |
| overrideprotectedvirtual

Implements vsg::Logger.

## ◆ error_implementation()

void vsg::ThreadLogger::error_implementation | ( | const std::string_view & | message | ) |
| overrideprotectedvirtual

Implements vsg::Logger.

## ◆ fatal_implementation()

void vsg::ThreadLogger::fatal_implementation | ( | const std::string_view & | message | ) |
| overrideprotectedvirtual

Implements vsg::Logger.

## ◆ flush()

void vsg::ThreadLogger::flush | ( |  | ) |
| overridevirtual

Reimplemented from vsg::Logger.

## ◆ info_implementation()

void vsg::ThreadLogger::info_implementation | ( | const std::string_view & | message | ) |
| overrideprotectedvirtual

Implements vsg::Logger.

## ◆ warn_implementation()

void vsg::ThreadLogger::warn_implementation | ( | const std::string_view & | message | ) |
| overrideprotectedvirtual

Implements vsg::Logger.

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

- include/vsg/io/Logger.h