log4cplus  2.1.0
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
log4cplus::spi::LoggerImpl Class Reference

This is the central class in the log4cplus package. More...

#include <loggerimpl.h>

Inheritance diagram for log4cplus::spi::LoggerImpl:
[legend]
Collaboration diagram for log4cplus::spi::LoggerImpl:
[legend]

Public Types

typedef helpers::SharedObjectPtr< LoggerImplSharedLoggerImplPtr
 

Public Member Functions

virtual void callAppenders (const InternalLoggingEvent &event)
 Call the appenders in the hierrachy starting at this. More...
 
virtual void closeNestedAppenders ()
 Close all attached appenders implementing the AppenderAttachable interface. More...
 
virtual bool isEnabledFor (LogLevel ll) const
 Check whether this logger is enabled for a given LogLevel passed as parameter. More...
 
virtual void log (LogLevel ll, const log4cplus::tstring &message, const char *file=nullptr, int line=-1, const char *function=nullptr)
 This generic form is intended to be used by wrappers. More...
 
virtual void log (spi::InternalLoggingEvent const &)
 
virtual LogLevel getChainedLogLevel () const
 Starting from this logger, search the logger hierarchy for a "set" LogLevel and return it. More...
 
LogLevel getLogLevel () const
 Returns the assigned LogLevel, if any, for this Logger. More...
 
void setLogLevel (LogLevel _ll)
 Set the LogLevel of this Logger. More...
 
virtual HierarchygetHierarchy () const
 Return the the Hierarchy where this Logger instance is attached. More...
 
log4cplus::tstring const & getName () const
 Return the logger name. More...
 
bool getAdditivity () const
 Get the additivity flag for this Logger instance. More...
 
void setAdditivity (bool additive)
 Set the additivity flag for this Logger instance. More...
 
virtual ~LoggerImpl ()
 
- Public Member Functions inherited from log4cplus::helpers::SharedObject
void addReference () const LOG4CPLUS_NOEXCEPT
 
void removeReference () const
 
- Public Member Functions inherited from log4cplus::helpers::AppenderAttachableImpl
 AppenderAttachableImpl ()
 
virtual ~AppenderAttachableImpl ()
 
virtual void addAppender (SharedAppenderPtr newAppender)
 Add an appender. More...
 
virtual SharedAppenderPtrList getAllAppenders ()
 Get all previously added appenders as an vectory. More...
 
virtual SharedAppenderPtr getAppender (const log4cplus::tstring &name)
 Look for an attached appender named as name. More...
 
virtual void removeAllAppenders ()
 Remove all previously added appenders. More...
 
virtual void removeAppender (SharedAppenderPtr appender)
 Remove the appender passed as parameter from the list of appenders. More...
 
virtual void removeAppender (const log4cplus::tstring &name)
 Remove the appender with the name passed as parameter from the list of appenders. More...
 
int appendLoopOnAppenders (const spi::InternalLoggingEvent &event) const
 Call the doAppend method on all attached appenders. More...
 
- Public Member Functions inherited from log4cplus::spi::AppenderAttachable
virtual ~AppenderAttachable ()=0
 

Protected Member Functions

 LoggerImpl (const log4cplus::tstring &name, Hierarchy &h)
 This constructor created a new Logger instance and sets its name. More...
 
virtual void forcedLog (LogLevel ll, const log4cplus::tstring &message, const char *file, int line, const char *function)
 This method creates a new logging event and logs the event without further checks. More...
 
virtual void forcedLog (spi::InternalLoggingEvent const &ev)
 
- Protected Member Functions inherited from log4cplus::helpers::SharedObject
 SharedObject ()
 
 SharedObject (const SharedObject &)
 
 SharedObject (SharedObject &&)
 
virtual ~SharedObject ()
 
SharedObjectoperator= (const SharedObject &) LOG4CPLUS_NOEXCEPT
 
SharedObjectoperator= (SharedObject &&) LOG4CPLUS_NOEXCEPT
 

Protected Attributes

log4cplus::tstring name
 The name of this logger. More...
 
LogLevel ll
 The assigned LogLevel of this logger. More...
 
SharedLoggerImplPtr parent
 The parent of this logger. More...
 
bool additive
 Additivity is set to true by default, that is children inherit the appenders of their ancestors by default. More...
 
- Protected Attributes inherited from log4cplus::helpers::AppenderAttachableImpl
ListType appenderList
 Array of appenders. More...
 

Friends

class log4cplus::Logger
 
class log4cplus::DefaultLoggerFactory
 
class log4cplus::Hierarchy
 

Additional Inherited Members

- Public Attributes inherited from log4cplus::helpers::SharedObject
thread::Mutex access_mutex
 
- Public Attributes inherited from log4cplus::helpers::AppenderAttachableImpl
thread::Mutex appender_list_mutex
 
- Protected Types inherited from log4cplus::helpers::AppenderAttachableImpl
typedef std::vector< SharedAppenderPtrListType
 

Detailed Description

This is the central class in the log4cplus package.

One of the distintive features of log4cplus are hierarchical loggers and their evaluation.

Definition at line 51 of file loggerimpl.h.

Member Typedef Documentation

◆ SharedLoggerImplPtr

Definition at line 56 of file loggerimpl.h.

Constructor & Destructor Documentation

◆ ~LoggerImpl()

virtual log4cplus::spi::LoggerImpl::~LoggerImpl ( )
virtual

◆ LoggerImpl()

log4cplus::spi::LoggerImpl::LoggerImpl ( const log4cplus::tstring name,
Hierarchy h 
)
protected

This constructor created a new Logger instance and sets its name.

It is intended to be used by sub-classes only. You should not create loggers directly.

Parameters
nameThe name of the logger.
hHierarchy

Member Function Documentation

◆ callAppenders()

virtual void log4cplus::spi::LoggerImpl::callAppenders ( const InternalLoggingEvent event)
virtual

Call the appenders in the hierrachy starting at this.

If no appenders could be found, emit a warning.

This method calls all the appenders inherited from the hierarchy circumventing any evaluation of whether to log or not to log the particular log request.

Parameters
eventThe event to log.

◆ closeNestedAppenders()

virtual void log4cplus::spi::LoggerImpl::closeNestedAppenders ( )
virtual

Close all attached appenders implementing the AppenderAttachable interface.

◆ forcedLog() [1/2]

virtual void log4cplus::spi::LoggerImpl::forcedLog ( LogLevel  ll,
const log4cplus::tstring message,
const char *  file,
int  line,
const char *  function 
)
protectedvirtual

This method creates a new logging event and logs the event without further checks.

◆ forcedLog() [2/2]

virtual void log4cplus::spi::LoggerImpl::forcedLog ( spi::InternalLoggingEvent const &  ev)
protectedvirtual

◆ getAdditivity()

bool log4cplus::spi::LoggerImpl::getAdditivity ( ) const

Get the additivity flag for this Logger instance.

◆ getChainedLogLevel()

virtual LogLevel log4cplus::spi::LoggerImpl::getChainedLogLevel ( ) const
virtual

Starting from this logger, search the logger hierarchy for a "set" LogLevel and return it.

Otherwise, return the LogLevel of the root logger.

The Logger class is designed so that this method executes as quickly as possible.

Reimplemented in log4cplus::spi::RootLogger.

◆ getHierarchy()

virtual Hierarchy& log4cplus::spi::LoggerImpl::getHierarchy ( ) const
virtual

Return the the Hierarchy where this Logger instance is attached.

◆ getLogLevel()

LogLevel log4cplus::spi::LoggerImpl::getLogLevel ( ) const
inline

Returns the assigned LogLevel, if any, for this Logger.

Returns
LogLevel - the assigned LogLevel.

Definition at line 111 of file loggerimpl.h.

◆ getName()

log4cplus::tstring const& log4cplus::spi::LoggerImpl::getName ( ) const
inline

Return the logger name.

Definition at line 127 of file loggerimpl.h.

◆ isEnabledFor()

virtual bool log4cplus::spi::LoggerImpl::isEnabledFor ( LogLevel  ll) const
virtual

Check whether this logger is enabled for a given LogLevel passed as parameter.

Returns
boolean True if this logger is enabled for ll.

◆ log() [1/2]

virtual void log4cplus::spi::LoggerImpl::log ( LogLevel  ll,
const log4cplus::tstring message,
const char *  file = nullptr,
int  line = -1,
const char *  function = nullptr 
)
virtual

This generic form is intended to be used by wrappers.

◆ log() [2/2]

virtual void log4cplus::spi::LoggerImpl::log ( spi::InternalLoggingEvent const &  )
virtual

◆ setAdditivity()

void log4cplus::spi::LoggerImpl::setAdditivity ( bool  additive)

Set the additivity flag for this Logger instance.

◆ setLogLevel()

void log4cplus::spi::LoggerImpl::setLogLevel ( LogLevel  _ll)
inline

Set the LogLevel of this Logger.

Definition at line 116 of file loggerimpl.h.

Friends And Related Function Documentation

◆ log4cplus::DefaultLoggerFactory

friend class log4cplus::DefaultLoggerFactory
friend

Definition at line 207 of file loggerimpl.h.

◆ log4cplus::Hierarchy

friend class log4cplus::Hierarchy
friend

Definition at line 208 of file loggerimpl.h.

◆ log4cplus::Logger

friend class log4cplus::Logger
friend

Definition at line 206 of file loggerimpl.h.

Member Data Documentation

◆ additive

bool log4cplus::spi::LoggerImpl::additive
protected

Additivity is set to true by default, that is children inherit the appenders of their ancestors by default.

If this variable is set to false then the appenders found in the ancestors of this logger are not used. However, the children of this logger will inherit its appenders, unless the children have their additivity flag set to false too. See the user manual for more details.

Definition at line 194 of file loggerimpl.h.

◆ ll

LogLevel log4cplus::spi::LoggerImpl::ll
protected

The assigned LogLevel of this logger.

Definition at line 177 of file loggerimpl.h.

◆ name

log4cplus::tstring log4cplus::spi::LoggerImpl::name
protected

The name of this logger.

Definition at line 172 of file loggerimpl.h.

◆ parent

SharedLoggerImplPtr log4cplus::spi::LoggerImpl::parent
protected

The parent of this logger.

All loggers have at least one ancestor which is the root logger.

Definition at line 183 of file loggerimpl.h.


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