Update of /cvsroot/objecthandler/log4cxx-0.9.7/include/log4cxx/spi
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv25784/include/log4cxx/spi
Added Files:
Makefile.am appenderattachable.h configurator.h
defaultrepositoryselector.h errorhandler.h filter.h
hierarchyeventlistener.h loggerfactory.h loggerrepository.h
loggingevent.h optionhandler.h repositoryselector.h
rootcategory.h triggeringeventevaluator.h
Log Message:
--- NEW FILE: configurator.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_SPI_CONFIGURATOR_H
#define _LOG4CXX_SPI_CONFIGURATOR_H
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/helpers/object.h>
#include <log4cxx/helpers/objectptr.h>
namespace log4cxx
{
namespace spi
{
class LoggerRepository;
typedef helpers::ObjectPtrT<LoggerRepository> LoggerRepositoryPtr;
class Configurator;
typedef helpers::ObjectPtrT<Configurator> ConfiguratorPtr;
/**
Implemented by classes capable of configuring log4j using a URL.
*/
class LOG4CXX_EXPORT Configurator : virtual public helpers::Object
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Configurator)
/**
Special level value signifying inherited behaviour. The current
value of this string constant is <b>inherited</b>. #NuLL
is a synonym. */
static String INHERITED /*= "inherited"*/;
/**
Special level signifying inherited behaviour, same as
#INHERITED. The current value of this string constant is
<b>null</b>. */
static String NuLL /*= "null"*/;
/**
Interpret a resource pointed by a URL and set up log4j accordingly.
The configuration is done relative to the <code>hierarchy</code>
parameter.
@param configFileName The file to parse
@param repository The hierarchy to operation upon.
*/
virtual void doConfigure(const String& configFileName,
spi::LoggerRepositoryPtr& repository) = 0;
};
}
}
#endif // _LOG4CXX_SPI_CONFIGURATOR_H
--- NEW FILE: loggerfactory.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_SPI_LOGGERFACTORY_H
#define _LOG4CXX_SPI_LOGGERFACTORY_H
#include <log4cxx/helpers/object.h>
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/tchar.h>
namespace log4cxx
{
class Logger;
typedef helpers::ObjectPtrT<Logger> LoggerPtr;
namespace spi
{
/**
Implement this interface to create new instances of Logger or
a sub-class of Logger.
*/
class LOG4CXX_EXPORT LoggerFactory : public virtual helpers::Object
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(LoggerFactory)
virtual ~LoggerFactory() {}
virtual LoggerPtr makeNewLoggerInstance(const String& name) = 0;
};
typedef helpers::ObjectPtrT<LoggerFactory> LoggerFactoryPtr;
} // namespace spi
}; // namesapce log4cxx
#endif //_LOG4CXX_SPI_LOGGERFACTORY_H
--- NEW FILE: filter.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_SPI_FILTER_H
#define _LOG4CXX_SPI_FILTER_H
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/spi/optionhandler.h>
namespace log4cxx
{
namespace spi
{
class Filter;
typedef helpers::ObjectPtrT<Filter> FilterPtr;
class LoggingEvent;
typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr;
/**
Users should extend this class to implement customized logging
event filtering. Note that Logger and
AppenderSkeleton, the parent class of all standard
appenders, have built-in filtering rules. It is suggested that you
first use and understand the built-in rules before rushing to write
your own custom filters.
<p>This abstract class assumes and also imposes that filters be
organized in a linear chain. The {@link #decide
decide(LoggingEvent)} method of each filter is called sequentially,
in the order of their addition to the chain.
<p>The {@link #decide decide(LoggingEvent)} method must return one
of the integer constants #DENY, #NEUTRAL or
#ACCEPT.
<p>If the value #DENY is returned, then the log event is
dropped immediately without consulting with the remaining
filters.
<p>If the value #NEUTRAL is returned, then the next filter
in the chain is consulted. If there are no more filters in the
chain, then the log event is logged. Thus, in the presence of no
filters, the default behaviour is to log all logging events.
<p>If the value #ACCEPT is returned, then the log
event is logged without consulting the remaining filters.
<p>The philosophy of log4cxx filters is largely inspired from the
Linux ipchains.
<p>Note that filtering is only supported by the {@link
xml::DOMConfigurator DOMConfigurator}.
*/
class LOG4CXX_EXPORT Filter : public virtual OptionHandler,
public virtual helpers::ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Filter)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(Filter)
LOG4CXX_CAST_ENTRY(spi::OptionHandler)
END_LOG4CXX_CAST_MAP()
/**
Points to the next filter in the filter chain.
*/
FilterPtr next;
enum FilterDecision
{
/**
The log event must be dropped immediately without consulting
with the remaining filters, if any, in the chain. */
DENY = -1,
/**
This filter is neutral with respect to the log event. The
remaining filters, if any, should be consulted for a final decision.
*/
NEUTRAL = 0,
/**
The log event must be logged immediately without consulting with
the remaining filters, if any, in the chain.
*/
ACCEPT = 1
};
/**
Usually filters options become active when set. We provide a
default do-nothing implementation for convenience.
*/
void activateOptions() {}
void setOption(const String& option, const String& value) {}
/**
<p>If the decision is <code>DENY</code>, then the event will be
dropped. If the decision is <code>NEUTRAL</code>, then the next
filter, if any, will be invoked. If the decision is ACCEPT then
the event will be logged without consulting with other filters in
the chain.
@param event The LoggingEvent to decide upon.
@return The decision of the filter. */
virtual FilterDecision decide(const LoggingEventPtr& event) const = 0;
};
}
}
#endif //_LOG4CXX_SPI_FILTER_H
--- NEW FILE: loggingevent.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_SPI_LOGGING_EVENT_H
#define _LOG4CXX_SPI_LOGGING_EVENT_H
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/tchar.h>
#include <time.h>
#include <log4cxx/logger.h>
#include <log4cxx/mdc.h>
#include <set>
namespace log4cxx
{
class Logger;
typedef helpers::ObjectPtrT<Logger> LoggerPtr;
class Level;
namespace helpers
{
class SocketOutputStream;
typedef helpers::ObjectPtrT<SocketOutputStream> SocketOutputStreamPtr;
class SocketInputStream;
typedef helpers::ObjectPtrT<SocketInputStream> SocketInputStreamPtr;
}
namespace spi
{
class LoggingEvent;
/** smart pointer to a LoggingEvent class */
typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr;
/**
The internal representation of logging events. When an affirmative
decision is made to log then a <code>LoggingEvent</code> instance
is created. This instance is passed around to the different log4cxx
components.
<p>This class is of concern to those wishing to extend log4cxx.
*/
class LOG4CXX_EXPORT LoggingEvent :
public virtual helpers::ObjectImpl
{
public:
DECLARE_LOG4CXX_OBJECT(LoggingEvent)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(LoggingEvent)
END_LOG4CXX_CAST_MAP()
/** For serialization only
*/
LoggingEvent();
/**
Instantiate a LoggingEvent from the supplied parameters.
<p>Except #timeStamp all the other fields of
<code>LoggingEvent</code> are filled when actually needed.
<p>
@param fqnOfLoggerClass The fully qualified name of the calling
logger class.
@param logger The logger of this event.
@param level The level of this event.
@param message The message of this event.
@param file The file where this log statement was written.
@param line The line where this log statement was written.
*/
LoggingEvent(const String& fqnOfLoggerClass,
const LoggerPtr& logger,
const LevelPtr& level, const String& message,
const char* file=0, int line=-1);
~LoggingEvent();
/** Return the #level of this event. */
inline const LevelPtr& getLevel() const
{ return level; }
/** Return the name of the #logger. */
const String& getLoggerName() const;
/** Return the #message for this logging event. */
inline const String& getMessage() const
{ return message; }
/** Return the #message for this logging event. */
inline const String& getRenderedMessage() const
{ return message; }
/**Returns the time when the application started,
in seconds elapsed since 01.01.1970.
*/
static int64_t getStartTime()
{ return startTime; }
/** Return the #threadId of this event. */
inline unsigned long getThreadId() const
{ return threadId; }
/** Return the #timeStamp of this event. */
inline int64_t getTimeStamp() const
{ return timeStamp; }
/* Return the file where this log statement was written. */
inline char * getFile() const
{ return file; }
/* Return the line where this log statement was written. */
inline int getLine() const
{ return line; }
/**
* This method returns the NDC for this event. It will return the
* correct content even if the event was generated in a different
* thread or even on a different machine. The NDC#get method
* should <em>never</em> be called directly. */
const String& getNDC() const;
/** Write this event to a helpers::SocketOutputStream. */
void write(helpers::SocketOutputStreamPtr& os) const;
void writeLevel(helpers::SocketOutputStreamPtr& os) const;
/** Read this event from a helpers::SocketOutputStream. */
void read(const helpers::SocketInputStreamPtr& is);
void readLevel(const helpers::SocketInputStreamPtr& is);
/**
* Returns the the context corresponding to the <code>key</code> parameter.
* If there is a local MDC copy, possibly because we are in a logging
* server or running inside AsyncAppender, then we search for the key in
* MDC copy, if a value is found it is returned. Otherwise, if the search
* in MDC copy returns an empty result, then the current thread's
* <code>MDC</code> is used.
*
* <p>
* Note that <em>both</em> the local MDC copy and the current thread's MDC
* are searched.
* </p>
*/
String getMDC(const String& key) const;
/**
* Returns the set of of the key values in the MDC for the event.
* The returned set is unmodifiable by the caller.
*
* @return Set an unmodifiable set of the MDC keys.
* @since 1.3
*/
std::set<String> getMDCKeySet() const;
/**
Obtain a copy of this thread's MDC prior to serialization
or asynchronous logging.
*/
void getMDCCopy() const;
/**
* Return a previously set property. The return value can be null.
*/
String getProperty(const String& key) const;
/**
* Returns the set of of the key values in the properties
* for the event. The returned set is unmodifiable by the caller.
*
* @return Set an unmodifiable set of the property keys.
*/
std::set<String> getPropertyKeySet() const;
/**
* Set a string property using a key and a string value. since 1.3
*/
void setProperty(const String& key, const String& value);
public:
/**
* Fully qualified name of the calling category class.
*/
String fqnOfCategoryClass;
private:
/**
* The logger of the logging event. This field is not serialized for
* performance reasons.
*
* <p>
* It is set by the LoggingEvent constructor or set by a remote
* entity after deserialization.
**/
LoggerPtr logger;
/** level of logging event. */
LevelPtr level;
/** The nested diagnostic context (NDC) of logging event. */
String ndc;
/** The mapped diagnostic context (MDC) of logging event. */
MDC::Map mdcCopy;
/**
* A map of String keys and String values.
*/
std::map<String, String> * properties;
/** Have we tried to do an NDC lookup? If we did, there is no need
* to do it again. Note that its value is always false when
* serialized. Thus, a receiving SocketNode will never use it's own
* (incorrect) NDC. See also writeObject method.
*/
bool ndcLookupRequired;
/**
* Have we tried to do an MDC lookup? If we did, there is no need to do it
* again. Note that its value is always false when serialized. See also
* the getMDC and getMDCCopy methods.
*/
bool mdcCopyLookupRequired;
/** The application supplied message of logging event. */
String message;
/** The name of thread in which this logging event was generated. */
//const LOG4CPLUS_THREAD_KEY_TYPE thread;
/** The number of milliseconds elapsed from 1/1/1970 until logging event
was created. */
int64_t timeStamp;
/** The is the file where this log statement was written. */
char* file;
std::string fileFromStream;
/** The is the line where this log statement was written. */
int line;
/** The identifier of thread in which this logging event
was generated.
*/
unsigned long threadId;
static int64_t startTime;
};
}
}
#endif //_LOG4CXX_SPI_LOGGING_EVENT_H
--- NEW FILE: loggerrepository.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_SPI_LOG_REPOSITORY_H
#define _LOG4CXX_SPI_LOG_REPOSITORY_H
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/object.h>
#include <log4cxx/helpers/tchar.h>
#include <vector>
namespace log4cxx
{
class Level;
typedef helpers::ObjectPtrT<Level> LevelPtr;
class Logger;
typedef helpers::ObjectPtrT<Logger> LoggerPtr;
typedef std::vector<LoggerPtr> LoggerList;
class Appender;
typedef log4cxx::helpers::ObjectPtrT<Appender> AppenderPtr;
namespace spi
{
class HierarchyEventListener;
typedef log4cxx::helpers::ObjectPtrT<HierarchyEventListener>
HierarchyEventListenerPtr;
class LoggerFactory;
typedef helpers::ObjectPtrT<LoggerFactory> LoggerFactoryPtr;
class LoggerRepository;
typedef helpers::ObjectPtrT<LoggerRepository> LoggerRepositoryPtr;
/**
A <code>LoggerRepository</code> is used to create and retrieve
<code>Loggers</code>. The relation between loggers in a repository
depends on the repository but typically loggers are arranged in a
named hierarchy.
<p>In addition to the creational methods, a
<code>LoggerRepository</code> can be queried for existing loggers,
can act as a point of registry for events related to loggers.
*/
class LOG4CXX_EXPORT LoggerRepository : public virtual helpers::Object
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(LoggerRepository)
virtual ~LoggerRepository() {}
/**
Add a {@link spi::HierarchyEventListener HierarchyEventListener}
event to the repository.
*/
virtual void addHierarchyEventListener(const HierarchyEventListenerPtr&
listener) = 0;
/**
Is the repository disabled for a given level? The answer depends
on the repository threshold and the <code>level</code>
parameter. See also #setThreshold method. */
virtual bool isDisabled(int level) const = 0;
/**
Set the repository-wide threshold. All logging requests below the
threshold are immediately dropped. By default, the threshold is
set to <code>Level::ALL</code> which has the lowest possible rank. */
virtual void setThreshold(const LevelPtr& level) = 0;
/**
Another form of {@link #setThreshold(const LevelPtr&)
setThreshold} accepting a string
parameter instead of a <code>Level</code>. */
virtual void setThreshold(const String& val) = 0;
virtual void emitNoAppenderWarning(const LoggerPtr& logger) = 0;
/**
Get the repository-wide threshold. See {@link
#setThreshold(const LevelPtr&) setThreshold}
for an explanation. */
virtual const LevelPtr& getThreshold() const = 0;
virtual LoggerPtr getLogger(const String& name) = 0;
virtual LoggerPtr getLogger(const String& name, spi::LoggerFactoryPtr
factory) = 0;
virtual LoggerPtr getRootLogger() const = 0;
virtual LoggerPtr exists(const String& name) = 0;
virtual void shutdown() = 0;
virtual LoggerList getCurrentLoggers() const = 0;
virtual void fireAddAppenderEvent(const LoggerPtr& logger,
const AppenderPtr& appender) = 0;
virtual void resetConfiguration() = 0;
}; // class LoggerRepository
} // namespace spi
}; // namespace log4cxx
#endif //_LOG4CXX_SPI_LOG_REPOSITORY_H
--- NEW FILE: rootcategory.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_SPI_ROOT_CATEGORY_H
#define _LOG4CXX_SPI_ROOT_CATEGORY_H
#include <log4cxx/logger.h>
namespace log4cxx
{
namespace spi
{
/**
RootCategory sits at the top of the logger hierachy. It is a
regular logger except that it provides several guarantees.
<p>First, it cannot be assigned a null
level. Second, since root logger cannot have a parent, the
#getEffectiveLevel method always returns the value of the
level field without walking the hierarchy.
*/
class LOG4CXX_EXPORT RootCategory : public Logger
{
public:
/**
The root logger names itself as "root". However, the root
logger cannot be retrieved by name.
*/
RootCategory(const LevelPtr& level);
/**
Return the assigned level value without walking the category
hierarchy.
*/
virtual const LevelPtr& getEffectiveLevel();
/**
Setting a null value to the level of the root category may have catastrophic
results. We prevent this here.
*/
void setLevel(const LevelPtr& level);
};
} // namespace spi
}; // namespace log4cxx
#endif //_LOG4CXX_SPI_ROOT_CATEGORY_H
--- NEW FILE: defaultrepositoryselector.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_SPI_DEFAULT_REPOSITORY_SELECTOR_H
#define _LOG4CXX_SPI_DEFAULT_REPOSITORY_SELECTOR_H
#include <log4cxx/spi/repositoryselector.h>
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/spi/loggerrepository.h>
namespace log4cxx
{
namespace spi
{
class LOG4CXX_EXPORT DefaultRepositorySelector :
public virtual RepositorySelector,
public virtual helpers::ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(DefaultRepositorySelector)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(RepositorySelector)
END_LOG4CXX_CAST_MAP()
DefaultRepositorySelector(const LoggerRepositoryPtr& repository)
: repository(repository)
{
}
virtual LoggerRepositoryPtr& getLoggerRepository()
{
return repository;
}
private:
LoggerRepositoryPtr repository;
};
} // namespace spi
}; // namespace log4cxx
#endif //_LOG4CXX_SPI_DEFAULT_REPOSITORY_SELECTOR_H
--- NEW FILE: hierarchyeventlistener.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_SPI_HIERARCHY_EVENT_LISTENER_H
#define _LOG4CXX_SPI_HIERARCHY_EVENT_LISTENER_H
#include <log4cxx/helpers/object.h>
#include <log4cxx/helpers/objectptr.h>
#include <vector>
namespace log4cxx
{
class Logger;
typedef helpers::ObjectPtrT<Logger> LoggerPtr;
class Appender;
typedef helpers::ObjectPtrT<Appender> AppenderPtr;
namespace spi
{
class HierarchyEventListener;
typedef log4cxx::helpers::ObjectPtrT<HierarchyEventListener>
HierarchyEventListenerPtr;
typedef std::vector<HierarchyEventListenerPtr> HierarchyEventListenerList;
/** Listen to events occuring within a Hierarchy.*/
class LOG4CXX_EXPORT HierarchyEventListener :
public virtual log4cxx::helpers::Object
{
public:
virtual ~HierarchyEventListener() {}
virtual void addAppenderEvent(const LoggerPtr& logger, const AppenderPtr&
appender) = 0;
virtual void removeAppenderEvent(const LoggerPtr& logger,
const AppenderPtr& appender) = 0;
};
} // namespace spi
}; // namespace log4cxx
#endif //_LOG4CXX_SPI_HIERARCHY_EVENT_LISTENER_H
--- NEW FILE: repositoryselector.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_SPI_REPOSITORY_SELECTOR_H
#define _LOG4CXX_SPI_REPOSITORY_SELECTOR_H
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/object.h>
namespace log4cxx
{
namespace spi
{
class LoggerRepository;
typedef helpers::ObjectPtrT<LoggerRepository> LoggerRepositoryPtr;
class RepositorySelector;
typedef helpers::ObjectPtrT<RepositorySelector> RepositorySelectorPtr;
/**
The <code>LogManager</code> uses one (and only one)
<code>RepositorySelector</code> implementation to select the
{@link LoggerRepository LoggerRepository}
for a particular application context.
<p>It is the responsability of the <code>RepositorySelector</code>
implementation to track the application context. log4cxx makes no
assumptions about the application context or on its management.
<p>See also LogManager.
*/
class LOG4CXX_EXPORT RepositorySelector : public virtual helpers::Object
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(RepositorySelector)
virtual ~RepositorySelector() {}
virtual LoggerRepositoryPtr& getLoggerRepository() = 0;
};
} //namespace spi
}; //namespace log4cxx
#endif //_LOG4CXX_SPI_REPOSITORY_SELECTOR_H
--- NEW FILE: triggeringeventevaluator.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_SPI_TRIGGERING_EVENT_EVALUATOR_H
#define _LOG4CXX_SPI_TRIGGERING_EVENT_EVALUATOR_H
#include <log4cxx/helpers/object.h>
#include <log4cxx/helpers/objectptr.h>
namespace log4cxx
{
namespace spi
{
class TriggeringEventEvaluator;
typedef helpers::ObjectPtrT<TriggeringEventEvaluator>
TriggeringEventEvaluatorPtr;
class LoggingEvent;
typedef helpers::ObjectPtrT<Logger> LoggerPtr;
/**
Implementions of this interface allow certain appenders to decide
when to perform an appender specific action.
<p>For example the {@link net::SMTPAppender SMTPAppender} sends
an email when the #isTriggeringEvent method returns
<code>true</code> and adds the event to an internal buffer when the
returned result is <code>false</code>.
*/
class LOG4CXX_EXPORT TriggeringEventEvaluator : public virtual helpers::Object
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(TriggeringEventEvaluator)
/**
Is this the triggering event?
*/
virtual bool isTriggeringEvent(const spi::LoggingEventPtr& event) = 0;
};
}
}
#endif // _LOG4CXX_SPI_TRIGGERING_EVENT_EVALUATOR_H
--- NEW FILE: optionhandler.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_SPI_OPTION_HANDLER_H
#define _LOG4CXX_SPI_OPTION_HANDLER_H
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/helpers/object.h>
#include <log4cxx/helpers/objectptr.h>
namespace log4cxx
{
namespace spi
{
class OptionHandler;
typedef helpers::ObjectPtrT<OptionHandler> OptionHandlerPtr;
/**
A string based interface to configure package components.
*/
class LOG4CXX_EXPORT OptionHandler : public virtual helpers::Object
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(OptionHandler)
virtual ~OptionHandler() {}
/**
Activate the options that were previously set with calls to option
setters.
<p>This allows to defer activiation of the options until all
options have been set. This is required for components which have
related options that remain ambigous until all are set.
<p>For example, the FileAppender has the {@link
FileAppender#setFile File} and {@link
FileAppender#setAppend Append} options both of
which are ambigous until the other is also set. */
virtual void activateOptions() = 0;
/**
Set <code>option</code> to <code>value</code>.
<p>The handling of each option depends on the OptionHandler
instance. Some options may become active immediately whereas
other may be activated only when #activateOptions is
called.
*/
virtual void setOption(const String& option, const String& value) = 0;
}; // class OptionConverter
} // namespace spi
}; // namespace log4cxx
#endif //_LOG4CXX_SPI_OPTION_HANDLER_H
--- NEW FILE: appenderattachable.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_SPI_APPENDER_ATTACHABLE_H_
#define _LOG4CXX_SPI_APPENDER_ATTACHABLE_H_
#include <log4cxx/helpers/tchar.h>
#include <vector>
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/object.h>
#include <log4cxx/appender.h>
namespace log4cxx
{
// Forward Declarations
class Appender;
typedef helpers::ObjectPtrT<Appender> AppenderPtr;
typedef std::vector<AppenderPtr> AppenderList;
namespace spi
{
class AppenderAttachable;
typedef helpers::ObjectPtrT<AppenderAttachable> AppenderAttachablePtr;
/**
* This Interface is for attaching Appenders to objects.
*/
class LOG4CXX_EXPORT AppenderAttachable : public virtual helpers::Object
{
public:
// Methods
DECLARE_ABSTRACT_LOG4CXX_OBJECT(AppenderAttachable)
/**
* Add an appender.
*/
virtual void addAppender(const AppenderPtr& newAppender) = 0;
/**
* Get all previously added appenders as an AppenderList.
*/
virtual AppenderList getAllAppenders() const = 0;
/**
* Get an appender by name.
*/
virtual AppenderPtr getAppender(const String& name) const = 0;
/**
Returns <code>true</code> if the specified appender is in list of
attached attached, <code>false</code> otherwise.
*/
virtual bool isAttached(const AppenderPtr& appender) const = 0;
/**
* Remove all previously added appenders.
*/
virtual void removeAllAppenders() = 0;
/**
* Remove the appender passed as parameter from the list of appenders.
*/
virtual void removeAppender(const AppenderPtr& appender) = 0;
/**
* Remove the appender with the name passed as parameter from the
* list of appenders.
*/
virtual void removeAppender(const String& name) = 0;
// Dtor
virtual ~AppenderAttachable(){}
};
}
}
#endif //_LOG4CXX_SPI_APPENDER_ATTACHABLE_H_
--- NEW FILE: Makefile.am ---
spiincdir = $(includedir)/log4cxx/spi
spiinc_HEADERS= $(top_srcdir)/include/log4cxx/spi/*.h
--- NEW FILE: errorhandler.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_SPI_ERROR_HANDLER_H
#define _LOG4CXX_SPI_ERROR_HANDLER_H
#include <log4cxx/spi/optionhandler.h>
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/object.h>
#include <log4cxx/helpers/exception.h>
namespace log4cxx
{
class Appender;
typedef log4cxx::helpers::ObjectPtrT<Appender> AppenderPtr;
class Logger;
typedef helpers::ObjectPtrT<Logger> LoggerPtr;
namespace spi
{
class ErrorCode
{
public:
enum
{
GENERIC_FAILURE = 0,
WRITE_FAILURE = 1,
FLUSH_FAILURE = 2,
CLOSE_FAILURE = 3,
FILE_OPEN_FAILURE = 4,
MISSING_LAYOUT = 5,
ADDRESS_PARSE_FAILURE = 6
};
};
class LoggingEvent;
typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr;
class ErrorHandler;
typedef log4cxx::helpers::ObjectPtrT<ErrorHandler> ErrorHandlerPtr;
/**
Appenders may delegate their error handling to
<code>ErrorHandlers</code>.
<p>Error handling is a particularly tedious to get right because by
definition errors are hard to predict and to reproduce.
<p>Please take the time to contact the author in case you discover
that errors are not properly handled. You are most welcome to
suggest new error handling policies or criticize existing policies.
*/
class LOG4CXX_EXPORT ErrorHandler : public virtual OptionHandler
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(ErrorHandler)
virtual ~ErrorHandler() {}
/**
Add a reference to a logger to which the failing appender might
be attached to. The failing appender will be searched and
replaced only in the loggers you add through this method.
@param logger One of the loggers that will be searched for the failing
appender in view of replacement.
*/
virtual void setLogger(const LoggerPtr& logger) = 0;
/**
Equivalent to the error(const String&, helpers::Exception&, int,
spi::LoggingEvent&) with the the event parameteter set to
null.
*/
virtual void error(const String& message, helpers::Exception& e,
int errorCode) const = 0;
/**
This method is normally used to just print the error message
passed as a parameter.
*/
virtual void error(const String& message) const = 0;
/**
This method is invoked to handle the error.
@param message The message assoicated with the error.
@param e The Exption that was thrown when the error occured.
@param errorCode The error code associated with the error.
@param event The logging event that the failing appender is asked
to log.
*/
virtual void error(const String& message, helpers::Exception& e,
int errorCode, const LoggingEventPtr& event) const = 0;
/**
Set the appender for which errors are handled. This method is
usually called when the error handler is configured.
*/
virtual void setAppender(const AppenderPtr& appender) = 0;
/**
Set the appender to fallback upon in case of failure.
*/
virtual void setBackupAppender(const AppenderPtr& appender) = 0;
};
} //namespace spi
}; //namespace log4cxx
#endif //_LOG4CXX_SPI_ERROR_HANDLER_H
|