Update of /cvsroot/objecthandler/log4cxx-0.9.7/include/log4cxx/varia
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv25784/include/log4cxx/varia
Added Files:
Makefile.am denyallfilter.h fallbackerrorhandler.h
levelmatchfilter.h levelrangefilter.h stringmatchfilter.h
Log Message:
--- NEW FILE: levelrangefilter.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_VARIA_LEVEL_RANGE_FILTER_H
#define _LOG4CXX_VARIA_LEVEL_RANGE_FILTER_H
#include <log4cxx/spi/filter.h>
#include <log4cxx/level.h>
namespace log4cxx
{
namespace varia
{
/**
This is a very simple filter based on level matching, which can be
used to reject messages with priorities outside a certain range.
<p>The filter admits three options <b>LevelMin</b>, <b>LevelMax</b>
and <b>AcceptOnMatch</b>.
<p>If the level of the {@link spi::LoggingEvent LoggingEvent} is not
between Min and Max (inclusive), then {@link spi::Filter#DENY DENY}
is returned.
<p> If the Logging event level is within the specified range, then if
<b>AcceptOnMatch</b> is true, {@link spi::Filter#ACCEPT ACCEPT} is
returned, and if <b>AcceptOnMatch</b> is false,
{@link spi::Filter#NEUTRAL NEUTRAL} is returned.
<p>If <code>LevelMin</code>w is not defined, then there is no
minimum acceptable level (ie a level is never rejected for
being too "low"/unimportant). If <code>LevelMax</code> is not
defined, then there is no maximum acceptable level (ie a
level is never rejected for beeing too "high"/important).
<p>Refer to the {@link
AppenderSkeleton#setThreshold setThreshold} method
available to <code>all</code> appenders extending
AppenderSkeleton for a more convenient way to
filter out events by level.
*/
class LevelRangeFilter;
typedef helpers::ObjectPtrT<LevelRangeFilter> LevelRangeFilterPtr;
class LOG4CXX_EXPORT LevelRangeFilter : public spi::Filter
{
private:
static String LEVEL_MIN_OPTION;
static String LEVEL_MAX_OPTION;
static String ACCEPT_ON_MATCH_OPTION;
/**
Do we return ACCEPT when a match occurs. Default is
<code>false</code>, so that later filters get run by default
*/
bool acceptOnMatch;
LevelPtr levelMin;
LevelPtr levelMax;
public:
typedef spi::Filter BASE_CLASS;
DECLARE_LOG4CXX_OBJECT(LevelRangeFilter)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(LevelRangeFilter)
LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
END_LOG4CXX_CAST_MAP()
LevelRangeFilter();
/**
Set options
*/
virtual void setOption(const String& option,
const String& value);
/**
Set the <code>LevelMin</code> option.
*/
void setLevelMin(const LevelPtr& levelMin)
{ this->levelMin = levelMin; }
/**
Get the value of the <code>LevelMin</code> option.
*/
const LevelPtr& getLevelMin() const
{ return levelMin; }
/**
Set the <code>LevelMax</code> option.
*/
void setLevelMax(const LevelPtr& levelMax)
{ this->levelMax = levelMax; }
/**
Get the value of the <code>LevelMax</code> option.
*/
const LevelPtr& getLevelMax() const
{ return levelMax; }
/**
Set the <code>AcceptOnMatch</code> option.
*/
inline void setAcceptOnMatch(bool acceptOnMatch)
{ this->acceptOnMatch = acceptOnMatch; }
/**
Get the value of the <code>AcceptOnMatch</code> option.
*/
inline bool getAcceptOnMatch() const
{ return acceptOnMatch; }
/**
Return the decision of this filter.
Returns {@link spi::Filter#NEUTRAL NEUTRAL} if the
<b>LevelToMatch</b> option is not set or if there is not match.
Otherwise, if there is a match, then the returned decision is
{@link spi::Filter#ACCEPT ACCEPT} if the
<b>AcceptOnMatch</b> property is set to <code>true</code>. The
returned decision is {@link spi::Filter#DENY DENY} if the
<b>AcceptOnMatch</b> property is set to false.
*/
FilterDecision decide(const spi::LoggingEventPtr& event) const;
}; // class LevelMatchFilter
} // namespace varia
}; // namespace log4cxx
#endif // _LOG4CXX_VARIA_LEVEL_RANGE_FILTER_H
--- NEW FILE: stringmatchfilter.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_VARIA_STRING_MATCH_FILTER_H
#define _LOG4CXX_VARIA_STRING_MATCH_FILTER_H
#include <log4cxx/spi/filter.h>
namespace log4cxx
{
namespace varia
{
/**
This is a very simple filter based on string matching.
<p>The filter admits two options <b>StringToMatch</b> and
<b>AcceptOnMatch</b>. If there is a match between the value of the
StringToMatch option and the message of the {@link spi::LoggingEvent
LoggingEvent}, then the #decide method returns
{@link spi::Filter#ACCEPT ACCEPT} if the <b>AcceptOnMatch</b> option
value is true, if it is false then {@link spi::Filter#DENY DENY} is
returned. If there is no match, {@link spi::Filter#NEUTRAL NEUTRAL}
is returned.
<p>See configuration files <a
href="../xml/doc-files/test6.xml">test6.xml</a>, <a
href="../xml/doc-files/test7.xml">test7.xml</a>, <a
href="../xml/doc-files/test8.xml">test8.xml</a>, <a
href="../xml/doc-files/test9.xml">test9.xml</a>, and <a
href="../xml/doc-files/test10.xml">test10.xml</a> for examples of
seeting up a <code>StringMatchFilter</code>.
*/
class StringMatchFilter;
typedef helpers::ObjectPtrT<StringMatchFilter> StringMatchFilterPtr;
class LOG4CXX_EXPORT StringMatchFilter : public spi::Filter
{
private:
static String STRING_TO_MATCH_OPTION;
static String ACCEPT_ON_MATCH_OPTION;
bool acceptOnMatch;
String stringToMatch;
public:
typedef spi::Filter BASE_CLASS;
DECLARE_LOG4CXX_OBJECT(StringMatchFilter)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(StringMatchFilter)
LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
END_LOG4CXX_CAST_MAP()
StringMatchFilter();
/**
Set options
*/
virtual void setOption(const String& option,
const String& value);
inline void setStringToMatch(const String& stringToMatch)
{ this->stringToMatch = stringToMatch; }
inline const String& getStringToMatch() const
{ return stringToMatch; }
inline void setAcceptOnMatch(bool acceptOnMatch)
{ this->acceptOnMatch = acceptOnMatch; }
inline bool getAcceptOnMatch() const
{ return acceptOnMatch; }
/**
Returns {@link spi::Filter#NEUTRAL NEUTRAL}
is there is no string match.
*/
FilterDecision decide(const spi::LoggingEventPtr& event) const;
}; // class StringMatchFilter
} // namespace varia
}; // namespace log4cxx
#endif // _LOG4CXX_VARIA_STRING_MATCH_FILTER_H
--- NEW FILE: levelmatchfilter.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_VARIA_LEVEL_MATCH_FILTER_H
#define _LOG4CXX_VARIA_LEVEL_MATCH_FILTER_H
#include <log4cxx/spi/filter.h>
#include <log4cxx/level.h>
namespace log4cxx
{
class Level;
namespace varia
{
/**
This is a very simple filter based on level matching.
<p>The filter admits two options <b>LevelToMatch</b> and
<b>AcceptOnMatch</b>. If there is an exact match between the value
of the <b>LevelToMatch</b> option and the level of the {@link
spi::LoggingEvent LoggingEvent}, then the #decide method returns {@link
spi::Filter#ACCEPT ACCEPT} in case the <b>AcceptOnMatch</b>
option value is set to <code>true</code>, if it is <code>false</code>
then {@link spi::Filter#DENY DENY} is returned. If there is no match,
{@link spi::Filter#NEUTRAL NEUTRAL} is returned.
*/
class LevelMatchFilter;
typedef helpers::ObjectPtrT<LevelMatchFilter> LevelMatchFilterPtr;
class LOG4CXX_EXPORT LevelMatchFilter : public spi::Filter
{
private:
static String LEVEL_TO_MATCH_OPTION;
static String ACCEPT_ON_MATCH_OPTION;
bool acceptOnMatch;
LevelPtr levelToMatch;
public:
typedef spi::Filter BASE_CLASS;
DECLARE_LOG4CXX_OBJECT(LevelMatchFilter)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(LevelMatchFilter)
LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
END_LOG4CXX_CAST_MAP()
LevelMatchFilter();
/**
Set options
*/
virtual void setOption(const String& option,
const String& value);
void setLevelToMatch(const String& levelToMatch);
const String& getLevelToMatch() const;
inline void setAcceptOnMatch(bool acceptOnMatch)
{ this->acceptOnMatch = acceptOnMatch; }
inline bool getAcceptOnMatch() const
{ return acceptOnMatch; }
/**
Return the decision of this filter.
Returns {@link spi::Filter#NEUTRAL NEUTRAL} if the
<b>LevelToMatch</b> option is not set or if there is not match.
Otherwise, if there is a match, then the returned decision is
{@link spi::Filter#ACCEPT ACCEPT} if the <b>AcceptOnMatch</b>
property is set to <code>true</code>. The returned decision is
{@link spi::Filter#DENY DENY} if the
<b>AcceptOnMatch</b> property is set to false.
*/
FilterDecision decide(const spi::LoggingEventPtr& event) const;
}; // class LevelMatchFilter
} // namespace varia
}; // namespace log4cxx
#endif // _LOG4CXX_VARIA_STRING_MATCH_FILTER_H
--- NEW FILE: denyallfilter.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_VARIA_DENY_ALL_FILTER_H
#define _LOG4CXX_VARIA_DENY_ALL_FILTER_H
#include <log4cxx/spi/filter.h>
namespace log4cxx
{
namespace varia
{
/**
This filter drops all logging events.
<p>You can add this filter to the end of a filter chain to
switch from the default "accept all unless instructed otherwise"
filtering behaviour to a "deny all unless instructed otherwise"
behaviour.
*/
class DenyAllFilter;
typedef helpers::ObjectPtrT<DenyAllFilter> DenyAllFilterPtr;
class LOG4CXX_EXPORT DenyAllFilter : public spi::Filter
{
public:
typedef spi::Filter BASE_CLASS;
DECLARE_LOG4CXX_OBJECT(DenyAllFilter)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(DenyAllFilter)
LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
END_LOG4CXX_CAST_MAP()
/**
Always returns the integer constant {@link spi::Filter#DENY DENY}
regardless of the {@link spi::LoggingEvent LoggingEvent} parameter.
@param event The LoggingEvent to filter.
@return Always returns {@link spi::Filter#DENY DENY}.
*/
FilterDecision decide(const spi::LoggingEventPtr& event) const
{ return spi::Filter::DENY; }
}; // class DenyAllFilter
} // namespace varia
}; // namespace log4cxx
#endif // _LOG4CXX_VARIA_DENY_ALL_FILTER_H
--- NEW FILE: Makefile.am ---
variaincdir = $(includedir)/log4cxx/varia
variainc_HEADERS= $(top_srcdir)/include/log4cxx/varia/*.h
--- NEW FILE: fallbackerrorhandler.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_VARIA_FALLBACK_ERROR_HANDLER_H
#define _LOG4CXX_VARIA_FALLBACK_ERROR_HANDLER_H
#include <log4cxx/spi/errorhandler.h>
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/appender.h>
#include <log4cxx/logger.h>
#include <vector>
namespace log4cxx
{
namespace varia
{
/**
The <code>FallbackErrorHandler</code> implements the ErrorHandler
interface such that a secondary appender may be specified. This
secondary appender takes over if the primary appender fails for
whatever reason.
<p>The error message is printed on <code>System.err</code>, and
logged in the new secondary appender.
*/
class LOG4CXX_EXPORT FallbackErrorHandler :
public virtual spi::ErrorHandler,
public virtual helpers::ObjectImpl
{
private:
AppenderPtr backup;
AppenderPtr primary;
std::vector<LoggerPtr> loggers;
public:
DECLARE_LOG4CXX_OBJECT(FallbackErrorHandler)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(spi::OptionHandler)
LOG4CXX_CAST_ENTRY(spi::ErrorHandler)
END_LOG4CXX_CAST_MAP()
FallbackErrorHandler();
/**
<em>Adds</em> the logger passed as parameter to the list of
loggers that we need to search for in case of appender failure.
*/
void setLogger(const LoggerPtr& logger);
/**
No options to activate.
*/
void activateOptions();
void setOption(const String& name, const String& value);
/**
Prints the message and the stack trace of the exception on
<code>System.err</code>.
*/
void error(const String& message, helpers::Exception& e,
int errorCode) const;
/**
Prints the message and the stack trace of the exception on
<code>System.err</code>.
*/
void error(const String& message, helpers::Exception& e,
int errorCode, const spi::LoggingEventPtr& event) const;
/**
Print a the error message passed as parameter on
<code>System.err</code>.
*/
void error(const String& message) const {}
/**
Return the backup appender.
*/
const AppenderPtr& getBackupAppender() const
{ return backup; }
/**
The appender to which this error handler is attached.
*/
void setAppender(const AppenderPtr& primary);
/**
Set the backup appender.
*/
void setBackupAppender(const AppenderPtr& backup);
};
} // namespace varia
}; // namespace log4cxx
#endif //_LOG4CXX_VARIA_FALLBACK_ERROR_HANDLER_H
|