/******************************************************************************
*
* This file is part of Log4Qt library.
*
* Copyright (C) 2007 - 2020 Log4Qt contributors
*
* 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 LOG4QT_H
#define LOG4QT_H
#include "log4qtshared.h"
/*!
* \page Log4Qt/Log4j
*
* %Log4Qt is a C++ port of the Apache Software Foundation Log4j package
* using the Qt Framework.
*
* The documentation describes classes and methods that have been added or
* changed compared to Log4j.
*
* The following sections are describing the implementation in more detail:
* - \ref Changes "Differences to Log4j"
* - \ref Ownership "Object ownership"
* - \ref LogLog "Logging within the package"
* - \ref Init "Initialization procedure"
* - \ref Env "Environment Variables"
* - \ref Undocumented "Undocumented functions"
* - \ref Assumptions "Assumptions"
*
*/
/*!
* \page Changes Differences to Log4j
*
* The following fundamental differences exist between %Log4Qt and Log4j:
*
* - As a JAVA package Log4j does not have to manage object ownership and
* lifetime in the same way then it is required in C++. For details on
* how object ownership is handled see \ref Ownership "Object ownership".
* - The package uses itself for its internal logging similar to Log4j 1.3.
* For details see \ref LogLog "Logging within the package".
* - The configuration using system properties was replaced with a combination
* of environment variables and application settings. For details see
* \ref Env "Environment Variables".
* - Custom levels are not supported.
* - Multiple Logger Repositories are not supported
*
* The following classes have been changed:
*
* - \ref Log4Qt::AppenderSkeleton "AppenderSkeleton"
* - The procedure of checking, if logging is possible, originally used by
* \ref Log4Qt::WriterAppender "WriterAppender" was generalised and is used
* in \ref Log4Qt::AppenderSkeleton "AppenderSkeleton" and derived classes
* (\ref Log4Qt::AppenderSkeleton::checkEntryConditions() "checkEntryConditions()").
* - The \ref Log4Qt::AppenderSkeleton::doAppend() "doAppend()" member function will
* check the entry conditions by calling the sub-class specific
* \ref Log4Qt::AppenderSkeleton::checkEntryConditions() "checkEntryConditions()".
* If successful the sub-class specific
* \ref Log4Qt::AppenderSkeleton::append() "append()" function is called.
*
* - Configurator
* - Configure functions return a boolean indicating, if the configuration
* was successful.
* - Configure errors are accessible over
* \ref Log4Qt::ConfiguratorHelper::configureError()
* "ConfiguratorHelper::configureError()".
* - Watching for configuration file changes is a function performed
* centrally by the \ref Log4Qt::ConfiguratorHelper "ConfiguratorHelper".
* The class provides Q_SIGNALS to notify on configuration change and errors.
* - The class \ref Log4Qt::PropertyConfigurator "PropertyConfigurator" was
* extended to be able to read configuration data from a QSettings object.
*
* - \ref Log4Qt::Level "Level"
* - A new value \ref Log4Qt::Level::NULL_INT "Level::NULL_INT" was
* introduced to indicate there is no level set.
*
* - \ref Log4Qt::Logger "Logger"
* - The method \ref Log4Qt::Logger::isEnabledFor() "isEnabledFor()"
* does also take the repository threshold into account.
* - Several overloaded convenience member function are available to log
* messages with arguments of different types.
* - Two macros, \ref Log4Qt::LOG4QT_DECLARE_STATIC_LOGGER "LOG4QT_DECLARE_STATIC_LOGGER"
* and \ref Log4Qt::LOG4QT_DECLARE_QCLASS_LOGGER "LOG4QT_DECLARE_QCLASS_LOGGER",
* allows retrieving and caching of a pointer to a logger object.
*
* - \ref Log4Qt::LogManager "LogManager"
* - A QtMessage handler can be installed via
* \ref Log4Qt::LogManager::setHandleQtMessages() "setHandleQtMessages()",
* to redirect all messages created by calls to qDebug(), qWarning(),
* qCritical() and qFatal() to a logger. The logger is named Qt and can be
* accessed using \ref Log4Qt::LogManager::qtLogger() "qtLogger()".
* - The initialisation procedure is available over a public method
* (\ref Log4Qt::LogManager::startup() "startup()").
* - The LogManager provides access to the logger used internally by the
* package (\ref Log4Qt::LogManager::logLogger() "logLogger()") and to
* its default initialisation procedure
* (\ref Log4Qt::LogManager::configureLogLogger() "configureLogLogger()").
*
* - \ref Log4Qt::WriterAppender "WriterAppender"
* - The class will call \ref Log4Qt::WriterAppender::handleIoErrors()
* "handleIoErrors()" after all I/O operations. Sub-classes should
* re-implement the function to handle errors.
*
* - \ref Log4Qt::RollingFileAppender "RollingFileAppender"*
* - The class behaves different to the log4/log4cpp implementation
* on application restart the existing log files are rolled if
* appendFile is set to false to avoid data loss.
*
* The following classes have been added:
*
* - An additional appender class, \ref Log4Qt::DebugAppender "DebugAppender",
* was added. The class appends logging events to the platform specific debug
* output.
* - Various helper class have been introduced:
* - \ref Log4Qt::ClassLogger "ClassLogger": The class ClassLogger provides
* logging for a QObject derived class.
* - \ref Log4Qt::ConfiguratorHelper "ConfiguratorHelper": The class
* ConfiguratorHelper provides a configuration file watch and last error
* for configurator classes.
* - \ref Log4Qt::DateTime "DateTime": The class DateTime provides extended
* functionality for QDateTime.
* - \ref Log4Qt::LogError "LogError": The class LogError represents an error.
* - \ref Log4Qt::Factory "Factory": The class Factory provides factories
* for Appender, Filter and Layout objects.
* - \ref Log4Qt::InitialisationHelper "InitialisationHelper": The class
* InitialisationHelper performs static initialisation tasks.
* - \ref Log4Qt::PatternFormatter "PatternFormatter": The class
* PatternFormatter formats a logging event based on a pattern string.
* - \ref Log4Qt::Properties "Properties": The class Properties implements a
* JAVA property hash.
*/
/*!
* \page Ownership Object ownership
*
* In difference to the JAVA Log4j package %Log4Qt must manage ownership and
* lifetime of the objects used. This is non trivial as objects are created
* and used in different ways.
*
* In general an object can be created explicitly for example an application
* may create Loggers, Appenders and Layouts during creation of a QApplication
* object. But they can also be automatically created by the package on
* startup using a \ref Log4Qt::PropertyConfigurator "PropertyConfigurator"
* configuration file. Objects may also be created the one way and then used
* the other. Object may be used by multiple other objects. A Layout for example
* may be used by multiple Appenders. Objects are also created from multiple
* threads. The creation may happen during static initialisation and the
* de
评论0