log4cplus  2.0.5
loggerimpl.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 // Module: Log4CPLUS
3 // File: loggerimpl.h
4 // Created: 6/2001
5 // Author: Tad E. Smith
6 //
7 //
8 // Copyright 2001-2017 Tad E. Smith
9 //
10 // Licensed under the Apache License, Version 2.0 (the "License");
11 // you may not use this file except in compliance with the License.
12 // You may obtain a copy of the License at
13 //
14 // http://www.apache.org/licenses/LICENSE-2.0
15 //
16 // Unless required by applicable law or agreed to in writing, software
17 // distributed under the License is distributed on an "AS IS" BASIS,
18 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 // See the License for the specific language governing permissions and
20 // limitations under the License.
21 
24 #ifndef LOG4CPLUS_SPI_LOGGER_HEADER_
25 #define LOG4CPLUS_SPI_LOGGER_HEADER_
26 
27 #include <log4cplus/config.hxx>
28 
29 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
30 #pragma once
31 #endif
32 
33 #include <log4cplus/tstring.h>
37 #include <memory>
38 #include <vector>
39 
40 
41 namespace log4cplus {
42  class DefaultLoggerFactory;
43 
44  namespace spi {
45 
52  : public virtual log4cplus::helpers::SharedObject,
54  {
55  public:
57 
58  // Methods
59 
71  virtual void callAppenders(const InternalLoggingEvent& event);
72 
77  virtual void closeNestedAppenders();
78 
85  virtual bool isEnabledFor(LogLevel ll) const;
86 
90  virtual void log(LogLevel ll, const log4cplus::tstring& message,
91  const char* file=nullptr, int line=-1,
92  const char* function=nullptr);
93 
94  virtual void log(spi::InternalLoggingEvent const &);
95 
104  virtual LogLevel getChainedLogLevel() const;
105 
111  LogLevel getLogLevel() const { return this->ll; }
112 
116  void setLogLevel(LogLevel _ll) { this->ll = _ll; }
117 
122  virtual Hierarchy& getHierarchy() const;
123 
127  log4cplus::tstring const & getName() const { return name; }
128 
132  bool getAdditivity() const;
133 
137  void setAdditivity(bool additive);
138 
139  virtual ~LoggerImpl();
140 
141  protected:
142  // Ctors
154 
155 
156  // Methods
161  virtual void forcedLog(LogLevel ll,
162  const log4cplus::tstring& message,
163  const char* file,
164  int line,
165  const char* function);
166 
167  virtual void forcedLog(spi::InternalLoggingEvent const & ev);
168 
169 
170  // Data
173 
178 
184 
194  bool additive;
195 
196  private:
197  // Data
199  Hierarchy& hierarchy;
200 
201  // Disallow copying of instances of this class
202  LoggerImpl(const LoggerImpl&) = delete;
203  LoggerImpl& operator=(const LoggerImpl&) = delete;
204 
205  // Friends
206  friend class log4cplus::Logger;
208  friend class log4cplus::Hierarchy;
209  };
210 
212 
213  } // end namespace spi
214 } // end namespace log4cplus
215 
216 #endif // LOG4CPLUS_SPI_LOGGER_HEADER_
log4cplus::spi::LoggerImpl::callAppenders
virtual void callAppenders(const InternalLoggingEvent &event)
Call the appenders in the hierrachy starting at this.
tstring.h
log4cplus::spi::LoggerImpl::log
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.
log4cplus::helpers::AppenderAttachableImpl
This Interface is for attaching Appenders to objects.
Definition: appenderattachableimpl.h:50
appenderattachableimpl.h
log4cplus
Definition: appender.h:46
log4cplus::tstring
std::basic_string< tchar > tstring
Definition: tstring.h:39
log4cplus::spi::LoggerImpl::LoggerImpl
LoggerImpl(const log4cplus::tstring &name, Hierarchy &h)
This constructor created a new Logger instance and sets its name.
log4cplus::helpers::SharedObjectPtr< LoggerImpl >
log4cplus::spi::LoggerImpl::log
virtual void log(spi::InternalLoggingEvent const &)
log4cplus::spi::LoggerImpl
This is the central class in the log4cplus package.
Definition: loggerimpl.h:54
log4cplus::spi::LoggerImpl::setLogLevel
void setLogLevel(LogLevel _ll)
Set the LogLevel of this Logger.
Definition: loggerimpl.h:116
log4cplus::spi::LoggerImpl::forcedLog
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.
log4cplus::spi::LoggerImpl::name
log4cplus::tstring name
The name of this logger.
Definition: loggerimpl.h:172
loggerfactory.h
log4cplus::spi::LoggerImpl::additive
bool additive
Additivity is set to true by default, that is children inherit the appenders of their ancestors by de...
Definition: loggerimpl.h:194
log4cplus::spi::LoggerImpl::getName
log4cplus::tstring const & getName() const
Return the logger name.
Definition: loggerimpl.h:127
log4cplus::spi::LoggerImpl::parent
SharedLoggerImplPtr parent
The parent of this logger.
Definition: loggerimpl.h:183
log4cplus::spi::LoggerImpl::closeNestedAppenders
virtual void closeNestedAppenders()
Close all attached appenders implementing the AppenderAttachable interface.
config.hxx
pointer.h
log4cplus::spi::LoggerImpl::setAdditivity
void setAdditivity(bool additive)
Set the additivity flag for this Logger instance.
log4cplus::spi::LoggerImpl::forcedLog
virtual void forcedLog(spi::InternalLoggingEvent const &ev)
log4cplus::Hierarchy
This class is specialized in retrieving loggers by name and also maintaining the logger hierarchy.
Definition: hierarchy.h:64
log4cplus::spi::LoggerImpl::getAdditivity
bool getAdditivity() const
Get the additivity flag for this Logger instance.
log4cplus::LogLevel
int LogLevel
Definition: loglevel.h:48
log4cplus::spi::LoggerImpl::ll
LogLevel ll
The assigned LogLevel of this logger.
Definition: loggerimpl.h:177
log4cplus::spi::LoggerImpl::isEnabledFor
virtual bool isEnabledFor(LogLevel ll) const
Check whether this logger is enabled for a given LogLevel passed as parameter.
log4cplus::spi::SharedLoggerImplPtr
LoggerImpl::SharedLoggerImplPtr SharedLoggerImplPtr
Definition: loggerimpl.h:211
log4cplus::spi::InternalLoggingEvent
The internal representation of logging events.
Definition: loggingevent.h:51
log4cplus::spi::LoggerImpl::getHierarchy
virtual Hierarchy & getHierarchy() const
Return the the Hierarchy where this Logger instance is attached.
LOG4CPLUS_EXPORT
#define LOG4CPLUS_EXPORT
Definition: win32.h:141
log4cplus::helpers::SharedObject
Definition: pointer.h:54
log4cplus::spi::LoggerImpl::SharedLoggerImplPtr
helpers::SharedObjectPtr< LoggerImpl > SharedLoggerImplPtr
Definition: loggerimpl.h:56
log4cplus::spi::LoggerImpl::getChainedLogLevel
virtual LogLevel getChainedLogLevel() const
Starting from this logger, search the logger hierarchy for a "set" LogLevel and return it.
log4cplus::spi::LoggerImpl::getLogLevel
LogLevel getLogLevel() const
Returns the assigned LogLevel, if any, for this Logger.
Definition: loggerimpl.h:111
log4cplus::DefaultLoggerFactory
This class is used to create the default implementation of the Logger class.
Definition: logger.h:312
log4cplus::Logger
This is the central class in the log4cplus package.
Definition: logger.h:71
log4cplus::spi::LoggerImpl::~LoggerImpl
virtual ~LoggerImpl()