AYON Cpp Dev Tools  0.1.0
Loading...
Searching...
No Matches
AyonLogger Class Reference

Simple Logger Class that wraps around spdlog in order to expose easy logging functions. More...

#include <AyonLogger.hpp>

Collaboration diagram for AyonLogger:

Public Member Functions

void initFileLogger (const std::string &filepath, unsigned int flushIntervalSeconds=0)
 
 AyonLogger (const AyonLogger &)=delete
 
AyonLoggeroperator= (const AyonLogger &)=delete
 
std::set< std::string >::iterator key (const std::string &key)
 
bool registerLoggingKey (const std::string &keyName)
 
bool unregisterLoggingKey (const std::string &keyName)
 
bool isKeyActive (const std::set< std::string >::iterator &loggingIterator)
 
template<typename... Args>
void error (fmt::format_string< Args... > fmt, Args &&... args)
 
template<typename... Args>
void error (const std::set< std::string >::iterator &it, fmt::format_string< Args... > fmt, Args &&... args)
 
template<typename... Args>
void info (fmt::format_string< Args... > fmt, Args &&... args)
 
template<typename... Args>
void info (const std::set< std::string >::iterator &it, fmt::format_string< Args... > fmt, Args &&... args)
 
template<typename... Args>
void warn (fmt::format_string< Args... > fmt, Args &&... args)
 
template<typename... Args>
void warn (const std::set< std::string >::iterator &it, fmt::format_string< Args... > fmt, Args &&... args)
 
template<typename... Args>
void critical (fmt::format_string< Args... > fmt, Args &&... args)
 
template<typename... Args>
void critical (const std::set< std::string >::iterator &it, fmt::format_string< Args... > fmt, Args &&... args)
 
void setLogLevel (spdlog::level::level_enum lvl, bool applyToFile=false)
 
void setLogLevel (const std::string &levelStr, bool applyToFile=false)
 
void setLogLevelFromEnv (const std::string &envKey="AYON_USD_RESOLVER_LOG_LVL", bool applyToFile=false)
 
void setLogLevelInfo (bool applyToFile=false)
 
void setLogLevelError (bool applyToFile=false)
 
void setLogLevelWarn (bool applyToFile=false)
 
void setLogLevelCritical (bool applyToFile=false)
 
void setLogLevelOff (bool applyToFile=false)
 
void flush ()
 

Static Public Member Functions

static AyonLoggergetInstance ()
 

Private Member Functions

 AyonLogger ()
 
 ~AyonLogger ()
 
template<typename... Args>
void log (spdlog::level::level_enum lvl, fmt::format_string< Args... > fmt, Args &&... args)
 
bool canUseAsyncFileLogger () const
 
void setLevel (spdlog::level::level_enum lvl, bool applyToFile)
 

Private Attributes

std::shared_ptr< spdlog::logger > m_consoleLogger
 
std::shared_ptr< spdlog::logger > m_fileLogger
 
std::weak_ptr< spdlog::details::thread_pool > m_fileLoggerThreadPool
 
bool m_enableFileLogging {false}
 
std::mutex m_initMutex
 
std::set< std::string > m_enabledLoggingKeys
 

Detailed Description

Simple Logger Class that wraps around spdlog in order to expose easy logging functions.

Uses async logging for better performance.

Usage: auto& log = AyonLogger::getInstance(); log.initFileLogger("/tmp/app.log"); log.registerLoggingKey("MyModule"); log.info(log.key("MyModule"), "Started {}", version);

Constructor & Destructor Documentation

◆ AyonLogger() [1/2]

AyonLogger::AyonLogger ( const AyonLogger )
delete

◆ AyonLogger() [2/2]

AyonLogger::AyonLogger ( )
inlineprivate
Here is the caller graph for this function:

◆ ~AyonLogger()

AyonLogger::~AyonLogger ( )
inlineprivate

Member Function Documentation

◆ canUseAsyncFileLogger()

bool AyonLogger::canUseAsyncFileLogger ( ) const
inlineprivate
Here is the caller graph for this function:

◆ critical() [1/2]

template<typename... Args>
void AyonLogger::critical ( const std::set< std::string >::iterator &  it,
fmt::format_string< Args... >  fmt,
Args &&...  args 
)
inline
Here is the call graph for this function:

◆ critical() [2/2]

template<typename... Args>
void AyonLogger::critical ( fmt::format_string< Args... >  fmt,
Args &&...  args 
)
inline
Here is the call graph for this function:

◆ error() [1/2]

template<typename... Args>
void AyonLogger::error ( const std::set< std::string >::iterator &  it,
fmt::format_string< Args... >  fmt,
Args &&...  args 
)
inline
Here is the call graph for this function:

◆ error() [2/2]

template<typename... Args>
void AyonLogger::error ( fmt::format_string< Args... >  fmt,
Args &&...  args 
)
inline
Here is the call graph for this function:

◆ flush()

void AyonLogger::flush ( )
inline
Here is the call graph for this function:

◆ getInstance()

static AyonLogger & AyonLogger::getInstance ( )
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ info() [1/2]

template<typename... Args>
void AyonLogger::info ( const std::set< std::string >::iterator &  it,
fmt::format_string< Args... >  fmt,
Args &&...  args 
)
inline
Here is the call graph for this function:

◆ info() [2/2]

template<typename... Args>
void AyonLogger::info ( fmt::format_string< Args... >  fmt,
Args &&...  args 
)
inline
Here is the call graph for this function:

◆ initFileLogger()

void AyonLogger::initFileLogger ( const std::string &  filepath,
unsigned int  flushIntervalSeconds = 0 
)
inline

◆ isKeyActive()

bool AyonLogger::isKeyActive ( const std::set< std::string >::iterator &  loggingIterator)
inline
Here is the caller graph for this function:

◆ key()

std::set< std::string >::iterator AyonLogger::key ( const std::string &  key)
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ log()

template<typename... Args>
void AyonLogger::log ( spdlog::level::level_enum  lvl,
fmt::format_string< Args... >  fmt,
Args &&...  args 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

AyonLogger & AyonLogger::operator= ( const AyonLogger )
delete

◆ registerLoggingKey()

bool AyonLogger::registerLoggingKey ( const std::string &  keyName)
inline

◆ setLevel()

void AyonLogger::setLevel ( spdlog::level::level_enum  lvl,
bool  applyToFile 
)
inlineprivate
Here is the caller graph for this function:

◆ setLogLevel() [1/2]

void AyonLogger::setLogLevel ( const std::string &  levelStr,
bool  applyToFile = false 
)
inline
Here is the call graph for this function:

◆ setLogLevel() [2/2]

void AyonLogger::setLogLevel ( spdlog::level::level_enum  lvl,
bool  applyToFile = false 
)
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setLogLevelCritical()

void AyonLogger::setLogLevelCritical ( bool  applyToFile = false)
inline
Here is the call graph for this function:

◆ setLogLevelError()

void AyonLogger::setLogLevelError ( bool  applyToFile = false)
inline
Here is the call graph for this function:

◆ setLogLevelFromEnv()

void AyonLogger::setLogLevelFromEnv ( const std::string &  envKey = "AYON_USD_RESOLVER_LOG_LVL",
bool  applyToFile = false 
)
inline
Here is the call graph for this function:

◆ setLogLevelInfo()

void AyonLogger::setLogLevelInfo ( bool  applyToFile = false)
inline
Here is the call graph for this function:

◆ setLogLevelOff()

void AyonLogger::setLogLevelOff ( bool  applyToFile = false)
inline
Here is the call graph for this function:

◆ setLogLevelWarn()

void AyonLogger::setLogLevelWarn ( bool  applyToFile = false)
inline
Here is the call graph for this function:

◆ unregisterLoggingKey()

bool AyonLogger::unregisterLoggingKey ( const std::string &  keyName)
inline

◆ warn() [1/2]

template<typename... Args>
void AyonLogger::warn ( const std::set< std::string >::iterator &  it,
fmt::format_string< Args... >  fmt,
Args &&...  args 
)
inline
Here is the call graph for this function:

◆ warn() [2/2]

template<typename... Args>
void AyonLogger::warn ( fmt::format_string< Args... >  fmt,
Args &&...  args 
)
inline
Here is the call graph for this function:

Member Data Documentation

◆ m_consoleLogger

std::shared_ptr<spdlog::logger> AyonLogger::m_consoleLogger
private

◆ m_enabledLoggingKeys

std::set<std::string> AyonLogger::m_enabledLoggingKeys
private

◆ m_enableFileLogging

bool AyonLogger::m_enableFileLogging {false}
private

◆ m_fileLogger

std::shared_ptr<spdlog::logger> AyonLogger::m_fileLogger
private

◆ m_fileLoggerThreadPool

std::weak_ptr<spdlog::details::thread_pool> AyonLogger::m_fileLoggerThreadPool
private

◆ m_initMutex

std::mutex AyonLogger::m_initMutex
private

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