loggerimpl.h
Go to the documentation of this file.
// -*- C++ -*-
// Module: Log4CPLUS
// File: loggerimpl.h
// Created: 6/2001
// Author: Tad E. Smith
//
//
// Copyright 2001-2017 Tad E. Smith
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef LOG4CPLUS_SPI_LOGGER_HEADER_
#define LOG4CPLUS_SPI_LOGGER_HEADER_
#include <log4cplus/config.hxx>
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
#pragma once
#endif
#include <log4cplus/tstring.h>
#include <log4cplus/helpers/appenderattachableimpl.h>
#include <log4cplus/helpers/pointer.h>
#include <log4cplus/spi/loggerfactory.h>
#include <memory>
#include <vector>
namespace log4cplus {
class DefaultLoggerFactory;
namespace spi {
class LOG4CPLUS_EXPORT LoggerImpl
: public virtual log4cplus::helpers::SharedObject,
public log4cplus::helpers::AppenderAttachableImpl
{
public:
typedef helpers::SharedObjectPtr<LoggerImpl> SharedLoggerImplPtr;
// Methods
virtual void callAppenders(const InternalLoggingEvent& event);
virtual void closeNestedAppenders();
virtual bool isEnabledFor(LogLevel ll) const;
virtual void log(LogLevel ll, const log4cplus::tstring& message,
const char* file=nullptr, int line=-1,
const char* function=nullptr);
virtual void log(spi::InternalLoggingEvent const &);
virtual LogLevel getChainedLogLevel() const;
LogLevel getLogLevel() const { return this->ll; }
void setLogLevel(LogLevel _ll) { this->ll = _ll; }
virtual Hierarchy& getHierarchy() const;
log4cplus::tstring const & getName() const { return name; }
bool getAdditivity() const;
void setAdditivity(bool additive);
virtual ~LoggerImpl();
protected:
// Ctors
LoggerImpl(const log4cplus::tstring& name, Hierarchy& h);
// Methods
virtual void forcedLog(LogLevel ll,
const log4cplus::tstring& message,
const char* file,
int line,
const char* function);
virtual void forcedLog(spi::InternalLoggingEvent const & ev);
// Data
log4cplus::tstring name;
LogLevel ll;
SharedLoggerImplPtr parent;
bool additive;
private:
// Data
Hierarchy& hierarchy;
// Disallow copying of instances of this class
LoggerImpl(const LoggerImpl&) = delete;
LoggerImpl& operator=(const LoggerImpl&) = delete;
// Friends
friend class log4cplus::Logger;
friend class log4cplus::DefaultLoggerFactory;
friend class log4cplus::Hierarchy;
};
typedef LoggerImpl::SharedLoggerImplPtr SharedLoggerImplPtr;
} // end namespace spi
} // end namespace log4cplus
#endif // LOG4CPLUS_SPI_LOGGER_HEADER_
appenderattachableimpl.h
log4cplus::DefaultLoggerFactory
This class is used to create the default implementation of the Logger class.
Definition logger.h:312
log4cplus::Hierarchy
This class is specialized in retrieving loggers by name and also maintaining the logger hierarchy.
Definition hierarchy.h:64
log4cplus::Logger
This is the central class in the log4cplus package.
Definition logger.h:71
log4cplus::helpers::AppenderAttachableImpl
This Interface is for attaching Appenders to objects.
Definition appenderattachableimpl.h:50
log4cplus::helpers::SharedObjectPtr
Definition pointer.h:101
log4cplus::helpers::SharedObject
Definition pointer.h:54
log4cplus::spi::InternalLoggingEvent
The internal representation of logging events.
Definition loggingevent.h:51
log4cplus::spi::LoggerImpl::closeNestedAppenders
virtual void closeNestedAppenders()
Close all attached appenders implementing the AppenderAttachable interface.
log4cplus::spi::LoggerImpl::getLogLevel
LogLevel getLogLevel() const
Returns the assigned LogLevel, if any, for this Logger.
Definition loggerimpl.h:111
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::setAdditivity
void setAdditivity(bool additive)
Set the additivity flag for this Logger instance.
log4cplus::spi::LoggerImpl::getAdditivity
bool getAdditivity() const
Get the additivity flag for this Logger instance.
log4cplus::spi::LoggerImpl::Hierarchy
friend class log4cplus::Hierarchy
Definition loggerimpl.h:208
log4cplus::spi::LoggerImpl::SharedLoggerImplPtr
helpers::SharedObjectPtr< LoggerImpl > SharedLoggerImplPtr
Definition loggerimpl.h:56
log4cplus::spi::LoggerImpl::LoggerImpl
LoggerImpl(const log4cplus::tstring &name, Hierarchy &h)
This constructor created a new Logger instance and sets its name.
log4cplus::spi::LoggerImpl::getHierarchy
virtual Hierarchy & getHierarchy() const
Return the the Hierarchy where this Logger instance is attached.
log4cplus::spi::LoggerImpl::forcedLog
virtual void forcedLog(spi::InternalLoggingEvent const &ev)
log4cplus::spi::LoggerImpl::ll
LogLevel ll
The assigned LogLevel of this logger.
Definition loggerimpl.h:177
log4cplus::spi::LoggerImpl::parent
SharedLoggerImplPtr parent
The parent of this logger.
Definition loggerimpl.h:183
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::LoggerImpl::~LoggerImpl
virtual ~LoggerImpl()
log4cplus::spi::LoggerImpl::callAppenders
virtual void callAppenders(const InternalLoggingEvent &event)
Call the appenders in the hierrachy starting at this.
log4cplus::spi::LoggerImpl::getName
log4cplus::tstring const & getName() const
Return the logger name.
Definition loggerimpl.h:127
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::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::log
virtual void log(spi::InternalLoggingEvent const &)
log4cplus::spi::LoggerImpl::setLogLevel
void setLogLevel(LogLevel _ll)
Set the LogLevel of this Logger.
Definition loggerimpl.h:116
log4cplus::spi::LoggerImpl::name
log4cplus::tstring name
The name of this logger.
Definition loggerimpl.h:172
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.
config.hxx
loggerfactory.h
log4cplus::spi
Definition layout.h:62
log4cplus::spi::SharedLoggerImplPtr
LoggerImpl::SharedLoggerImplPtr SharedLoggerImplPtr
Definition loggerimpl.h:211
log4cplus
Definition appender.h:46
log4cplus::tstring
std::basic_string< tchar > tstring
Definition tstring.h:39
log4cplus::LogLevel
int LogLevel
Defines the minimum set of priorities recognized by the system, that is FATAL_LOG_LEVEL,...
Definition loglevel.h:48
pointer.h
tstring.h
LOG4CPLUS_EXPORT
#define LOG4CPLUS_EXPORT
Definition win32.h:141