Update of /cvsroot/objecthandler/log4cxx-0.9.7/include/log4cxx
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv25784/include/log4cxx
Added Files:
Makefile.am appender.h appenderskeleton.h asyncappender.h
autolink.hpp basicconfigurator.h config.h config_auto.h.in
config_msvc.h consoleappender.h dailyrollingfileappender.h
defaultcategoryfactory.h fileappender.h hierarchy.h
htmllayout.h layout.h level.h logger.h logmanager.h mdc.h
ndc.h patternlayout.h propertyconfigurator.h provisionnode.h
rollingfileappender.h simplelayout.h ttcclayout.h
writerappender.h
Log Message:
--- NEW FILE: autolink.hpp ---
/*
Copyright (C) 2006 Ferdinando Ametrano
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it under the
terms of the QuantLib license. You should have received a copy of the
license along with this program; if not, please email qua...@li...
The license is also available online at http://quantlib.org/html/license.html
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/
#ifndef log4cxx_autolink_hpp
#define log4cxx_autolink_hpp
// select toolset:
#if (_MSC_VER < 1200)
# error "unsupported Microsoft compiler"
#elif (_MSC_VER == 1200)
# define LOG4CXX_LIB_TOOLSET "vc6"
#elif (_MSC_VER == 1300)
# define LOG4CXX_LIB_TOOLSET "vc7"
#elif (_MSC_VER == 1310)
# define LOG4CXX_LIB_TOOLSET "vc71"
#elif (_MSC_VER == 1400)
# define LOG4CXX_LIB_TOOLSET "vc80"
#else
# error "unknown Microsoft compiler"
#endif
/*** libraries to be linked ***/
// select thread opt:
#ifdef _MT
# define LOG4CXX_LIB_THREAD_OPT "-mt"
#else
# define LOG4CXX_LIB_THREAD_OPT
#endif
// select linkage opt:
#ifdef _DLL
# if defined(_DEBUG)
# define LOG4CXX_LIB_RT_OPT "-gd"
# else
# define LOG4CXX_LIB_RT_OPT
# endif
#else
# if defined(_DEBUG)
# define LOG4CXX_LIB_RT_OPT "-sgd"
# else
# define LOG4CXX_LIB_RT_OPT "-s"
# endif
#endif
#define LOG4CXX_LIB_NAME "log4cxxs-" LOG4CXX_LIB_TOOLSET LOG4CXX_LIB_THREAD_OPT LOG4CXX_LIB_RT_OPT ".lib"
#pragma comment(lib, LOG4CXX_LIB_NAME)
//#ifdef BOOST_LIB_DIAGNOSTIC
# pragma message("Linking to lib file: " LOG4CXX_LIB_NAME)
//#endif
#endif
--- NEW FILE: fileappender.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* 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 _LOG4CXX_FILE_APPENDER_H
#define _LOG4CXX_FILE_APPENDER_H
#include <log4cxx/config.h>
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/writerappender.h>
#include <fstream>
namespace log4cxx
{
class FileAppender;
typedef helpers::ObjectPtrT<FileAppender> FileAppenderPtr;
/**
* FileAppender appends log events to a file.
*
* <p>Support for <code>java.io.Writer</code> and console appending
* has been deprecated and then removed. See the replacement
* solutions: WriterAppender and ConsoleAppender.
*/
class LOG4CXX_EXPORT FileAppender : public WriterAppender
{
protected:
/** Append to or truncate the file? The default value for this
variable is <code>true</code>, meaning that by default a
<code>FileAppender</code> will append to an existing file and
not truncate it.
<p>This option is meaningful only if the FileAppender opens the
file.
*/
bool fileAppend;
/**
The name of the log file. */
String fileName;
/**
Do we do bufferedIO? */
bool bufferedIO;
/**
How big should the IO buffer be? Default is 8K. */
int bufferSize;
#ifdef UNICODE
std::wofstream ofs;
#else
std::ofstream ofs;
#endif
public:
DECLARE_LOG4CXX_OBJECT(FileAppender)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(FileAppender)
LOG4CXX_CAST_ENTRY_CHAIN(WriterAppender)
END_LOG4CXX_CAST_MAP()
/**
The default constructor does not do anything.
*/
FileAppender();
/**
Instantiate a <code>FileAppender</code> and open the file
designated by <code>filename</code>. The opened filename will
become the output destination for this appender.
<p>If the <code>append</code> parameter is true, the file will be
appended to. Otherwise, the file designated by
<code>filename</code> will be truncated before being opened.
<p>If the <code>bufferedIO</code> parameter is <code>true</code>,
then buffered IO will be used to write to the output file.
*/
FileAppender(const LayoutPtr& layout, const String& filename, bool append,
bool bufferedIO, int bufferSize);
/**
Instantiate a FileAppender and open the file designated by
<code>filename</code>. The opened filename will become the output
destination for this appender.
<p>If the <code>append</code> parameter is true, the file will be
appended to. Otherwise, the file designated by
<code>filename</code> will be truncated before being opened.
*/
FileAppender(const LayoutPtr& layout, const String& filename, bool append);
/**
Instantiate a FileAppender and open the file designated by
<code>filename</code>. The opened filename will become the output
destination for this appender.
<p>The file will be appended to. */
FileAppender(const LayoutPtr& layout, const String& filename);
~FileAppender();
/**
The <b>File</b> property takes a string value which should be the
name of the file to append to.
<p><b>Note that the special values
"System.out" or "System.err" are no longer honored.</b>
<p>Note: Actual opening of the file is made when
#activateOptions is called, not when the options are set. */
void setFile(const String& file);
/**
Sets and <i>opens</i> the file where the log output will
go. The specified file must be writable.
<p>If there was already an opened file, then the previous file
is closed first.
<p><b>Do not use this method directly. To configure a FileAppender
or one of its subclasses, set its properties one by one and then
call activateOptions.</b>
@param file The path to the log file.
@param append If true will append to fileName. Otherwise will
truncate fileName.
@param bufferedIO Do we do bufferedIO?
@param bufferSize How big should the IO buffer be?
*/
void setFile(const String& file, bool append,
bool bufferedIO, int bufferSize);
/**
Returns the value of the <b>Append</b> option.
*/
inline bool getAppend() const { return fileAppend; }
/** Returns the value of the <b>File</b> option. */
inline const String& getFile() const { return fileName; }
/**
<p>Sets and <i>opens</i> the file where the log output will
go. The specified file must be writable.
<p>If there was already an opened file, then the previous file
is closed first.*/
void activateOptions();
void setOption(const String& option,
const String& value);
protected:
/**
Closes the previously opened file.
*/
virtual void closeWriter();
/**
Closes the previously opened file.
*/
void closeFile();
public:
/**
Get the value of the <b>BufferedIO</b> option.
<p>BufferedIO will significatnly increase performance on heavily
loaded systems.
*/
inline bool getBufferedIO() const { return bufferedIO; }
/**
Get the size of the IO buffer.
*/
inline int getBufferSize() const { return bufferSize; }
/**
The <b>Append</b> option takes a boolean value. It is set to
<code>true</code> by default. If true, then <code>File</code>
will be opened in append mode by #setFile (see
above). Otherwise, setFile will open
<code>File</code> in truncate mode.
<p>Note: Actual opening of the file is made when
#activateOptions is called, not when the options are set.
*/
inline void setAppend(bool fileAppend)
{ this->fileAppend = fileAppend; }
/**
The <b>BufferedIO</b> option takes a boolean value. It is set to
<code>false</code> by default. If true, then <code>File</code>
will be opened in buffered mode.
BufferedIO will significantly increase performance on heavily
loaded systems.
*/
void setBufferedIO(bool bufferedIO);
/**
Set the size of the IO buffer.
*/
void setBufferSize(int bufferSize) { this->bufferSize = bufferSize; }
}; // class FileAppender
} // namespace log4cxx
#endif
--- NEW FILE: basicconfigurator.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* 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 _LOG4CXX_BASIC_CONFIGURATOR_H
#define _LOG4CXX_BASIC_CONFIGURATOR_H
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/config.h>
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/spi/configurator.h>
#include <map>
namespace log4cxx
{
class Appender;
typedef helpers::ObjectPtrT<Appender> AppenderPtr;
/**
Use this class to quickly configure the package.
<p>For file based configuration see
PropertyConfigurator. For XML based configuration see
DOMConfigurator.
*/
class LOG4CXX_EXPORT BasicConfigurator
{
protected:
BasicConfigurator() {}
public:
/**
Add a ConsoleAppender that uses PatternLayout
using the PatternLayout#TTCC_CONVERSION_PATTERN and
prints to <code>stdout</code> to the root logger.*/
static void configure();
/**
Add <code>appender</code> to the root logger.
@param appender The appender to add to the root logger.
*/
static void configure(const AppenderPtr& appender);
/**
Reset the default hierarchy to its defaut. It is equivalent to
calling
<code>Logger::getDefaultHierarchy()->resetConfiguration()</code>.
See Hierarchy#resetConfiguration() for more details. */
static void resetConfiguration();
}; // class BasicConfigurator
} // namespace log4cxx
#endif //_LOG4CXX_BASIC_CONFIGURATOR_H
--- NEW FILE: propertyconfigurator.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* 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 _LOG4CXX_PROPERTY_CONFIGURATOR_H
#define _LOG4CXX_PROPERTY_CONFIGURATOR_H
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/config.h>
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/spi/configurator.h>
#include <map>
namespace log4cxx
{
class Logger;
typedef helpers::ObjectPtrT<Logger> LoggerPtr;
class Appender;
typedef helpers::ObjectPtrT<Appender> AppenderPtr;
namespace spi
{
class LoggerFactory;
typedef helpers::ObjectPtrT<LoggerFactory> LoggerFactoryPtr;
class LoggerRepository;
typedef helpers::ObjectPtrT<LoggerRepository> LoggerRepositoryPtr;
}
namespace helpers
{
class Properties;
}
/**
Allows the configuration of log4cxx from an external file. See
<b>{@link #doConfigure(const String&, spi::LoggerRepositoryPtr&)}</b>
for the expected format.
<p>It is sometimes useful to see how log4cxx is reading configuration
files. You can enable log4cxx internal logging by defining the
<b>log4j.debug</b> variable.
<P>At class initialization time class,
the file <b>log4j.properties</b> will be searched in the current directory.
If the file can be found, then it will
be fed to the
{@link PropertyConfigurator#configure(const String& configFilename)}
method.
<p>The <code>PropertyConfigurator</code> does not handle the
advanced configuration features supported by the {@link
xml::DOMConfigurator DOMConfigurator} such as
support for {@link spi::Filter Filters}, custom
{@link spi::ErrorHandler ErrorHandlers}, nested
appenders such as the {@link AsyncAppender
AsyncAppender}, etc.
<p>All option <em>values</em> admit variable substitution. The
syntax of variable substitution is similar to that of Unix
shells. The string between an opening <b>"${"</b> and
closing <b>"}"</b> is interpreted as a key. The value of
the substituted variable can be defined as a system property or in
the configuration file itself. The value of the key is first
searched in the system properties, and if not found there, it is
then searched in the configuration file being parsed. The
corresponding value replaces the ${variableName} sequence. For
example, if <code>java.home</code> system property is set to
<code>/home/xyz</code>, then every occurrence of the sequence
<code>${java.home}</code> will be interpreted as
<code>/home/xyz</code>.
*/
class LOG4CXX_EXPORT PropertyConfigurator :
virtual public spi::Configurator,
virtual public helpers::ObjectImpl
{
protected:
static String CATEGORY_PREFIX;
static String LOGGER_PREFIX;
static String FACTORY_PREFIX;
static String ADDITIVITY_PREFIX;
static String ROOT_CATEGORY_PREFIX;
static String ROOT_LOGGER_PREFIX;
static String APPENDER_PREFIX;
static String RENDERER_PREFIX;
static String THRESHOLD_PREFIX;
/* Key for specifying the {@link spi::LoggerFactory
LoggerFactory}. Currently set to "<code>log4j.loggerFactory</code>". */
static String LOGGER_FACTORY_KEY;
static String INTERNAL_ROOT_NAME;
/**
Used internally to keep track of configured appenders.
*/
std::map<String, AppenderPtr> registry;
spi::LoggerFactoryPtr loggerFactory;
public:
DECLARE_LOG4CXX_OBJECT(PropertyConfigurator)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(spi::Configurator)
END_LOG4CXX_CAST_MAP()
PropertyConfigurator();
/**
Read configuration from a file. <b>The existing configuration is
not cleared nor reset.</b> If you require a different behavior,
then call {@link LogManager#resetConfiguration
resetConfiguration} method before calling
<code>doConfigure</code>.
<p>The configuration file consists of statements in the format
<code>key=value</code>. The syntax of different configuration
elements are discussed below.
<h3>Repository-wide threshold</h3>
<p>The repository-wide threshold filters logging requests by level
regardless of logger. The syntax is:
<pre>
log4j.threshold=[level]
</pre>
<p>The level value can consist of the string values OFF, FATAL,
ERROR, WARN, INFO, DEBUG, ALL or a <em>custom level</em> value. A
custom level value can be specified in the form
level#classname. By default the repository-wide threshold is set
to the lowest possible value, namely the level <code>ALL</code>.
</p>
<h3>Appender configuration</h3>
<p>Appender configuration syntax is:
<pre>
# For appender named <i>appenderName</i>, set its class.
# Note: The appender name can contain dots.
log4j.appender.appenderName=fully.qualified.name.of.appender.class
# Set appender specific options.
log4j.appender.appenderName.option1=value1
...
log4j.appender.appenderName.optionN=valueN
</pre>
For each named appender you can configure its {@link Layout Layout}. The
syntax for configuring an appender's layout is:
<pre>
log4j.appender.appenderName.layout=fully.qualified.name.of.layout.class
log4j.appender.appenderName.layout.option1=value1
....
log4j.appender.appenderName.layout.optionN=valueN
</pre>
<h3>Configuring loggers</h3>
<p>The syntax for configuring the root logger is:
<pre>
log4j.rootLogger=[level], appenderName, appenderName, ...
</pre>
<p>This syntax means that an optional <em>level</em> can be
supplied followed by appender names separated by commas.
<p>The level value can consist of the string values OFF, FATAL,
ERROR, WARN, INFO, DEBUG, ALL or a <em>custom level</em> value. A
custom level value can be specified in the form
<code>level#classname</code>.
<p>If a level value is specified, then the root level is set
to the corresponding level. If no level value is specified,
then the root level remains untouched.
<p>The root logger can be assigned multiple appenders.
<p>Each <i>appenderName</i> (separated by commas) will be added to
the root logger. The named appender is defined using the
appender syntax defined above.
<p>For non-root categories the syntax is almost the same:
<pre>
log4j.logger.logger_name=[level|INHERITED|NULL], appenderName, appenderName,
...
</pre>
<p>The meaning of the optional level value is discussed above
in relation to the root logger. In addition however, the value
INHERITED can be specified meaning that the named logger should
inherit its level from the logger hierarchy.
<p>If no level value is supplied, then the level of the
named logger remains untouched.
<p>By default categories inherit their level from the
hierarchy. However, if you set the level of a logger and later
decide that that logger should inherit its level, then you should
specify INHERITED as the value for the level value. NULL is a
synonym for INHERITED.
<p>Similar to the root logger syntax, each <i>appenderName</i>
(separated by commas) will be attached to the named logger.
<p>See the <a href="../../../../manual.html#additivity">appender
additivity rule</a> in the user manual for the meaning of the
<code>additivity</code> flag.
<h3>Logger Factories</h3>
The usage of custom logger factories is discouraged and no longer
documented.
<h3>Example</h3>
<p>An example configuration is given below. Other configuration
file examples are given in the <code>examples</code> folder.
<pre>
# Set options for appender named "A1".
# Appender "A1" will be a SyslogAppender
log4j.appender.A1=SyslogAppender
# The syslog daemon resides on www.abc.net
log4j.appender.A1.SyslogHost=www.abc.net
# A1's layout is a PatternLayout, using the conversion pattern
# <b>%r %-5p %c{2} %M.%L %x - %m\n</b>. Thus, the log output will
# include # the relative time since the start of the application in
# milliseconds, followed by the level of the log request,
# followed by the two rightmost components of the logger name,
# followed by the callers method name, followed by the line number,
# the nested disgnostic context and finally the message itself.
# Refer to the documentation of PatternLayout for further information
# on the syntax of the ConversionPattern key.
log4j.appender.A1.layout=PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r %-5p %c{2} %M.%L %x - %m\n
# Set options for appender named "A2"
# A2 should be a RollingFileAppender, with maximum file size of 10 MB
# using at most one backup file. A2's layout is TTCC, using the
# ISO8061 date format with context printing enabled.
log4j.appender.A2=RollingFileAppender
log4j.appender.A2.MaxFileSize=10MB
log4j.appender.A2.MaxBackupIndex=1
log4j.appender.A2.layout=TTCCLayout
log4j.appender.A2.layout.ContextPrinting=enabled
log4j.appender.A2.layout.DateFormat=ISO8601
# Root logger set to DEBUG using the A2 appender defined above.
log4j.rootLogger=DEBUG, A2
# Logger definitions:
# The SECURITY logger inherits is level from root. However, it's output
# will go to A1 appender defined above. It's additivity is non-cumulative.
log4j.logger.SECURITY=INHERIT, A1
log4j.additivity.SECURITY=false
# Only warnings or above will be logged for the logger "SECURITY.access".
# Output will go to A1.
log4j.logger.SECURITY.access=WARN
# The logger "class.of.the.day" inherits its level from the
# logger hierarchy. Output will go to the appender's of the root
# logger, A2 in this case.
log4j.logger.class.of.the.day=INHERIT
</pre>
<p>Refer to the <b>setOption</b> method in each Appender and
Layout for class specific options.
<p>Use the <code>#</code> or <code>!</code> characters at the
beginning of a line for comments.
<p>
@param configFileName The name of the configuration file where the
configuration information is stored.
@param hierarchy The hierarchy to operation upon.
*/
void doConfigure(const String& configFileName,
spi::LoggerRepositoryPtr& hierarchy);
/**
Read configuration options from file <code>configFilename</code>.
*/
static void configure(const String& configFilename);
/**
Like {@link #configureAndWatch(const String& configFilename, long delay)}
except that the
default delay as defined by helpers::FileWatchdog#DEFAULT_DELAY
is used.
@param configFilename A file in key=value format.
*/
static void configureAndWatch(const String& configFilename);
/**
Read the configuration file <code>configFilename</code> if it
exists. Moreover, a thread will be created that will periodically
check if <code>configFilename</code> has been created or
modified. The period is determined by the <code>delay</code>
argument. If a change or file creation is detected, then
<code>configFilename</code> is read to configure log4j.
@param configFilename A file in key=value format.
@param delay The delay in milliseconds to wait between each check.
*/
static void configureAndWatch(const String& configFilename,
long delay);
/**
Read configuration options from <code>properties</code>.
See #doConfigure(const string&, spi::LoggerRepositoryPtr&)
for the expected format.
*/
static void configure(helpers::Properties& properties);
/**
Read configuration options from <code>properties</code>.
See #doConfigure(const String&, spi::LoggerRepositoryPtr&)
for the expected format.
*/
void doConfigure(helpers::Properties& properties,
spi::LoggerRepositoryPtr& hierarchy);
// --------------------------------------------------------------------------
// Internal stuff
// --------------------------------------------------------------------------
protected:
/**
Check the provided <code>Properties</code> object for a
#LoggerFactory
entry specified by #LOGGER_FACTORY_KEY. If such an entry
exists, an attempt is made to create an instance using the default
constructor. This instance is used for subsequent Logger creations
within this configurator.
@see #parseCatsAndRenderers
*/
void configureLoggerFactory(helpers::Properties& props);
void configureRootCategory(helpers::Properties& props,
spi::LoggerRepositoryPtr& hierarchy);
/**
Parse non-root elements, such non-root categories and renderers.
*/
void parseCatsAndRenderers(helpers::Properties& props,
spi::LoggerRepositoryPtr& hierarchy);
/**
Parse the additivity option for a non-root logger.
*/
void parseAdditivityForLogger(helpers::Properties& props,
LoggerPtr& cat, const String& loggerName);
/**
This method must work for the root logger as well.
*/
void parseCategory(
helpers::Properties& props, LoggerPtr& logger,
const String& optionKey, const String& loggerName,
const String& value);
AppenderPtr parseAppender(
helpers::Properties& props, const String& appenderName);
void registryPut(const AppenderPtr& appender);
AppenderPtr registryGet(const String& name);
}; // class PropertyConfigurator
} // namespace log4cxx
#endif //_LOG4CXX_PROPERTY_CONFIGURATOR_H
--- NEW FILE: defaultcategoryfactory.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* 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 _LOG4CXX_DEFAULT_CATEGORY_FACTORY_H
#define _LOG4CXX_DEFAULT_CATEGORY_FACTORY_H
#include <log4cxx/spi/loggerfactory.h>
#include <log4cxx/helpers/objectimpl.h>
namespace log4cxx
{
class Logger;
typedef helpers::ObjectPtrT<Logger> LoggerPtr;
class LOG4CXX_EXPORT DefaultCategoryFactory :
public virtual spi::LoggerFactory,
public virtual helpers::ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(DefaultCategoryFactory)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(spi::LoggerFactory)
END_LOG4CXX_CAST_MAP()
virtual LoggerPtr makeNewLoggerInstance(const String& name);
};
} // namespace log4cxx
#endif //_LOG4CXX_DEFAULT_CATEGORY_FACTORY_H
--- NEW FILE: config_msvc.h ---
/* Name of package */
#define PACKAGE "log4cxx"
/* Version number of package */
#define VERSION "0.9.6"
/* Define to 1 if you have the `ftime' function. */
#define HAVE_FTIME 1
/* ODBC support through Microsoft ODBC. */
#define HAVE_MS_ODBC 1
/* thread support through Microsoft threads. */
#define HAVE_MS_THREAD 1
/* XML support through Microsoft XML. */
#define HAVE_MS_XML 1
/* ODBC support */
#define HAVE_ODBC 1
/* thread support */
#define HAVE_THREAD 1
/* XML support */
#define HAVE_XML 1
typedef __int64 int64_t;
#ifdef WIN32
#pragma warning(disable : 4250 4251 4786 4290)
#endif
#ifdef LOG4CXX_STATIC
#define LOG4CXX_EXPORT
// cf. file msvc/static/static.cpp
#pragma comment(linker, "/include:?ForceSymbolReferences@@YAXXZ")
#else // DLL
#ifdef LOG4CXX
#define LOG4CXX_EXPORT __declspec(dllexport)
#else
#define LOG4CXX_EXPORT __declspec(dllimport)
#endif
#endif
#define _WIN32_WINNT 0x0400
--- NEW FILE: appender.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* 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 _LOG4CXX_APPENDER_H
#define _LOG4CXX_APPENDER_H
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/object.h>
#include <vector>
#include <log4cxx/spi/optionhandler.h>
namespace log4cxx
{
// Forward declarations
namespace spi
{
class LoggingEvent;
typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr;
class Filter;
typedef helpers::ObjectPtrT<Filter> FilterPtr;
class ErrorHandler;
typedef log4cxx::helpers::ObjectPtrT<ErrorHandler> ErrorHandlerPtr;
}
class Layout;
typedef log4cxx::helpers::ObjectPtrT<Layout> LayoutPtr;
class Appender;
typedef log4cxx::helpers::ObjectPtrT<Appender> AppenderPtr;
typedef std::vector<AppenderPtr> AppenderList;
/**
Implement this interface for your own strategies for outputting log
statements.
*/
class LOG4CXX_EXPORT Appender :
public virtual spi::OptionHandler
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Appender)
virtual ~Appender() {}
/**
Add a filter to the end of the filter list.
*/
virtual void addFilter(const spi::FilterPtr& newFilter) = 0;
/**
Returns the head Filter. The Filters are organized in a linked list
and so all Filters on this Appender are available through the result.
@return the head Filter or null, if no Filters are present
*/
virtual const spi::FilterPtr& getFilter() const = 0;
/**
Clear the list of filters by removing all the filters in it.
*/
virtual void clearFilters() = 0;
/**
Release any resources allocated within the appender such as file
handles, network connections, etc.
<p>It is a programming error to append to a closed appender.
*/
virtual void close() = 0;
/**
Log in <code>Appender</code> specific way. When appropriate,
Loggers will call the <code>doAppend</code> method of appender
implementations in order to log.
*/
virtual void doAppend(const spi::LoggingEventPtr& event) = 0;
/**
Get the name of this appender. The name uniquely identifies the
appender.
*/
virtual const String& getName() const = 0;
/**
Set the {@link spi::ErrorHandler ErrorHandler} for this appender.
*/
virtual void setErrorHandler(const spi::ErrorHandlerPtr& errorHandler) = 0;
/**
Returns the {@link spi::ErrorHandler ErrorHandler} for this appender.
*/
virtual const spi::ErrorHandlerPtr& getErrorHandler() const = 0;
/**
Set the Layout for this appender.
*/
virtual void setLayout(const LayoutPtr& layout) = 0;
/**
Returns this appenders layout.
*/
virtual const LayoutPtr& getLayout() const = 0;
/**
Set the name of this appender. The name is used by other
components to identify this appender.
*/
virtual void setName(const String& name) = 0;
/**
Configurators call this method to determine if the appender
requires a layout. If this method returns <code>true</code>,
meaning that layout is required, then the configurator will
configure an layout using the configuration information at its
disposal. If this method returns <code>false</code>, meaning that
a layout is not required, then layout configuration will be
skipped even if there is available layout configuration
information at the disposal of the configurator..
<p>In the rather exceptional case, where the appender
implementation admits a layout but can also work without it, then
the appender should return <code>true</code>.
*/
virtual bool requiresLayout() const = 0;
};
}
#endif //_LOG4CXX_APPENDER_H
--- NEW FILE: simplelayout.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* 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 _LOG4CXX_SIMPLE_LAYOUT_H
#define _LOG4CXX_SIMPLE_LAYOUT_H
#include <log4cxx/layout.h>
namespace log4cxx
{
class SimpleLayout;
typedef helpers::ObjectPtrT<SimpleLayout> SimpleLayoutPtr;
/**
SimpleLayout consists of the level of the log statement,
followed by " - " and then the log message itself. For example,
<pre>
DEBUG - Hello world
</pre>
<p>
<p>PatternLayout offers a much more powerful alternative.
*/
class LOG4CXX_EXPORT SimpleLayout : public Layout
{
public:
DECLARE_LOG4CXX_OBJECT(SimpleLayout)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(SimpleLayout)
LOG4CXX_CAST_ENTRY_CHAIN(Layout)
END_LOG4CXX_CAST_MAP()
/**
Returns the log statement in a format consisting of the
<code>level</code>, followed by " - " and then the
<code>message</code>. For example, <pre> INFO - "A message"
</pre>
<p>The <code>category</code> parameter is ignored.
<p>
@return A byte array in SimpleLayout format.
*/
virtual void format(ostream& output, const spi::LoggingEventPtr& event) const;
/**
The SimpleLayout does not handle the throwable contained within
{@link spi::LoggingEvent LoggingEvents}. Thus, it returns
<code>true</code>.
*/
bool ignoresThrowable() const { return true; }
virtual void activateOptions() {}
virtual void setOption(const String& option, const String& value) {}
};
} // namespace log4cxx
#endif //_LOG4CXX_SIMPLE_LAYOUT_H
--- NEW FILE: logger.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* 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 _LOG4CXX_LOGGER_H
#define _LOG4CXX_LOGGER_H
#include <log4cxx/config.h>
#include <vector>
#include <log4cxx/helpers/appenderattachableimpl.h>
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/level.h>
#include <log4cxx/spi/loggerfactory.h>
#include <log4cxx/spi/loggerrepository.h>
#include <log4cxx/helpers/resourcebundle.h>
namespace log4cxx
{
namespace spi
{
class LoggerFactory;
typedef helpers::ObjectPtrT<LoggerFactory> LoggerFactoryPtr;
class LoggerRepository;
typedef helpers::ObjectPtrT<LoggerRepository> LoggerRepositoryPtr;
}
class Logger;
/** smart pointer to a Logger class */
typedef helpers::ObjectPtrT<Logger> LoggerPtr;
/** vector of {@link Logger loggers} */
typedef std::vector<LoggerPtr> LoggerList;
/**
This is the central class in the log4cxx package. Most logging
operations, except configuration, are done through this class.
*/
class LOG4CXX_EXPORT Logger :
public virtual spi::AppenderAttachable,
public virtual helpers::ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Logger)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(Logger)
LOG4CXX_CAST_ENTRY(spi::AppenderAttachable)
END_LOG4CXX_CAST_MAP()
protected:
/**
The name of this logger.
*/
String name;
/**
The assigned level of this logger. The
<code>level</code> variable need not be assigned a value in
which case it is inherited form the hierarchy. */
LevelPtr level;
/**
The parent of this logger. All loggers have at least one
ancestor which is the root logger. */
LoggerPtr parent;
/** The resourceBundle for localized messages.
@see setResourceBundle, getResourceBundle
*/
helpers::ResourceBundlePtr resourceBundle;
/**
The fully qualified name of the Category class. See also the getFQCN
method.
*/
static String FQCN;
// Loggers need to know what Hierarchy they are in
spi::LoggerRepository * repository;
helpers::AppenderAttachableImplPtr aai;
/** Additivity is set to true by default, that is children inherit
the appenders of their ancestors by default. If this variable is
set to <code>false</code> 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 <code>false</code> too. See
the user manual for more details. */
bool additive;
protected:
friend class DefaultCategoryFactory;
/**
This constructor created a new <code>logger</code> instance and
sets its name.
<p>It is intended to be used by sub-classes only. You should not
create categories directly.
@param name The name of the logger.
*/
Logger(const String& name);
public:
~Logger();
/**
Add <code>newAppender</code> to the list of appenders of this
Logger instance.
<p>If <code>newAppender</code> is already in the list of
appenders, then it won't be added again.
*/
virtual void addAppender(const AppenderPtr& newAppender);
/**
If <code>assertion</code> parameter is <code>false</code>, then
logs <code>msg</code> as an #error statement.
@param assertion
@param msg The message to print if <code>assertion</code> is
false.
*/
void assertLog(bool assertion, const String& msg);
/**
Call the appenders in the hierrachy starting at
<code>this</code>. If no appenders could be found, emit a
warning.
<p>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.
@param event the event to log. */
void callAppenders(const spi::LoggingEventPtr& event);
/**
Close all attached appenders implementing the AppenderAttachable
interface.
*/
void closeNestedAppenders();
/**
Log a message string with the {@link Level#DEBUG DEBUG} level.
<p>This method first checks if this logger is <code>DEBUG</code>
enabled by comparing the level of this logger with the {@link
Level#DEBUG DEBUG} level. If this logger is
<code>DEBUG</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param message the message string to log.
@param file the file where the log statement was written.
@param line the line where the log statement was written.
*/
void debug(const String& message, const char* file=0, int line=-1);
/**
Log a message string with the {@link Level#ERROR ERROR} level.
<p>This method first checks if this logger is <code>ERROR</code>
enabled by comparing the level of this logger with the {@link
Level#ERROR ERROR} level. If this logger is
<code>ERROR</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param message the message string to log.
@param file the file where the log statement was written.
@param line the line where the log statement was written.
*/
void error(const String& message, const char* file=0, int line=-1);
/**
Log a message string with the {@link Level#FATAL FATAL} level.
<p>This method first checks if this logger is <code>FATAL</code>
enabled by comparing the level of this logger with the {@link
Level#FATAL FATAL} level. If this logger is
<code>FATAL</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param message the message string to log.
@param file the file where the log statement was written.
@param line the line where the log statement was written.
*/
void fatal(const String& message, const char* file=0, int line=-1);
/**
This method creates a new logging event and logs the event
without further checks.
@param level the level to log.
@param message the message string to log.
@param file the file where the log statement was written.
@param line the line where the log statement was written.
*/
void forcedLog(const LevelPtr& level, const String& message,
const char* file=0, int line=-1);
/**
This method creates a new logging event and logs the event
without further checks.
@param fqcn The fully qualified name of the calling logger class.
@param level the level to log.
@param message the message string to log.
@param file the file where the log statement was written.
@param line the line where the log statement was written.
*/
protected:
void forcedLog(const String& fqcn, const LevelPtr& level, const String& message,
const char* file=0, int line=-1);
/**
Get the additivity flag for this Logger instance.
*/
public:
bool getAdditivity() const;
/**
Get the appenders contained in this logger as an AppenderList.
If no appenders can be found, then an empty AppenderList
is returned.
@return AppenderList An collection of the appenders in this logger.*/
AppenderList getAllAppenders() const;
/**
Look for the appender named as <code>name</code>.
<p>Return the appender with that name if in the list. Return
<code>NULL</code> otherwise. */
AppenderPtr getAppender(const String& name) const;
/**
Starting from this logger, search the logger hierarchy for a
non-null level and return it.
<p>The Logger class is designed so that this method executes as
quickly as possible.
@throws RuntimeException if all levels are null in the hierarchy
*/
virtual const LevelPtr& getEffectiveLevel() const;
/**
Return the the LoggerRepository where this
<code>Logger</code> is attached.
*/
spi::LoggerRepositoryPtr getLoggerRepository() const;
/**
Return the logger name. */
inline const String& getName() const
{ return name; }
/**
Returns the parent of this logger. Note that the parent of a
given logger may change during the lifetime of the logger.
<p>The root logger will return <code>0</code>.
*/
const LoggerPtr& getParent() const;
/**
Returns the assigned Level, if any, for this Logger.
@return Level - the assigned Level, can be null.
*/
const LevelPtr& getLevel() const;
/**
Retrieve a logger by name.
*/
static LoggerPtr getLogger(const String& name);
/**
Retrieve the root logger.
*/
static LoggerPtr getRootLogger();
/**
Like #getLogger except that the type of logger
instantiated depends on the type returned by the
LoggerFactory#makeNewLoggerInstance method of the
<code>factory</code> parameter.
<p>This method is intended to be used by sub-classes.
@param name The name of the logger to retrieve.
@param factory A LoggerFactory implementation that will
actually create a new Instance.
*/
static LoggerPtr getLogger(const String& name,
spi::LoggerFactoryPtr factory);
/**
Return the <em>inherited</em> ResourceBundle for this logger.
This method walks the hierarchy to find the appropriate resource bundle.
It will return the resource bundle attached to the closest ancestor of
this logger, much like the way priorities are searched. In case there
is no bundle in the hierarchy then <code>NULL</code> is returned.
*/
helpers::ResourceBundlePtr getResourceBundle() const;
protected:
/**
Returns the string resource coresponding to <code>key</code> in this
category's inherited resource bundle.
If the resource cannot be found, then an {@link #error error} message
will be logged complaining about the missing resource.
@see #getResourceBundle.
*/
String getResourceBundleString(const String& key) const;
public:
/**
Log a message string with the {@link Level#INFO INFO} level.
<p>This method first checks if this logger is <code>INFO</code>
enabled by comparing the level of this logger with the {@link
Level#INFO INFO} level. If this logger is
<code>INFO</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param message the message string to log.
@param file the file where the log statement was written.
@param line the line where the log statement was written.
*/
void info(const String& message, const char* file=NULL, int line=-1);
/**
Is the appender passed as parameter attached to this category?
*/
bool isAttached(const AppenderPtr& appender) const;
/**
* Check whether this logger is enabled for the <code>DEBUG</code>
* Level.
*
* <p> This function is intended to lessen the computational cost of
* disabled log debug statements.
*
* <p> For some <code>logger</code> Logger object, when you write,
* <pre>
* logger->debug("debug message");
* </pre>
*
* <p>You incur the cost constructing the message, concatenation in
* this case, regardless of whether the message is logged or not.
*
* <p>If you are worried about speed, then you should write
* <pre>
* if(logger->isDebugEnabled()) {
* logger->debug("debug message");
* }
* </pre>
*
* <p>This way you will not incur the cost of parameter
* construction if debugging is disabled for <code>logger</code>. On
* the other hand, if the <code>logger</code> is debug enabled, you
* will incur the cost of evaluating whether the logger is debug
* enabled twice. Once in <code>isDebugEnabled</code> and once in
* the <code>debug</code>. This is an insignificant overhead
* since evaluating a logger takes about 1%% of the time it
* takes to actually log.
*
* @return bool - <code>true</code> if this logger is debug
* enabled, <code>false</code> otherwise.
* */
bool isDebugEnabled() const;
/**
Check whether this logger is enabled for a given
Level passed as parameter.
See also #isDebugEnabled.
@return bool True if this logger is enabled for <code>level</code>.
*/
bool isEnabledFor(const LevelPtr& level) const;
/**
Check whether this logger is enabled for the info Level.
See also #isDebugEnabled.
@return bool - <code>true</code> if this logger is enabled
for level info, <code>false</code> otherwise.
*/
bool isInfoEnabled() const;
/**
Check whether this logger is enabled for the warn Level.
See also #isDebugEnabled.
@return bool - <code>true</code> if this logger is enabled
for level warn, <code>false</code> otherwise.
*/
bool isWarnEnabled() const;
/**
Check whether this logger is enabled for the error Level.
See also #isDebugEnabled.
@return bool - <code>true</code> if this logger is enabled
for level error, <code>false</code> otherwise.
*/
bool isErrorEnabled() const;
/**
Check whether this logger is enabled for the fatal Level.
See also #isDebugEnabled.
@return bool - <code>true</code> if this logger is enabled
for level fatal, <code>false</code> otherwise.
*/
bool isFatalEnabled() const;
/**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resulting
pattern is formatted using helpers::StringHelper::format method with the user
supplied object array <code>params</code>.
@param level The level of the logging request.
@param key The key to be searched in the #resourceBundle.
@param file The source file of the logging request, may be null.
@param line The number line of the logging request.
@see #setResourceBundle
*/
void l7dlog(const LevelPtr& level, const String& key,
const char* file, int line, ...);
/**
This is the most generic printing method. It is intended to be
invoked by <b>wrapper</b> classes.
@param level The level of the logging request.
@param message The message of the logging request.
@param file The source file of the logging request, may be null.
@param line The number line of the logging request. */
void log(const LevelPtr& level, const String& message,
const char* file=0, int line=-1);
/**
Remove all previously added appenders from this logger
instance.
<p>This is useful when re-reading configuration information.
*/
void removeAllAppenders();
/**
Remove the appender passed as parameter form the list of appenders.
*/
void removeAppender(const AppenderPtr& appender);
/**
Remove the appender with the name passed as parameter form the
list of appenders.
*/
void removeAppender(const String& name);
/**
Set the additivity flag for this Logger instance.
*/
void setAdditivity(bool additive);
protected:
friend class Hierarchy;
/**
Only the Hierarchy class can set the hierarchy of a logger.*/
void setHierarchy(spi::LoggerRepository * repository);
public:
/**
Set the level of this Logger. If you are passing any of
<code>Level#DEBUG</code>, <code>Level#INFO</code>,
<code>Level#WARN</code>, <code>Level#ERROR</code>,
<code>Level#FATAL</code> as a parameter, you need to case them as
Level.
<p>As in <pre> logger->setLevel(Level::DEBUG); </pre>
<p>Null values are admitted. */
virtual void setLevel(const LevelPtr& level);
/**
Set the resource bundle to be used with localized logging method #l7dlog.
*/
inline void setResourceBundle(const helpers::ResourceBundlePtr& bundle)
{ resourceBundle = bundle; }
/**
Log a message string with the {@link Level#WARN WARN} level.
<p>This method first checks if this logger is <code>WARN</code>
enabled by comparing the level of this logger with the {@link
Level#WARN WARN} level. If this logger is
<code>WARN</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param message the message string to log.
@param file the file where the log statement was written.
@param line the line where the log statement was written.
*/
void warn(const String& message, const char* file=NULL, int line=-1);
};
}
/** @addtogroup LoggingMacros Logging macros
@{
*/
/**
Logs a message to a specified logger with a specified level.
@param logger the logger to be used.
@param level the level to log.
@param message the message string to log.
*/
#define LOG4CXX_LOG(logger, level, message) { \
if (logger->isEnabledFor(level)) {\
::log4cxx::StringBuffer oss; \
oss << message; \
logger->forcedLog(level, oss.str(), __FILE__, __LINE__); }}
/**
Logs a message to a specified logger with the DEBUG level.
@param logger the logger to be used.
@param message the message string to log.
*/
#define LOG4CXX_DEBUG(logger, message) { \
if (logger->isDebugEnabled()) {\
::log4cxx::StringBuffer oss; \
oss << message; \
logger->forcedLog(::log4cxx::Level::DEBUG, oss.str(), __FILE__, __LINE__); }}
/**
Logs a message to a specified logger with the INFO level.
@param logger the logger to be used.
@param message the message string to log.
*/
#define LOG4CXX_INFO(logger, message) { \
if (logger->isInfoEnabled()) {\
::log4cxx::StringBuffer oss; \
oss << message; \
logger->forcedLog(::log4cxx::Level::INFO, oss.str(), __FILE__, __LINE__); }}
/**
Logs a message to a specified logger with the WARN level.
@param logger the logger to be used.
@param message the message string to log.
*/
#define LOG4CXX_WARN(logger, message) { \
if (logger->isWarnEnabled()) {\
::log4cxx::StringBuffer oss; \
oss << message; \
logger->forcedLog(::log4cxx::Level::WARN, oss.str(), __FILE__, __LINE__); }}
/**
Logs a message to a specified logger with the ERROR level.
@param logger the logger to be used.
@param message the message string to log.
*/
#define LOG4CXX_ERROR(logger, message) { \
if (logger->isErrorEnabled()) {\
::log4cxx::StringBuffer oss; \
oss << message; \
logger->forcedLog(::log4cxx::Level::ERROR, oss.str(), __FILE__, __LINE__); }}
/**
Logs a message to a specified logger with the FATAL level.
@param logger the logger to be used.
@param message the message string to log.
*/
#define LOG4CXX_FATAL(logger, message) { \
if (logger->isFatalEnabled()) {\
::log4cxx::StringBuffer oss; \
oss << message; \
logger->forcedLog(::log4cxx::Level::FATAL, oss.str(), __FILE__, __LINE__); }}
/**
Logs a localized message with no parameter.
@param logger the logger to be used.
@param level the level to log.
@param key the key to be searched in the resourceBundle of the logger.
*/
#define LOG4CXX_L7DLOG(logger, level, key) { \
if (logger->isEnabledFor(level)) {\
logger->l7dlog(level, key, __FILE__, __LINE__); }}
/**
Logs a localized message with one parameter.
@param logger the logger to be used.
@param level the level to log.
@param key the key to be searched in the resourceBundle of the logger.
@param p1 the unique parameter. Must be of type (TCHAR *).
*/
#define LOG4CXX_L7DLOG1(logger, level, key, p1) { \
if (logger->isEnabledFor(level)) {\
logger->l7dlog(level, key, __FILE__, __LINE__, p1); }}
/**
Logs a localized message with two parameters.
@param logger the logger to be used.
@param level the level to log.
@param key the key to be searched in the resourceBundle of the logger.
@param p1 the first parameter. Must be of type (TCHAR *).
@param p2 the second parameter. Must be of type (TCHAR *).
*/
#define LOG4CXX_L7DLOG2(logger, level, key, p1, p2) { \
if (logger->isEnabledFor(level)) {\
logger->l7dlog(level, key, __FILE__, __LINE__, p1, p2); }}
/**
Logs a localized message with three parameters.
@param logger the logger to be used.
@param level the level to log.
@param key the key to be searched in the resourceBundle of the logger.
@param p1 the first parameter. Must be of type (TCHAR *).
@param p2 the second parameter. Must be of type (TCHAR *).
@param p3 the third parameter. Must be of type (TCHAR *).
*/
#define LOG4CXX_L7DLOG3(logger, level, key, p1, p2, p3) { \
if (logger->isEnabledFor(level)) {\
logger->l7dlog(level, key, __FILE__, __LINE__, p1, p2, p3); }}
/**@}*/
#endif //_LOG4CXX_LOGGER_H
--- NEW FILE: Makefile.am ---
SUBDIRS = helpers net nt spi varia xml config db
log4cxxincdir = $(includedir)/log4cxx
log4cxxinc_HEADERS= $(top_srcdir)/include/log4cxx/*.h*
--- NEW FILE: writerappender.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* 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 _LOG4CXX_WRITER_APPENDER_H
#define _LOG4CXX_WRITER_APPENDER_H
#include <log4cxx/appenderskeleton.h>
namespace log4cxx
{
class WriterAppender;
typedef helpers::ObjectPtrT<WriterAppender> WriterAppenderPtr;
/**
WriterAppender appends log events to a standard output stream
(ostream or wostream)
*/
class LOG4CXX_EXPORT WriterAppender : public AppenderSkeleton
{
protected:
/**
Immediate flush means that the underlying writer or output stream
will be flushed at the end of each append operation. Immediate
flush is slower but ensures that each append request is actually
written. If <code>immediateFlush</code> is set to
<code>false</code>, then there is a good chance that the last few
logs events are not actually written to persistent media if and
when the application crashes.
<p>The <code>immediateFlush</code> variable is set to
<code>true</code> by default.
*/
bool immediateFlush;
/**
The encoding to use when opening an input stream.
<p>The <code>encoding</code> variable is set to <code>""</code> by
default which results in the utilization of the system's default
encoding. */
String encoding;
/** This is the output stream where we will write to.*/
ostream * os;
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(WriterAppender)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(WriterAppender)
LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
END_LOG4CXX_CAST_MAP()
/**
This default constructor does nothing.*/
WriterAppender();
/**
Instantiate a WriterAppender and set the output destination to
<code>os</code>.*/
WriterAppender(const LayoutPtr& layout, ostream * os);
~WriterAppender();
/**
If the <b>ImmediateFlush</b> option is set to
<code>true</code>, the appender will flush at the end of each
write. This is the default behavior. If the option is set to
<code>false</code>, then the underlying stream can defer writing
to physical medium to a later time.
<p>Avoiding the flush operation at the end of each append results in
a performance gain of 10 to 20 percent. However, there is safety
tradeoff involved in skipping flushing. Indeed, when flushing is
skipped, then it is likely that the last few log events will not
be recorded on disk when the application exits. This is a high
price to pay even for a 20% performance gain.
*/
void setImmediateFlush(bool value) { immediateFlush = value; }
/**
Returns value of the <b>ImmediateFlush</b> option.
*/
bool getImmediateFlush() const { return immediateFlush; }
/**
This method is called by the AppenderSkeleton#doAppend
method.
<p>If the output stream exists and is writable then write a log
statement to the output stream. Otherwise, write a single warning
message to <code>stderr</code>.
<p>The format of the output will depend on this appender's
layout.
*/
virtual void append(const spi::LoggingEventPtr& event);
protected:
/**
This method determines if there is a sense in attempting to append.
<p>It checks whether there is a set output target and also if
there is a set layout. If these checks fail, then the boolean
value <code>false</code> is returned. */
virtual bool checkEntryConditions() const;
public:
/**
Close this appender instance. The underlying stream or writer is
also closed.
<p>Closed appenders cannot be reused.
*/
virtual void close();
protected:
/**
* Close the underlying output stream.
* */
virtual void closeWriter() = 0;
public:
const String& getEncoding() const { return encoding; }
void setEncoding(const String& value) { encoding = value; }
protected:
/**
Actual writing occurs here.
<p>Most subclasses of <code>WriterAppender</code> will need to
override this method.
*/
virtual void subAppend(const spi::LoggingEventPtr& event);
/**
The WriterAppender requires a layout. Hence, this method returns
<code>true</code>.
*/
public:
virtual bool requiresLayout() const { return true; }
/**
Clear internal references to the writer and other variables.
Subclasses can override this method for an alternate closing
behavior. */
protected:
virtual void reset();
/**
Write a footer as produced by the embedded layout's
Layout#appendFooter method. */
protected:
virtual void writeFooter();
/**
Write a header as produced by the embedded layout's
Layout#appendHeader me...
[truncated message content] |