OSVR-Core
Classes | Public Member Functions | Static Public Member Functions | List of all members
osvr::util::log::Logger Class Reference

An object allowing you to log messages with a given log source name. More...

#include <Logger.h>

Classes

class  StreamProxy
 An object returned the logging functions (including operator<<), serves to accumulate streamed output in a single ostringstream then write it to the logger at the end of the expression's lifetime. More...
 

Public Member Functions

 Logger (std::string const &name, std::shared_ptr< spdlog::logger > logger, PrivateConstructor *)
 Internal-use constructor - please used a factory/named constructor. More...
 
 Logger (const Logger &)=delete
 Non-copyable.
 
Loggeroperator= (const Logger &)=delete
 Non-copy-assignable.
 
OSVR_UTIL_EXPORT ~Logger ()
 Destructor.
 
OSVR_UTIL_EXPORT LogLevel getLogLevel () const
 Get the minimum level at which this logger will actually forward messages on to the sinks. More...
 
OSVR_UTIL_EXPORT void setLogLevel (LogLevel level)
 Set the minimum level at which this logger will actually forward messages on to the sinks. More...
 
OSVR_UTIL_EXPORT void flushOn (LogLevel level)
 Set the log level at which this logger will trigger a flush.
 
OSVR_UTIL_EXPORT StreamProxy log (LogLevel level, const char *msg)
 logger.log(log_level, msg) (with optional << "more message") call style
 
OSVR_UTIL_EXPORT StreamProxy log (LogLevel level)
 logger.log(log_level) << "msg" call style
 
OSVR_UTIL_EXPORT void flush ()
 Make sure this logger has written out its data.
 
std::string const & getName () const
 Get the logger name.
 
logger->info(msg) (with optional << "more message") call

style

OSVR_UTIL_EXPORT StreamProxy trace (const char *msg)
 
OSVR_UTIL_EXPORT StreamProxy debug (const char *msg)
 
OSVR_UTIL_EXPORT StreamProxy info (const char *msg)
 
OSVR_UTIL_EXPORT StreamProxy notice (const char *msg)
 
OSVR_UTIL_EXPORT StreamProxy warn (const char *msg)
 
OSVR_UTIL_EXPORT StreamProxy error (const char *msg)
 
OSVR_UTIL_EXPORT StreamProxy critical (const char *msg)
 
logger->info() << "msg" call style
OSVR_UTIL_EXPORT StreamProxy trace ()
 
OSVR_UTIL_EXPORT StreamProxy debug ()
 
OSVR_UTIL_EXPORT StreamProxy info ()
 
OSVR_UTIL_EXPORT StreamProxy notice ()
 
OSVR_UTIL_EXPORT StreamProxy warn ()
 
OSVR_UTIL_EXPORT StreamProxy error ()
 
OSVR_UTIL_EXPORT StreamProxy critical ()
 

Static Public Member Functions

static OSVR_UTIL_EXPORT LoggerPtr makeFromExistingImplementation (std::string const &name, std::shared_ptr< spdlog::logger > logger)
 Create from existing spdlog (implementation) logger. More...
 
static OSVR_UTIL_EXPORT LoggerPtr makeWithSink (std::string const &name, spdlog::sink_ptr sink)
 Construct with a name and an existing, single spdlog sink. More...
 
static OSVR_UTIL_EXPORT LoggerPtr makeWithSinks (std::string const &name, spdlog::sinks_init_list sinks)
 Construct with a name and an initializer list of existing spdlog sinks. More...
 

Detailed Description

An object allowing you to log messages with a given log source name.

Implemented as a wrapper around the spdlog::logger class.

Constructor & Destructor Documentation

§ Logger()

osvr::util::log::Logger::Logger ( std::string const &  name,
std::shared_ptr< spdlog::logger >  logger,
PrivateConstructor *   
)

Internal-use constructor - please used a factory/named constructor.

Member Function Documentation

§ getLogLevel()

LogLevel osvr::util::log::Logger::getLogLevel ( ) const

Get the minimum level at which this logger will actually forward messages on to the sinks.

§ makeFromExistingImplementation()

LoggerPtr osvr::util::log::Logger::makeFromExistingImplementation ( std::string const &  name,
std::shared_ptr< spdlog::logger >  logger 
)
static

Create from existing spdlog (implementation) logger.

Always returns a valid pointer even on invalid input, though it may be a "fallback" logger.

§ makeWithSink()

LoggerPtr osvr::util::log::Logger::makeWithSink ( std::string const &  name,
spdlog::sink_ptr  sink 
)
static

Construct with a name and an existing, single spdlog sink.

(Does not use any logger registry.)

Always returns a valid pointer even on invalid input, though it may be a "fallback" logger.

§ makeWithSinks()

LoggerPtr osvr::util::log::Logger::makeWithSinks ( std::string const &  name,
spdlog::sinks_init_list  sinks 
)
static

Construct with a name and an initializer list of existing spdlog sinks.

(Does not use any logger registry.)

Always returns a valid pointer even on invalid input, though it may be a "fallback" logger.

Todo:
should we be making a fallback logger here, just hoping spdlog will deal with a bad sink pointer without issue, or filtering the init list to a non-nullptr vector?

§ setLogLevel()

void osvr::util::log::Logger::setLogLevel ( LogLevel  level)

Set the minimum level at which this logger will actually forward messages on to the sinks.


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