libmoost
moost::logging::scoped_logger Class Reference

handles verbose with log4cxx gracefully. scoped_logger takes care of collecting the log information within the scope, then spit it out (to whatever it was configured to) More...

#include <scoped_logger.hpp>

List of all members.

Classes

struct  sLogEntry

Public Member Functions

 scoped_logger ()
 scoped_logger (const std::string &name)
 scoped_logger (const std::string &name, moost::timer::scoped_time &sc)
 scoped_logger (const std::string &name, moost::multi_timer::scoped_time &sc)
 scoped_logger (const std::string &name, const boost::posix_time::ptime &startTime)
 ~scoped_logger ()
void setTimingsHeader (const std::string &totTimingsHeader=" Overall time: ", const std::string &subTimingsIndentation=" -> ")
void addSubTime (const std::string &header, int ms)
void forcedLog (const log4cxx::LevelPtr &level, const std::string &message)
void forcedLog (const log4cxx::LevelPtr &level, const std::string &message, const log4cxx::spi::LocationInfo &location)
log4cxx::LevelPtr getLevel () const
virtual void setLevel (const log4cxx::LevelPtr &level)
void debug (const std::string &msg, const log4cxx::spi::LocationInfo &location)
void debug (const std::string &msg)
void error (const std::string &msg, const log4cxx::spi::LocationInfo &location)
void error (const std::string &msg)
void fatal (const std::string &msg, const log4cxx::spi::LocationInfo &location)
void fatal (const std::string &msg)
void info (const std::string &msg, const log4cxx::spi::LocationInfo &location)
void info (const std::string &msg)
void log (const log4cxx::LevelPtr &level, const std::string &message, const log4cxx::spi::LocationInfo &location)
void log (const log4cxx::LevelPtr &level, const std::string &message)
void warn (const std::string &msg, const log4cxx::spi::LocationInfo &location)
void warn (const std::string &msg)
void trace (const std::string &msg, const log4cxx::spi::LocationInfo &location)
void trace (const std::string &msg)
void addRef () const
void releaseRef () const
virtual void addAppender (const log4cxx::AppenderPtr &)
void callAppenders (const log4cxx::spi::LoggingEventPtr &, log4cxx::helpers::Pool &) const
void closeNestedAppenders ()
bool getAdditivity () const
virtual const log4cxx::LevelPtr & getEffectiveLevel () const
log4cxx::spi::LoggerRepositoryPtr getLoggerRepository () const
void getName (std::string &name) const
log4cxx::LoggerPtr getParent () const
log4cxx::helpers::ResourceBundlePtr getResourceBundle () const
void removeAllAppenders ()
void removeAppender (const log4cxx::AppenderPtr &appender)
void setAdditivity (bool additive)
void setResourceBundle (const log4cxx::helpers::ResourceBundlePtr &bundle)
const log4cxx::helpers::Mutex & getMutex () const
bool isAttached (const log4cxx::AppenderPtr &appender) const
bool isEnabledFor (const log4cxx::LevelPtr &level) const
bool isDebugEnabled () const
bool isInfoEnabled () const
bool isWarnEnabled () const
bool isErrorEnabled () const
bool isFatalEnabled () const
bool isTraceEnabled () const
void init (const std::string &name, log4cxx::LevelPtr level=log4cxx::Level::getFatal())

Private Member Functions

void forcedLog ()
void updateHighestLevel (const log4cxx::LevelPtr &level)

Private Attributes

log4cxx::LevelPtr m_loggerLevel
log4cxx::LevelPtr m_highestMessageLevel
log4cxx::LogString m_name
std::vector< sLogEntrym_messages
std::vector< std::pair
< log4cxx::LevelPtr,
log4cxx::AppenderPtr > > 
m_appenders
boost::posix_time::ptime m_startTime
std::map< std::string, int > m_subTimes
std::string m_totTimingsHeader
std::string m_subTimingsIndentation

Detailed Description

handles verbose with log4cxx gracefully. scoped_logger takes care of collecting the log information within the scope, then spit it out (to whatever it was configured to)

Note:
Important: scoped_logger is not thread safe.
I must forward everything because the constructor is a bit of a mess (it's generated from a factory).

Definition at line 67 of file scoped_logger.hpp.


Constructor & Destructor Documentation

Definition at line 83 of file scoped_logger.hpp.

Here is the call graph for this function:

moost::logging::scoped_logger::scoped_logger ( const std::string &  name) [inline]

Definition at line 89 of file scoped_logger.hpp.

Here is the call graph for this function:

moost::logging::scoped_logger::scoped_logger ( const std::string &  name,
moost::timer::scoped_time sc 
) [inline]

Definition at line 95 of file scoped_logger.hpp.

Here is the call graph for this function:

moost::logging::scoped_logger::scoped_logger ( const std::string &  name,
moost::multi_timer::scoped_time sc 
) [inline]

Definition at line 101 of file scoped_logger.hpp.

Here is the call graph for this function:

moost::logging::scoped_logger::scoped_logger ( const std::string &  name,
const boost::posix_time::ptime &  startTime 
) [inline]

Definition at line 107 of file scoped_logger.hpp.

Here is the call graph for this function:

Definition at line 113 of file scoped_logger.hpp.

Here is the call graph for this function:


Member Function Documentation

virtual void moost::logging::scoped_logger::addAppender ( const log4cxx::AppenderPtr &  ) [inline, virtual]

Definition at line 269 of file scoped_logger.hpp.

void moost::logging::scoped_logger::addRef ( ) const [inline]

Definition at line 265 of file scoped_logger.hpp.

void moost::logging::scoped_logger::addSubTime ( const std::string &  header,
int  ms 
) [inline]

Definition at line 135 of file scoped_logger.hpp.

void moost::logging::scoped_logger::callAppenders ( const log4cxx::spi::LoggingEventPtr &  ,
log4cxx::helpers::Pool &   
) const [inline]

Definition at line 271 of file scoped_logger.hpp.

Definition at line 273 of file scoped_logger.hpp.

void moost::logging::scoped_logger::debug ( const std::string &  msg,
const log4cxx::spi::LocationInfo &  location 
) [inline]

Definition at line 171 of file scoped_logger.hpp.

Here is the call graph for this function:

void moost::logging::scoped_logger::debug ( const std::string &  msg) [inline]

Definition at line 177 of file scoped_logger.hpp.

Here is the call graph for this function:

void moost::logging::scoped_logger::error ( const std::string &  msg,
const log4cxx::spi::LocationInfo &  location 
) [inline]

Definition at line 184 of file scoped_logger.hpp.

Here is the call graph for this function:

void moost::logging::scoped_logger::error ( const std::string &  msg) [inline]

Definition at line 190 of file scoped_logger.hpp.

Here is the call graph for this function:

void moost::logging::scoped_logger::fatal ( const std::string &  msg,
const log4cxx::spi::LocationInfo &  location 
) [inline]

Definition at line 197 of file scoped_logger.hpp.

Here is the call graph for this function:

void moost::logging::scoped_logger::fatal ( const std::string &  msg) [inline]

Definition at line 203 of file scoped_logger.hpp.

Here is the call graph for this function:

void moost::logging::scoped_logger::forcedLog ( const log4cxx::LevelPtr &  level,
const std::string &  message 
) [inline]

Definition at line 142 of file scoped_logger.hpp.

Here is the call graph for this function:

void moost::logging::scoped_logger::forcedLog ( const log4cxx::LevelPtr &  level,
const std::string &  message,
const log4cxx::spi::LocationInfo &  location 
) [inline]

Definition at line 152 of file scoped_logger.hpp.

Here is the call graph for this function:

void moost::logging::scoped_logger::forcedLog ( ) [inline, private]

Definition at line 343 of file scoped_logger.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 276 of file scoped_logger.hpp.

virtual const log4cxx::LevelPtr& moost::logging::scoped_logger::getEffectiveLevel ( ) const [inline, virtual]

Definition at line 280 of file scoped_logger.hpp.

log4cxx::LevelPtr moost::logging::scoped_logger::getLevel ( ) const [inline]

Definition at line 163 of file scoped_logger.hpp.

log4cxx::spi::LoggerRepositoryPtr moost::logging::scoped_logger::getLoggerRepository ( ) const [inline]

Definition at line 282 of file scoped_logger.hpp.

const log4cxx::helpers::Mutex& moost::logging::scoped_logger::getMutex ( ) const [inline]

Definition at line 299 of file scoped_logger.hpp.

void moost::logging::scoped_logger::getName ( std::string &  name) const [inline]

Definition at line 284 of file scoped_logger.hpp.

log4cxx::LoggerPtr moost::logging::scoped_logger::getParent ( ) const [inline]

Definition at line 286 of file scoped_logger.hpp.

log4cxx::helpers::ResourceBundlePtr moost::logging::scoped_logger::getResourceBundle ( ) const [inline]

Definition at line 288 of file scoped_logger.hpp.

void moost::logging::scoped_logger::info ( const std::string &  msg,
const log4cxx::spi::LocationInfo &  location 
) [inline]

Definition at line 210 of file scoped_logger.hpp.

Here is the call graph for this function:

void moost::logging::scoped_logger::info ( const std::string &  msg) [inline]

Definition at line 216 of file scoped_logger.hpp.

Here is the call graph for this function:

void moost::logging::scoped_logger::init ( const std::string &  name,
log4cxx::LevelPtr  level = log4cxx::Level::getFatal() 
) [inline]

Initialize the logger. It will go through all the appenders currently registered and check the lowest threshold, then set its own level to that and keep track of the appenders.

Definition at line 443 of file scoped_logger.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool moost::logging::scoped_logger::isAttached ( const log4cxx::AppenderPtr &  appender) const [inline]

Definition at line 305 of file scoped_logger.hpp.

Definition at line 310 of file scoped_logger.hpp.

Here is the caller graph for this function:

bool moost::logging::scoped_logger::isEnabledFor ( const log4cxx::LevelPtr &  level) const [inline]

Definition at line 307 of file scoped_logger.hpp.

Here is the caller graph for this function:

Definition at line 316 of file scoped_logger.hpp.

Here is the caller graph for this function:

Definition at line 318 of file scoped_logger.hpp.

Here is the caller graph for this function:

Definition at line 312 of file scoped_logger.hpp.

Here is the caller graph for this function:

Definition at line 320 of file scoped_logger.hpp.

Here is the caller graph for this function:

Definition at line 314 of file scoped_logger.hpp.

Here is the caller graph for this function:

void moost::logging::scoped_logger::log ( const log4cxx::LevelPtr &  level,
const std::string &  message,
const log4cxx::spi::LocationInfo &  location 
) [inline]

Definition at line 223 of file scoped_logger.hpp.

Here is the call graph for this function:

void moost::logging::scoped_logger::log ( const log4cxx::LevelPtr &  level,
const std::string &  message 
) [inline]

Definition at line 230 of file scoped_logger.hpp.

Here is the call graph for this function:

Definition at line 267 of file scoped_logger.hpp.

Definition at line 291 of file scoped_logger.hpp.

void moost::logging::scoped_logger::removeAppender ( const log4cxx::AppenderPtr &  appender) [inline]

Definition at line 293 of file scoped_logger.hpp.

void moost::logging::scoped_logger::setAdditivity ( bool  additive) [inline]

Definition at line 295 of file scoped_logger.hpp.

virtual void moost::logging::scoped_logger::setLevel ( const log4cxx::LevelPtr &  level) [inline, virtual]

Definition at line 166 of file scoped_logger.hpp.

void moost::logging::scoped_logger::setResourceBundle ( const log4cxx::helpers::ResourceBundlePtr &  bundle) [inline]

Definition at line 297 of file scoped_logger.hpp.

void moost::logging::scoped_logger::setTimingsHeader ( const std::string &  totTimingsHeader = "  Overall time: ",
const std::string &  subTimingsIndentation = "    -> " 
) [inline]

Set the timings headers.

Definition at line 129 of file scoped_logger.hpp.

Here is the caller graph for this function:

void moost::logging::scoped_logger::trace ( const std::string &  msg,
const log4cxx::spi::LocationInfo &  location 
) [inline]

Definition at line 250 of file scoped_logger.hpp.

Here is the call graph for this function:

void moost::logging::scoped_logger::trace ( const std::string &  msg) [inline]

Definition at line 256 of file scoped_logger.hpp.

Here is the call graph for this function:

void moost::logging::scoped_logger::updateHighestLevel ( const log4cxx::LevelPtr &  level) [inline, private]

Definition at line 427 of file scoped_logger.hpp.

Here is the caller graph for this function:

void moost::logging::scoped_logger::warn ( const std::string &  msg,
const log4cxx::spi::LocationInfo &  location 
) [inline]

Definition at line 237 of file scoped_logger.hpp.

Here is the call graph for this function:

void moost::logging::scoped_logger::warn ( const std::string &  msg) [inline]

Definition at line 243 of file scoped_logger.hpp.

Here is the call graph for this function:


Member Data Documentation

std::vector< std::pair<log4cxx::LevelPtr, log4cxx::AppenderPtr> > moost::logging::scoped_logger::m_appenders [private]

The list of available appenders.

Definition at line 508 of file scoped_logger.hpp.

The highest level of the message received. It's used when sending the actual entry to the appender.

Definition at line 493 of file scoped_logger.hpp.

log4cxx::LevelPtr moost::logging::scoped_logger::m_loggerLevel [private]

The level of the logger. Below this level nothing is stored. This is generally initialized with the smallest level of all the appenders attached to root.

Definition at line 487 of file scoped_logger.hpp.

The messages stored.

Definition at line 503 of file scoped_logger.hpp.

log4cxx::LogString moost::logging::scoped_logger::m_name [private]

The name of the log.

Definition at line 498 of file scoped_logger.hpp.

boost::posix_time::ptime moost::logging::scoped_logger::m_startTime [private]

Definition at line 510 of file scoped_logger.hpp.

std::map<std::string, int> moost::logging::scoped_logger::m_subTimes [private]

Definition at line 511 of file scoped_logger.hpp.

Definition at line 514 of file scoped_logger.hpp.

Definition at line 513 of file scoped_logger.hpp.


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