absolutetimedateformat.h   absolutetimedateformat.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_HELPERS_ABSOLUTE_TIME_DATE_FORMAT_H #ifndef _LOG4CXX_HELPERS_ABSOLUTE_TIME_DATE_FORMAT_H
#define _LOG4CXX_HELPERS_ABSOLUTE_TIME_DATE_FORMAT_H #define _LOG4CXX_HELPERS_ABSOLUTE_TIME_DATE_FORMAT_H
#include <log4cxx/helpers/dateformat.h> #include <log4cxx/helpers/simpledateformat.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
/** /**
Formats a date in the format <b>%H:%M:%S,%Q</b> for example, Formats a date in the format <b>HH:mm:ss,SSS</b> for exampl
"15:49:37,459". e,
*/ "15:49:37,459".
class LOG4CXX_EXPORT AbsoluteTimeDateFormat : public DateFor */
mat class LOG4CXX_EXPORT AbsoluteTimeDateFormat : public Simple
{ DateFormat
public: {
/** public:
string constant used to specify AbsoluteTimeDateFormat()
ISO8601DateFormat in layouts. Current : SimpleDateFormat(LOG4CXX_STR("HH:mm:ss,SSS")) {}
value is <b>ISO8601</b>. };
*/ } // namespace helpers
static String ISO8601_DATE_FORMAT; } // namespace log4cxx
/**
String constant used to specify
AbsoluteTimeDateFormat in layouts. Current
value is <b>ABSOLUTE</b>. */
static String ABS_TIME_DATE_FORMAT;
/**
String constant used to specify
DateTimeDateFormat in layouts. Current
value is <b>DATE</b>.
*/
static String DATE_AND_TIME_DATE_FORMAT;
AbsoluteTimeDateFormat(const TimeZonePtr& timeZone)
: DateFormat(_T("%H:%M:%S,%Q"), timeZone) {}
};
} // namespace helpers
}; // namespace log4cxx
#endif // _LOG4CXX_HELPERS_ABSOLUTE_TIME_DATE_FORMAT_H #endif // _LOG4CXX_HELPERS_ABSOLUTE_TIME_DATE_FORMAT_H
 End of changes. 3 change blocks. 
41 lines changed or deleted 23 lines changed or added


 appender.h   appender.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_APPENDER_H #ifndef _LOG4CXX_APPENDER_H
#define _LOG4CXX_APPENDER_H #define _LOG4CXX_APPENDER_H
#include <log4cxx/helpers/tchar.h> #if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/spi/optionhandler.h>
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/object.h> #include <log4cxx/helpers/object.h>
#include <vector> #include <vector>
#include <log4cxx/spi/optionhandler.h>
namespace log4cxx namespace log4cxx
{ {
// Forward declarations // Forward declarations
namespace spi namespace spi
{ {
class LoggingEvent; class LoggingEvent;
typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr; typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr;
class Filter; class Filter;
typedef helpers::ObjectPtrT<Filter> FilterPtr; typedef helpers::ObjectPtrT<Filter> FilterPtr;
class ErrorHandler; class ErrorHandler;
typedef log4cxx::helpers::ObjectPtrT<ErrorHandler> ErrorHand lerPtr; typedef log4cxx::helpers::ObjectPtrT<ErrorHandler> ErrorHan dlerPtr;
} }
class Layout; class Layout;
typedef log4cxx::helpers::ObjectPtrT<Layout> LayoutPtr; typedef log4cxx::helpers::ObjectPtrT<Layout> LayoutPtr;
class Appender; /**
typedef log4cxx::helpers::ObjectPtrT<Appender> AppenderPtr; Implement this interface for your own strategies for outputting log
typedef std::vector<AppenderPtr> AppenderList; statements.
*/
/**
Implement this interface for your own strategies for outputting log
statements.
*/
class LOG4CXX_EXPORT Appender : class LOG4CXX_EXPORT Appender :
public virtual spi::OptionHandler public virtual spi::OptionHandler
{ {
public: public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Appender) DECLARE_ABSTRACT_LOG4CXX_OBJECT(Appender)
virtual ~Appender() {}
virtual ~Appender() {}
/** /**
Add a filter to the end of the filter list. Add a filter to the end of the filter list.
*/ */
virtual void addFilter(const spi::FilterPtr& newFilter) = 0; virtual void addFilter(const spi::FilterPtr& newFilter) = 0;
/** /**
Returns the head Filter. The Filters are organized in a linked lis t Returns the head Filter. The Filters are organized in a linked lis t
and so all Filters on this Appender are available through the resu lt. and so all Filters on this Appender are available through the resu lt.
@return the head Filter or null, if no Filters are present @return the head Filter or null, if no Filters are present
*/ */
virtual const spi::FilterPtr& getFilter() const = 0; virtual spi::FilterPtr getFilter() const = 0;
/** /**
Clear the list of filters by removing all the filters in it. Clear the list of filters by removing all the filters in it.
*/ */
virtual void clearFilters() = 0; virtual void clearFilters() = 0;
/** /**
Release any resources allocated within the appender such as file Release any resources allocated within the appender such as file
handles, network connections, etc. handles, network connections, etc.
<p>It is a programming error to append to a closed appender. <p>It is a programming error to append to a closed appender.
*/ */
virtual void close() = 0; virtual void close() = 0;
/** /**
Log in <code>Appender</code> specific way. When appropriate, Log in <code>Appender</code> specific way. When appropriate,
Loggers will call the <code>doAppend</code> method of appender Loggers will call the <code>doAppend</code> method of appender
implementations in order to log. implementations in order to log.
*/ */
virtual void doAppend(const spi::LoggingEventPtr& event) = 0; virtual void doAppend(const spi::LoggingEventPtr& event,
log4cxx::helpers::Pool& pool) = 0;
/** /**
Get the name of this appender. The name uniquely identifies the Get the name of this appender. The name uniquely identifies the
appender. appender.
*/ */
virtual const String& getName() const = 0; virtual LogString getName() const = 0;
/**
Set the {@link spi::ErrorHandler ErrorHandler} for this appender.
*/
virtual void setErrorHandler(const spi::ErrorHandlerPtr& errorHandl
er) = 0;
/**
Returns the {@link spi::ErrorHandler ErrorHandler} for this append
er.
*/
virtual const spi::ErrorHandlerPtr& getErrorHandler() const = 0;
/** /**
Set the Layout for this appender. Set the Layout for this appender.
*/ */
virtual void setLayout(const LayoutPtr& layout) = 0; virtual void setLayout(const LayoutPtr& layout) = 0;
/** /**
Returns this appenders layout. Returns this appenders layout.
*/ */
virtual const LayoutPtr& getLayout() const = 0; virtual LayoutPtr getLayout() const = 0;
/** /**
Set the name of this appender. The name is used by other Set the name of this appender. The name is used by other
components to identify this appender. components to identify this appender.
*/ */
virtual void setName(const String& name) = 0; virtual void setName(const LogString& name) = 0;
/** /**
Configurators call this method to determine if the appender Configurators call this method to determine if the appender
requires a layout. If this method returns <code>true</code>, requires a layout. If this method returns <code>true</code>,
meaning that layout is required, then the configurator will meaning that layout is required, then the configurator will
configure an layout using the configuration information at its configure an layout using the configuration information at its
disposal. If this method returns <code>false</code>, meaning that disposal. If this method returns <code>false</code>, meaning that
a layout is not required, then layout configuration will be a layout is not required, then layout configuration will be
skipped even if there is available layout configuration skipped even if there is available layout configuration
information at the disposal of the configurator.. information at the disposal of the configurator..
<p>In the rather exceptional case, where the appender <p>In the rather exceptional case, where the appender
implementation admits a layout but can also work without it, then implementation admits a layout but can also work without it, then
the appender should return <code>true</code>. the appender should return <code>true</code>.
*/ */
virtual bool requiresLayout() const = 0; virtual bool requiresLayout() const = 0;
}; };
LOG4CXX_PTR_DEF(Appender);
LOG4CXX_LIST_DEF(AppenderList, AppenderPtr);
} }
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#endif //_LOG4CXX_APPENDER_H #endif //_LOG4CXX_APPENDER_H
 End of changes. 15 change blocks. 
37 lines changed or deleted 36 lines changed or added


 appenderattachable.h   appenderattachable.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_SPI_APPENDER_ATTACHABLE_H_ #ifndef _LOG4CXX_SPI_APPENDER_ATTACHABLE_H_
#define _LOG4CXX_SPI_APPENDER_ATTACHABLE_H_ #define _LOG4CXX_SPI_APPENDER_ATTACHABLE_H_
#include <log4cxx/helpers/tchar.h> #if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
#include <vector> #include <vector>
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/object.h> #include <log4cxx/helpers/object.h>
#include <log4cxx/appender.h> #include <log4cxx/appender.h>
namespace log4cxx namespace log4cxx
{ {
// Forward Declarations
class Appender;
typedef helpers::ObjectPtrT<Appender> AppenderPtr;
typedef std::vector<AppenderPtr> AppenderList;
namespace spi namespace spi
{ {
class AppenderAttachable;
typedef helpers::ObjectPtrT<AppenderAttachable> AppenderAtta
chablePtr;
/** /**
* This Interface is for attaching Appenders to objects. * This Interface is for attaching Appenders to objects.
*/ */
class LOG4CXX_EXPORT AppenderAttachable : public virtual helpers::O bject class LOG4CXX_EXPORT AppenderAttachable : public virtual helpers::O bject
{ {
public: public:
// Methods // Methods
DECLARE_ABSTRACT_LOG4CXX_OBJECT(AppenderAttachable) DECLARE_ABSTRACT_LOG4CXX_OBJECT(AppenderAttachable)
/** /**
* Add an appender. * Add an appender.
*/ */
virtual void addAppender(const AppenderPtr& newAppender) = 0; virtual void addAppender(const AppenderPtr& newAppender) = 0;
/** /**
* Get all previously added appenders as an AppenderList. * Get all previously added appenders as an AppenderList.
*/ */
virtual AppenderList getAllAppenders() const = 0; virtual AppenderList getAllAppenders() const = 0;
/** /**
* Get an appender by name. * Get an appender by name.
*/ */
virtual AppenderPtr getAppender(const String& name) const = 0; virtual AppenderPtr getAppender(const LogString& name) const = 0;
/** /**
Returns <code>true</code> if the specified appender Returns <code>true</code> if the specified appender is in list of
is in list of attached attached, <code>false</code> otherwise.
attached attached, <code>false</code> otherwise. */
*/ virtual bool isAttached(const AppenderPtr& appender) const = 0;
virtual bool isAttached(const AppenderPtr& appender)
const = 0;
/** /**
* Remove all previously added appenders. * Remove all previously added appenders.
*/ */
virtual void removeAllAppenders() = 0; virtual void removeAllAppenders() = 0;
/** /**
* Remove the appender passed as parameter from the list of app enders. * Remove the appender passed as parameter from the list of app enders.
*/ */
virtual void removeAppender(const AppenderPtr& appender) = 0; virtual void removeAppender(const AppenderPtr& appender) = 0;
/** /**
* Remove the appender with the name passed as parameter from t he * Remove the appender with the name passed as parameter from t he
* list of appenders. * list of appenders.
*/ */
virtual void removeAppender(const String& name) = 0; virtual void removeAppender(const LogString& name) = 0;
// Dtor // Dtor
virtual ~AppenderAttachable(){} virtual ~AppenderAttachable(){}
}; };
LOG4CXX_PTR_DEF(AppenderAttachable);
} }
} }
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#endif //_LOG4CXX_SPI_APPENDER_ATTACHABLE_H_ #endif //_LOG4CXX_SPI_APPENDER_ATTACHABLE_H_
 End of changes. 10 change blocks. 
22 lines changed or deleted 26 lines changed or added


 appenderattachableimpl.h   appenderattachableimpl.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_HELPERS_APPENDER_ATTACHABLE_IMPL_H #ifndef _LOG4CXX_HELPERS_APPENDER_ATTACHABLE_IMPL_H
#define _LOG4CXX_HELPERS_APPENDER_ATTACHABLE_IMPL_H #define _LOG4CXX_HELPERS_APPENDER_ATTACHABLE_IMPL_H
#if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/spi/appenderattachable.h> #include <log4cxx/spi/appenderattachable.h>
#include <log4cxx/helpers/objectimpl.h> #include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/mutex.h>
#include <log4cxx/helpers/pool.h>
namespace log4cxx namespace log4cxx
{ {
namespace spi namespace spi
{ {
class LoggingEvent; class LoggingEvent;
typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr; typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr;
} }
namespace helpers namespace helpers
{ {
class AppenderAttachableImpl;
typedef log4cxx::helpers::ObjectPtrT<AppenderAttachableImpl>
AppenderAttachableImplPtr;
class LOG4CXX_EXPORT AppenderAttachableImpl : class LOG4CXX_EXPORT AppenderAttachableImpl :
public virtual spi::AppenderAttachable, public virtual spi::AppenderAttachable,
public virtual helpers::ObjectImpl public virtual helpers::ObjectImpl
{ {
protected: protected:
/** Array of appenders. */ /** Array of appenders. */
AppenderList appenderList; AppenderList appenderList;
public: public:
DECLARE_LOG4CXX_OBJECT(AppenderAttachableImpl) /**
BEGIN_LOG4CXX_CAST_MAP() * Create new instance.
LOG4CXX_CAST_ENTRY(AppenderAttachableImpl) * @param pool pool, must be longer-lived than instance.
LOG4CXX_CAST_ENTRY(spi::AppenderAttachable) */
END_LOG4CXX_CAST_MAP() AppenderAttachableImpl(Pool& pool);
// Methods DECLARE_ABSTRACT_LOG4CXX_OBJECT(AppenderAttachableImpl)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(AppenderAttachableImpl)
LOG4CXX_CAST_ENTRY(spi::AppenderAttachable)
END_LOG4CXX_CAST_MAP()
void addRef() const;
void releaseRef() const;
// Methods
/** /**
* Add an appender. * Add an appender.
*/ */
virtual void addAppender(const AppenderPtr& newAppender); virtual void addAppender(const AppenderPtr& newAppender);
/** /**
Call the <code>doAppend</code> method on all attached appender s. Call the <code>doAppend</code> method on all attached appender s.
*/ */
int appendLoopOnAppenders(const spi::LoggingEventPtr& event); int appendLoopOnAppenders(const spi::LoggingEventPtr& event,
log4cxx::helpers::Pool& p);
/** /**
* Get all previously added appenders as an Enumeration. * Get all previously added appenders as an Enumeration.
*/ */
virtual AppenderList getAllAppenders() const; virtual AppenderList getAllAppenders() const;
/** /**
* Get an appender by name. * Get an appender by name.
*/ */
virtual AppenderPtr getAppender(const String& name) const; virtual AppenderPtr getAppender(const LogString& name) const;
/** /**
Returns <code>true</code> if the specified appender is in the Returns <code>true</code> if the specified appender is in the
list of attached appenders, <code>false</code> otherwise. list of attached appenders, <code>false</code> otherwise.
*/ */
virtual bool isAttached(const AppenderPtr& appender) const; virtual bool isAttached(const AppenderPtr& appender) const;
/** /**
* Remove all previously added appenders. * Remove all previously added appenders.
*/ */
skipping to change at line 93 skipping to change at line 108
/** /**
* Remove the appender passed as parameter from the list of app enders. * Remove the appender passed as parameter from the list of app enders.
*/ */
virtual void removeAppender(const AppenderPtr& appender); virtual void removeAppender(const AppenderPtr& appender);
/** /**
* Remove the appender with the name passed as parameter from t he * Remove the appender with the name passed as parameter from t he
* list of appenders. * list of appenders.
*/ */
virtual void removeAppender(const String& name); virtual void removeAppender(const LogString& name);
inline const log4cxx::helpers::Mutex& getMutex() const { return
mutex; }
private:
log4cxx::helpers::Mutex mutex;
AppenderAttachableImpl(const AppenderAttachableImpl&);
AppenderAttachableImpl& operator=(const AppenderAttachableImpl&
);
}; };
LOG4CXX_PTR_DEF(AppenderAttachableImpl);
} }
} }
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#endif //_LOG4CXX_HELPERS_APPENDER_ATTACHABLE_IMPL_H #endif //_LOG4CXX_HELPERS_APPENDER_ATTACHABLE_IMPL_H
 End of changes. 12 change blocks. 
20 lines changed or deleted 51 lines changed or added


 appenderskeleton.h   appenderskeleton.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_APPENDER_SKELETON_H #ifndef _LOG4CXX_APPENDER_SKELETON_H
#define _LOG4CXX_APPENDER_SKELETON_H #define _LOG4CXX_APPENDER_SKELETON_H
#if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/appender.h> #include <log4cxx/appender.h>
#include <log4cxx/layout.h> #include <log4cxx/layout.h>
#include <log4cxx/spi/errorhandler.h> #include <log4cxx/spi/errorhandler.h>
#include <log4cxx/spi/filter.h> #include <log4cxx/spi/filter.h>
#include <log4cxx/helpers/objectimpl.h> #include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/mutex.h>
#include <log4cxx/helpers/pool.h>
#include <log4cxx/level.h> #include <log4cxx/level.h>
namespace log4cxx namespace log4cxx
{ {
/** /**
* Implementation base class for all appenders. * Implementation base class for all appenders.
* *
* This class provides the code for common functionality, such as * This class provides the code for common functionality, such as
* support for threshold filtering and support for general filters. * support for threshold filtering and support for general filters.
* */ * */
class LOG4CXX_EXPORT AppenderSkeleton : class LOG4CXX_EXPORT AppenderSkeleton :
public virtual Appender, public virtual Appender,
public virtual helpers::ObjectImpl public virtual helpers::ObjectImpl
{ {
protected: protected:
/** The layout variable does not need to be set if the appen /** The layout variable does not need to be set if the appe
der nder
implementation has its own layout. */ implementation has its own layout. */
LayoutPtr layout; LayoutPtr layout;
/** Appenders are named. */ /** Appenders are named. */
String name; LogString name;
/** /**
There is no level threshold filtering by default. */ There is no level threshold filtering by default. */
LevelPtr threshold; LevelPtr threshold;
/** /**
It is assumed and enforced that errorHandler is never null. It is assumed and enforced that errorHandler is never null.
*/ */
spi::ErrorHandlerPtr errorHandler; spi::ErrorHandlerPtr errorHandler;
/** The first filter in the filter chain. Set to <code>null< /** The first filter in the filter chain. Set to <code>null
/code> </code>
initially. */ initially. */
spi::FilterPtr headFilter; spi::FilterPtr headFilter;
/** The last filter in the filter chain. */ /** The last filter in the filter chain. */
spi::FilterPtr tailFilter; spi::FilterPtr tailFilter;
/** /**
Is this appender closed? Is this appender closed?
*/ */
bool closed; bool closed;
public: log4cxx::helpers::Pool pool;
BEGIN_LOG4CXX_CAST_MAP() log4cxx::helpers::Mutex mutex;
LOG4CXX_CAST_ENTRY(Appender)
LOG4CXX_CAST_ENTRY(spi::OptionHandler)
END_LOG4CXX_CAST_MAP()
AppenderSkeleton(); public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(AppenderSkeleton)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(Appender)
LOG4CXX_CAST_ENTRY(spi::OptionHandler)
END_LOG4CXX_CAST_MAP()
/** AppenderSkeleton();
Finalize this appender by calling the derived class' AppenderSkeleton(const LayoutPtr& layout);
<code>close</code> method.
*/
void finalize();
/** void addRef() const;
Derived appenders should override this method if option stru void releaseRef() const;
cture
requires it.
*/
void activateOptions() {}
void setOption(const String& name, const String& value) {}
/** /**
Add a filter to end of the filter list. Finalize this appender by calling the derived class'
*/ <code>close</code> method.
void addFilter(const spi::FilterPtr& newFilter) ; */
void finalize();
/** /**
Subclasses of <code>AppenderSkeleton</code> should implement Derived appenders should override this method if option str
this ucture
method to perform actual logging. See also AppenderSkeleton: requires it.
:doAppend */
method. virtual void activateOptions(log4cxx::helpers::Pool& /* poo
*/ l */) {}
protected: virtual void setOption(const LogString& option, const LogSt
virtual void append(const spi::LoggingEventPtr& event) = 0; ring& value);
/** /**
Clear the filters chain. Add a filter to end of the filter list.
*/ */
public: void addFilter(const spi::FilterPtr& newFilter) ;
void clearFilters();
/** /**
Return the currently set spi::ErrorHandler for this Subclasses of <code>AppenderSkeleton</code> should implemen
Appender. t this
*/ method to perform actual logging. See also AppenderSkeleton
const spi::ErrorHandlerPtr& getErrorHandler() const { return ::doAppend
errorHandler; } method.
*/
protected:
virtual void append(const spi::LoggingEventPtr& event, log4
cxx::helpers::Pool& p) = 0;
/** /**
Returns the head Filter. Clear the filters chain.
*/ */
const spi::FilterPtr& getFilter() const { return headFilter; public:
} void clearFilters();
/** /**
Return the first filter in the filter chain for this Return the currently set spi::ErrorHandler for this
Appender. The return value may be <code>0</code> if no is Appender.
filter is set. */
*/ const spi::ErrorHandlerPtr& getErrorHandler() const { retur
const spi::FilterPtr& getFirstFilter() const { return headFi n errorHandler; }
lter; }
/** /**
Returns the layout of this appender. The value may be 0. Returns the head Filter.
*/ */
const LayoutPtr& getLayout() const { return layout; } spi::FilterPtr getFilter() const { return headFilter; }
/** /**
Returns the name of this Appender. Return the first filter in the filter chain for this
*/ Appender. The return value may be <code>0</code> if no is
const String& getName() const { return name; } filter is set.
*/
const spi::FilterPtr& getFirstFilter() const { return headF
ilter; }
/** /**
Returns this appenders threshold level. See the #setThreshol Returns the layout of this appender. The value may be 0.
d */
method for the meaning of this option. LayoutPtr getLayout() const { return layout; }
*/
const LevelPtr& getThreshold() { return threshold; }
/** /**
Check whether the message level is below the appender's Returns the name of this Appender.
threshold. If there is no threshold set, then the return val */
ue is LogString getName() const { return name; }
always <code>true</code>.
*/
bool isAsSevereAsThreshold(const LevelPtr& level) const;
/** /**
* This method performs threshold checks and invokes filters Returns this appenders threshold level. See the #setThresho
before ld
* delegating actual logging to the subclasses specific method for the meaning of this option.
* AppenderSkeleton#append method. */
* */ const LevelPtr& getThreshold() { return threshold; }
void doAppend(const spi::LoggingEventPtr& event);
/** /**
Set the {@link spi::ErrorHandler ErrorHandler} for this Appe Check whether the message level is below the appender's
nder. threshold. If there is no threshold set, then the return va
*/ lue is
void setErrorHandler(const spi::ErrorHandlerPtr& eh); always <code>true</code>.
*/
bool isAsSevereAsThreshold(const LevelPtr& level) const;
/** /**
Set the layout for this appender. Note that some appenders h * This method performs threshold checks and invokes filters
ave before
their own (fixed) layouts or do not use one. For example, th * delegating actual logging to the subclasses specific
e * AppenderSkeleton#append method.
{@link net::SocketAppender SocketAppender} ignores the layou * */
t set void doAppend(const spi::LoggingEventPtr& event, log4cxx::h
here. elpers::Pool& pool);
*/
void setLayout(const LayoutPtr& layout) { this->layout = lay
out; }
/** /**
Set the name of this Appender. Set the {@link spi::ErrorHandler ErrorHandler} for this App
*/ ender.
void setName(const String& name) { this->name = name; } */
void setErrorHandler(const spi::ErrorHandlerPtr& eh);
/** /**
Set the threshold level. All log events with lower level Set the layout for this appender. Note that some appenders
than the threshold level are ignored by the appender. have
their own (fixed) layouts or do not use one. For example, t
he
{@link net::SocketAppender SocketAppender} ignores the layo
ut set
here.
*/
void setLayout(const LayoutPtr& layout1) { this->layout = l
ayout1; }
<p>In configuration files this option is specified by settin /**
g the Set the name of this Appender.
value of the <b>Threshold</b> option to a level */
string, such as "DEBUG", "INFO" and so on. void setName(const LogString& name1) { this->name.assign(na
*/ me1); }
void setThreshold(const LevelPtr& threshold);
}; // class AppenderSkeleton /**
Set the threshold level. All log events with lower level
than the threshold level are ignored by the appender.
<p>In configuration files this option is specified by setti
ng the
value of the <b>Threshold</b> option to a level
string, such as "DEBUG", "INFO" and so on.
*/
void setThreshold(const LevelPtr& threshold);
}; // class AppenderSkeleton
} // namespace log4cxx } // namespace log4cxx
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#endif //_LOG4CXX_APPENDER_SKELETON_H #endif //_LOG4CXX_APPENDER_SKELETON_H
 End of changes. 31 change blocks. 
151 lines changed or deleted 176 lines changed or added


 asyncappender.h   asyncappender.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_ASYNC_APPENDER_H #ifndef _LOG4CXX_ASYNC_APPENDER_H
#define _LOG4CXX_ASYNC_APPENDER_H #define _LOG4CXX_ASYNC_APPENDER_H
#if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/appenderskeleton.h> #include <log4cxx/appenderskeleton.h>
#include <log4cxx/helpers/appenderattachableimpl.h> #include <log4cxx/helpers/appenderattachableimpl.h>
#include <deque>
#include <log4cxx/spi/loggingevent.h>
#include <log4cxx/helpers/thread.h> #include <log4cxx/helpers/thread.h>
#include <log4cxx/helpers/mutex.h>
#include <log4cxx/helpers/condition.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers
{
class BoundedFIFO;
typedef ObjectPtrT<BoundedFIFO> BoundedFIFOPtr;
}
class Dispatcher; /**
typedef helpers::ObjectPtrT<Dispatcher> DispatcherPtr; The AsyncAppender lets users log events asynchronously. It uses a
bounded buffer to store logging events.
class AsyncAppender; <p>The AsyncAppender will collect the events sent to it and then
typedef helpers::ObjectPtrT<AsyncAppender> AsyncAppenderPtr; dispatch them to all the appenders that are attached to it. You can
attach multiple appenders to an AsyncAppender.
/** <p>The AsyncAppender uses a separate thread to serve the events in
The AsyncAppender lets users log events asynchronously. It uses a its bounded buffer.
bounded buffer to store logging events.
<p>The AsyncAppender will collect the events sent to it and then <p><b>Important note:</b> The <code>AsyncAppender</code> can only
dispatch them to all the appenders that are attached to it. You can be script configured using the {@link xml::DOMConfigurator DOMConfi
attach multiple appenders to an AsyncAppender. gurator}.
*/
class LOG4CXX_EXPORT AsyncAppender :
public virtual spi::AppenderAttachable,
public virtual AppenderSkeleton
{
public:
DECLARE_LOG4CXX_OBJECT(AsyncAppender)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(AsyncAppender)
LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
LOG4CXX_CAST_ENTRY(spi::AppenderAttachable)
END_LOG4CXX_CAST_MAP()
<p>The AsyncAppender uses a separate thread to serve the events in /**
its bounded buffer. * Create new instance.
*/
AsyncAppender();
<p><b>Important note:</b> The <code>AsyncAppender</code> can only /**
be script configured using the {@link xml::DOMConfigurator DOMConfig * Destructor.
urator}. */
*/ virtual ~AsyncAppender();
class LOG4CXX_EXPORT AsyncAppender :
public virtual spi::AppenderAttachable,
public virtual AppenderSkeleton
{
friend class Dispatcher;
public: void addRef() const;
DECLARE_LOG4CXX_OBJECT(AsyncAppender) void releaseRef() const;
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(AsyncAppender)
LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
LOG4CXX_CAST_ENTRY(spi::AppenderAttachable)
END_LOG4CXX_CAST_MAP()
/** The default buffer size is set to 128 events. */ /**
static int DEFAULT_BUFFER_SIZE; * Add appender.
*
* @param newAppender appender to add, may not be null.
*/
void addAppender(const AppenderPtr& newAppender);
helpers::BoundedFIFOPtr bf; void append(const spi::LoggingEventPtr& event, log4cxx::hel
helpers::AppenderAttachableImplPtr aai; pers::Pool& p);
DispatcherPtr dispatcher;
bool locationInfo;
bool interruptedWarningMessage;
AsyncAppender(); /**
virtual ~AsyncAppender(); Close this <code>AsyncAppender</code> by interrupting the
dispatcher thread which will process all pending events bef
ore
exiting.
*/
void close();
void addAppender(const AppenderPtr& newAppender); /**
* Get iterator over attached appenders.
* @return list of all attached appenders.
*/
AppenderList getAllAppenders() const;
void append(const spi::LoggingEventPtr& event); /**
* Get appender by name.
*
* @param name name, may not be null.
* @return matching appender or null.
*/
AppenderPtr getAppender(const LogString& name) const;
/** /**
Close this <code>AsyncAppender</code> by interrupting the * Gets whether the location of the logging request call
dispatcher thread which will process all pending events befo * should be captured.
re *
exiting. * @return the current value of the <b>LocationInfo</b> opt
*/ ion.
void close(); */
bool getLocationInfo() const;
/**
* Determines if specified appender is attached.
* @param appender appender.
* @return true if attached.
*/
bool isAttached(const AppenderPtr& appender) const;
AppenderList getAllAppenders() const; virtual bool requiresLayout() const;
AppenderPtr getAppender(const String& name) const;
/** /**
Returns the current value of the <b>LocationInfo</b> option. * Removes and closes all attached appenders.
*/ */
inline bool getLocationInfo() const void removeAllAppenders();
{ return locationInfo; }
/** /**
Is the appender passed as parameter attached to this asyncap * Removes an appender.
pender? * @param appender appender to remove.
*/ */
bool isAttached(const AppenderPtr& appender) const; void removeAppender(const AppenderPtr& appender);
/**
* Remove appender by name.
* @param name name.
*/
void removeAppender(const LogString& name);
void removeAllAppenders(); /**
void removeAppender(const AppenderPtr& appender); * The <b>LocationInfo</b> attribute is provided for compati
void removeAppender(const String& name); bility
* with log4j and has no effect on the log output.
* @param flag new value.
*/
void setLocationInfo(bool flag);
/** /**
The <code>AsyncAppender</code> does not require a layout. He * The <b>BufferSize</b> option takes a non-negative integer
nce, value.
this method always returns <code>false</code>. * This integer value determines the maximum size of the bou
*/ nded
virtual bool requiresLayout() const * buffer.
{ return false; } * */
void setBufferSize(int size);
/** /**
* The <b>LocationInfo</b> option takes a boolean value. By d * Gets the current buffer size.
efault, * @return the current value of the <b>BufferSize</b> optio
* it is set to false which means there will be no effort to n.
extract */
* the location information related to the event. As a result int getBufferSize() const;
, the
* event that will be ultimately logged will likely to contai
n the
* wrong location information (if present in the log format).
*
* <p>Location information extraction is comparatively very s
low and
* should be avoided unless performance is not a concern.
* */
inline void setLocationInfo(bool flag)
{ locationInfo = flag; }
/** /**
* The <b>BufferSize</b> option takes a non-negative integer * Sets whether appender should wait if there is no
value. * space available in the event buffer or immediately retur
* This integer value determines the maximum size of the boun n.
ded *
* buffer. Increasing the size of the buffer is always * @param value true if appender should wait until availabl
* safe. However, if an existing buffer holds unwritten eleme e space in buffer.
nts, */
* then <em>decreasing the buffer size will result in event void setBlocking(bool value);
* loss.</em> Nevertheless, while script configuring the
* AsyncAppender, it is safe to set a buffer size smaller tha
n the
* {@link #DEFAULT_BUFFER_SIZE default buffer size} because
* configurators guarantee that an appender cannot be used be
fore
* being completely configured.
* */
void setBufferSize(int size);
/** /**
Returns the current value of the <b>BufferSize</b> option. * Gets whether appender should block calling thread when b
*/ uffer is full.
int getBufferSize() const; * If false, messages will be counted by logger and a summa
}; // class AsyncAppender ry
* message appended after the contents of the buffer have b
een appended.
*
* @return true if calling thread will be blocked when buff
er is full.
*/
bool getBlocking() const;
class LOG4CXX_EXPORT Dispatcher : public helpers::Thread /**
{ * Set appender properties by name.
helpers::BoundedFIFOPtr bf; * @param option property name.
helpers::AppenderAttachableImplPtr aai; * @param value property value.
bool interrupted; */
AsyncAppender * container; void setOption(const LogString& option, const LogString& v
alue);
public: private:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Dispatcher) AsyncAppender(const AsyncAppender&);
BEGIN_LOG4CXX_CAST_MAP() AsyncAppender& operator=(const AsyncAppender&);
LOG4CXX_CAST_ENTRY(Dispatcher) /**
LOG4CXX_CAST_ENTRY_CHAIN(Thread) * The default buffer size is set to 128 events.
END_LOG4CXX_CAST_MAP() */
enum { DEFAULT_BUFFER_SIZE = 128 };
Dispatcher(helpers::BoundedFIFOPtr bf, AsyncAppender * conta /**
iner); * Event buffer.
void close(); */
LOG4CXX_LIST_DEF(LoggingEventList, log4cxx::spi::LoggingEve
ntPtr);
LoggingEventList buffer;
/** /**
The dispatching strategy is to wait until there are events i * Mutex used to guard access to buffer and discardMap.
n the */
buffer to process. After having processed an event, we relea ::log4cxx::helpers::Mutex bufferMutex;
se ::log4cxx::helpers::Condition bufferNotFull;
the monitor (variable bf) so that new events can be placed i ::log4cxx::helpers::Condition bufferNotEmpty;
n the
buffer, instead of keeping the monitor and processing the re class DiscardSummary {
maining private:
events in the buffer. /**
<p>Other approaches might yield better results. * First event of the highest severity.
*/ */
void run(); ::log4cxx::spi::LoggingEventPtr maxEvent;
}; // class Dispatcher
/**
* Total count of messages discarded.
*/
int count;
public:
/**
* Create new instance.
*
* @param event event, may not be null.
*/
DiscardSummary(const ::log4cxx::spi::LoggingEventPtr& e
vent);
/** Copy constructor. */
DiscardSummary(const DiscardSummary& src);
/** Assignment operator. */
DiscardSummary& operator=(const DiscardSummary& src);
/**
* Add discarded event to summary.
*
* @param event event, may not be null.
*/
void add(const ::log4cxx::spi::LoggingEventPtr& event);
/**
* Create event with summary information.
*
* @return new event.
*/
::log4cxx::spi::LoggingEventPtr createEvent(::log4cxx:
:helpers::Pool& p);
};
/**
* Map of DiscardSummary objects keyed by logger name.
*/
typedef std::map<LogString, DiscardSummary> DiscardMap;
DiscardMap* discardMap;
/**
* Buffer size.
*/
int bufferSize;
/**
* Nested appenders.
*/
helpers::AppenderAttachableImplPtr appenders;
/**
* Dispatcher.
*/
helpers::Thread dispatcher;
/**
* Should location info be included in dispatched messages.
*/
bool locationInfo;
/**
* Does appender block when buffer is full.
*/
bool blocking;
/**
* Dispatch routine.
*/
static void* LOG4CXX_THREAD_FUNC dispatch(apr_thread_t* thr
ead, void* data);
}; // class AsyncAppender
LOG4CXX_PTR_DEF(AsyncAppender);
} // namespace log4cxx } // namespace log4cxx
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#endif// _LOG4CXX_ASYNC_APPENDER_H #endif// _LOG4CXX_ASYNC_APPENDER_H
 End of changes. 31 change blocks. 
147 lines changed or deleted 257 lines changed or added


 basicconfigurator.h   basicconfigurator.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_BASIC_CONFIGURATOR_H #ifndef _LOG4CXX_BASIC_CONFIGURATOR_H
#define _LOG4CXX_BASIC_CONFIGURATOR_H #define _LOG4CXX_BASIC_CONFIGURATOR_H
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/objectimpl.h> #include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/config.h> #include <log4cxx/logger.h>
#include <log4cxx/helpers/tchar.h> #include <log4cxx/logstring.h>
#include <log4cxx/spi/configurator.h> #include <log4cxx/spi/configurator.h>
#include <map>
namespace log4cxx namespace log4cxx
{ {
class Appender; class Appender;
typedef helpers::ObjectPtrT<Appender> AppenderPtr; typedef helpers::ObjectPtrT<Appender> AppenderPtr;
/** /**
Use this class to quickly configure the package. Use this class to quickly configure the package.
<p>For file based configuration see <p>For file based configuration see
PropertyConfigurator. For XML based configuration see PropertyConfigurator. For XML based configuration see
DOMConfigurator. DOMConfigurator.
*/ */
class LOG4CXX_EXPORT BasicConfigurator class LOG4CXX_EXPORT BasicConfigurator
{ {
protected: protected:
BasicConfigurator() {} BasicConfigurator() {}
public: public:
/** /**
Add a ConsoleAppender that uses PatternLayout Add a ConsoleAppender that uses PatternLayout
using the PatternLayout#TTCC_CONVERSION_PATTERN and using the PatternLayout#TTCC_CONVERSION_PATTERN and
prints to <code>stdout</code> to the root logger.*/ prints to <code>stdout</code> to the root logger.*/
static void configure(); static void configure();
/** /**
Add <code>appender</code> to the root logger. Add <code>appender</code> to the root logger.
@param appender The appender to add to the root logger. @param appender The appender to add to the root logger.
*/ */
static void configure(const AppenderPtr& appender); static void configure(const AppenderPtr& appender);
/** /**
Reset the default hierarchy to its defaut. It is equivalent Reset the default hierarchy to its defaut. It is equivalent to
to calling
calling <code>Logger::getDefaultHierarchy()->resetConfiguration()</code>.
<code>Logger::getDefaultHierarchy()->resetConfiguration()</c See Hierarchy#resetConfiguration() for more details. */
ode>. static void resetConfiguration();
See Hierarchy#resetConfiguration() for more details. */ }; // class BasicConfigurator
static void resetConfiguration();
}; // class BasicConfigurator
} // namespace log4cxx } // namespace log4cxx
#endif //_LOG4CXX_BASIC_CONFIGURATOR_H #endif //_LOG4CXX_BASIC_CONFIGURATOR_H
 End of changes. 8 change blocks. 
40 lines changed or deleted 38 lines changed or added


 class.h   class.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_HELPERS_CLASS_H #ifndef _LOG4CXX_HELPERS_CLASS_H
#define _LOG4CXX_HELPERS_CLASS_H #define _LOG4CXX_HELPERS_CLASS_H
#include <log4cxx/helpers/tchar.h> #if defined(_MSC_VER)
#pragma warning (push)
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
#include <map>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class Object; class Object;
typedef ObjectPtrT<Object> ObjectPtr; typedef ObjectPtrT<Object> ObjectPtr;
/** class LOG4CXX_EXPORT Class
Thrown when an application tries to create an instance of a {
class using public:
the newInstance method in class Class, but the specified cla virtual ~Class();
ss object virtual ObjectPtr newInstance() const;
cannot be instantiated because it is an interface or is an a LogString toString() const;
bstract class. virtual LogString getName() const = 0;
*/ static const Class& forName(const LogString& classN
class LOG4CXX_EXPORT InstantiationException : public Excepti ame);
on static bool registerClass(const Class& newClass);
{
public:
InstantiationException() : Exception(_T("Abstract cl
ass")) {}
};
/** protected:
Thrown when an application tries to load in a class through Class();
its
string name but no definition for the class with the specifi
ed name
could be found.
*/
class LOG4CXX_EXPORT ClassNotFoundException : public Excepti
on
{
public:
ClassNotFoundException(const String& className);
};
class LOG4CXX_EXPORT Class private:
{ Class(const Class&);
public: Class& operator=(const Class&);
Class(const String& name); typedef std::map<LogString, const Class *> ClassMap
virtual ObjectPtr newInstance() const; ;
const String& toString() const; static ClassMap& getRegistry();
const String& getName() const; static void registerClasses();
static const Class& forName(const String& className) };
; } // namespace log4cxx
} // namespace helper
protected: #if defined(_MSC_VER)
static void registerClass(const Class * newClass); #pragma warning (pop)
String name; #endif
};
} // namespace log4cxx
}; // namespace helper
#endif //_LOG4CXX_HELPERS_CLASS_H #endif //_LOG4CXX_HELPERS_CLASS_H
 End of changes. 8 change blocks. 
53 lines changed or deleted 42 lines changed or added


 condition.h   condition.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_HELPERS_CONDITION_H #ifndef _LOG4CXX_HELPERS_CONDITION_H
#define _LOG4CXX_HELPERS_CONDITION_H #define _LOG4CXX_HELPERS_CONDITION_H
#include <log4cxx/config.h> #include <log4cxx/log4cxx.h>
#include <log4cxx/helpers/exception.h>
#include <log4cxx/helpers/mutex.h> #include <log4cxx/helpers/mutex.h>
#include <log4cxx/helpers/semaphore.h>
#ifdef HAVE_PTHREAD extern "C" {
#include <pthread.h> struct apr_thread_cond_t;
#endif }
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class LOG4CXX_EXPORT ConditionException : public Exception class Pool;
{
};
class LOG4CXX_EXPORT Condition
{
public:
Condition();
~Condition();
void broadcast();
void signal();
void wait(Mutex& mutex);
void wait(Mutex& mutex, long timeOut);
protected:
#ifdef HAVE_PTHREAD
pthread_cond_t condition;
#elif defined(HAVE_MS_THREAD)
/// Number of waiting threads.
long volatile waiters;
/// Queue up threads waiting for the condition to be
come signaled.
Semaphore sema;
/** /**
* An auto reset event used by the broadcast/signal t * This class provides a means for one thread to suspend
hread to wait exception until
* for the waiting thread(s) to wake up and get a cha * notified by another thread to resume. This class shou
nce at the ld have
* semaphore. * similar semantics to java.util.concurrent.locks.Condit
*/ ion.
void * waitersDone; */
class LOG4CXX_EXPORT Condition
{
public:
/**
* Create new instance.
* @param p pool on which condition will be create
d. Needs to be
* longer-lived than created instance.
*/
Condition(log4cxx::helpers::Pool& p);
/**
* Destructor.
*/
~Condition();
/**
* Signal all waiting threads.
*/
log4cxx_status_t signalAll();
/**
* Await signaling of condition.
* @param lock lock associated with condition, cal
ling thread must
* own lock. Lock will be released while waiting
and reacquired
* before returning from wait.
* @throws InterruptedException if thread is inter
rupted.
*/
void await(Mutex& lock);
/// Keeps track of whether we were broadcasting or j private:
ust signaling. apr_thread_cond_t* condition;
bool wasBroadCast; Condition(const Condition&);
#endif Condition& operator=(const Condition&);
}; };
} // namespace helpers } // namespace helpers
};// namespace log4cxx } // namespace log4cxx
#endif //_LOG4CXX_HELPERS_CONDITION_H #endif //_LOG4CXX_HELPERS_CONDITION_H
 End of changes. 7 change blocks. 
52 lines changed or deleted 57 lines changed or added


 configurator.h   configurator.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_SPI_CONFIGURATOR_H #ifndef _LOG4CXX_SPI_CONFIGURATOR_H
#define _LOG4CXX_SPI_CONFIGURATOR_H #define _LOG4CXX_SPI_CONFIGURATOR_H
#include <log4cxx/helpers/tchar.h> #include <log4cxx/spi/loggerrepository.h>
#include <log4cxx/helpers/object.h>
#include <log4cxx/helpers/objectptr.h>
namespace log4cxx namespace log4cxx
{ {
namespace spi class File;
{
class LoggerRepository;
typedef helpers::ObjectPtrT<LoggerRepository> LoggerReposito
ryPtr;
class Configurator; namespace spi
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)
Configurator();
/** /**
Implemented by classes capable of configuring log4j using a Interpret a resource pointed by a URL and set up log4j accordingly
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"*/;
/** The configuration is done relative to the <code>hierarchy</code>
Special level signifying inherited behaviour, same a parameter.
s
#INHERITED. The current value of this string constan
t is
<b>null</b>. */
static String NuLL /*= "null"*/;
/** @param configFileName The file to parse
Interpret a resource pointed by a URL and set up log @param repository The hierarchy to operation upon.
4j accordingly. */
virtual void doConfigure(const File& configFileName,
spi::LoggerRepositoryPtr& repository) = 0;
The configuration is done relative to the <code>hier private:
archy</code> Configurator(const Configurator&);
parameter. Configurator& operator=(const Configurator&);
bool initialized;
};
@param configFileName The file to parse LOG4CXX_PTR_DEF(Configurator);
@param repository The hierarchy to operation upon. }
*/
virtual void doConfigure(const String& configFileNam
e,
spi::LoggerRepositoryPtr& repository) = 0;
};
}
} }
#endif // _LOG4CXX_SPI_CONFIGURATOR_H #endif // _LOG4CXX_SPI_CONFIGURATOR_H
 End of changes. 9 change blocks. 
52 lines changed or deleted 35 lines changed or added


 consoleappender.h   consoleappender.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_CONSOLE_APPENDER_H #ifndef _LOG4CXX_CONSOLE_APPENDER_H
#define _LOG4CXX_CONSOLE_APPENDER_H #define _LOG4CXX_CONSOLE_APPENDER_H
#include <log4cxx/writerappender.h> #include <log4cxx/writerappender.h>
namespace log4cxx namespace log4cxx
{ {
class ConsoleAppender;
typedef helpers::ObjectPtrT<ConsoleAppender> ConsoleAppenderPtr;
/**
* ConsoleAppender appends log events to <code>stdout</code> or
* <code>stderr</code> using a layout specified by the user. The
* default target is <code>stdout</code>.
*/
class LOG4CXX_EXPORT ConsoleAppender : public WriterAppender
{
public:
DECLARE_LOG4CXX_OBJECT(ConsoleAppender)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(ConsoleAppender)
LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
END_LOG4CXX_CAST_MAP()
ConsoleAppender(); /**
ConsoleAppender(const LayoutPtr& layout); * ConsoleAppender appends log events to <code>stdout</code> or
ConsoleAppender(const LayoutPtr& layout, const String& targe * <code>stderr</code> using a layout specified by the user. The
t); * default target is <code>stdout</code>.
~ConsoleAppender(); */
class LOG4CXX_EXPORT ConsoleAppender : public WriterAppender
{
private:
LogString target;
/** public:
* This method overrides the parent DECLARE_LOG4CXX_OBJECT(ConsoleAppender)
* WriterAppender#closeWriter implementation to do nothing because BEGIN_LOG4CXX_CAST_MAP()
* the console stream is not ours to close. LOG4CXX_CAST_ENTRY(ConsoleAppender)
* */ LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
protected: END_LOG4CXX_CAST_MAP()
virtual void closeWriter() {}
/** ConsoleAppender();
* Sets the value of the <b>#target</b> property. Recognized values ConsoleAppender(const LayoutPtr& layout);
* are "System.out" and "System.err". Any other value will be ConsoleAppender(const LayoutPtr& layout, const LogString& t
* ignored. arget);
* */ ~ConsoleAppender();
public:
void setTarget(const String& value);
/** /**
* Returns the current value of the <b>#target</b> property. The * Sets the value of the <b>target</b> property. Recognized
* default value of the option is "System.out". values
* * are "System.out" and "System.err". Any other value will
* See also #setTarget. be
* */ * ignored.
public: * */
const String& getTarget() const; void setTarget(const LogString& value);
protected: /**
void targetWarn(const String& val); * Returns the current value of the <b>target</b> property.
The
* default value of the option is "System.out".
*
* See also #setTarget.
* */
LogString getTarget() const;
public: void activateOptions(log4cxx::helpers::Pool& p);
void activateOptions(); void setOption(const LogString& option, const LogString& va
void setOption(const String& option, const String& value); lue);
static const LogString& getSystemOut();
static const LogString& getSystemErr();
public: private:
static String SYSTEM_OUT; void targetWarn(const LogString& val);
static String SYSTEM_ERR; static log4cxx::helpers::WriterPtr createWriter(const LogSt
ring& target);
protected: };
String target; LOG4CXX_PTR_DEF(ConsoleAppender);
};
} //namespace log4cxx } //namespace log4cxx
#endif //_LOG4CXX_CONSOLE_APPENDER_H #endif //_LOG4CXX_CONSOLE_APPENDER_H
 End of changes. 10 change blocks. 
59 lines changed or deleted 53 lines changed or added


 cyclicbuffer.h   cyclicbuffer.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_HELPERS_CYCLICBUFFER_H #ifndef _LOG4CXX_HELPERS_CYCLICBUFFER_H
#define _LOG4CXX_HELPERS_CYCLICBUFFER_H #define _LOG4CXX_HELPERS_CYCLICBUFFER_H
#include <log4cxx/spi/loggingevent.h> #include <log4cxx/spi/loggingevent.h>
#include <vector>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
/** /**
CyclicBuffer is used by other appenders to hold {@link spi:: CyclicBuffer is used by other appenders to hold instances o
LoggingEvent f
LoggingEvents} for immediate or differed display. {@link log4cxx::spi::LoggingEvent LoggingEvent} for immedia
<p>This buffer gives read access to any element in the buffe te
r not or deferred display.
just the first or last element. <p>This buffer gives read access to any element in the buff
*/ er not
class LOG4CXX_EXPORT CyclicBuffer just the first or last element.
{ */
std::vector<spi::LoggingEventPtr> ea; class LOG4CXX_EXPORT CyclicBuffer
int first; {
int last; log4cxx::spi::LoggingEventList ea;
int numElems; int first;
int maxSize; int last;
int numElems;
int maxSize;
public: public:
/** /**
Instantiate a new CyclicBuffer of at most <code>maxS Instantiate a new CyclicBuffer of at most <code>max
ize</code> Size</code>
events. events.
The <code>maxSize</code> argument must a positive in The <code>maxSize</code> argument must a positive i
teger. nteger.
@param maxSize The maximum number of elements in the @param maxSize The maximum number of elements in th
buffer. e buffer.
@throws IllegalArgumentException if <code>maxSize</c @throws IllegalArgumentException if <code>maxSize</
ode> code>
is negative. is negative.
*/ */
CyclicBuffer(int maxSize); CyclicBuffer(int maxSize);
~CyclicBuffer(); ~CyclicBuffer();
/** /**
Add an <code>event</code> as the last event in the b Add an <code>event</code> as the last event in the
uffer. buffer.
*/ */
void add(const spi::LoggingEventPtr& event); void add(const spi::LoggingEventPtr& event);
/** /**
Get the <i>i</i>th oldest event currently in the buf Get the <i>i</i>th oldest event currently in the bu
fer. If ffer. If
<em>i</em> is outside the range 0 to the number of e <em>i</em> is outside the range 0 to the number of
lements elements
currently in the buffer, then <code>null</code> is r currently in the buffer, then <code>null</code> is
eturned. returned.
*/ */
spi::LoggingEventPtr get(int i); spi::LoggingEventPtr get(int i);
int getMaxSize() const int getMaxSize() const
{ return maxSize; } { return maxSize; }
/** /**
Get the oldest (first) element in the buffer. The ol Get the oldest (first) element in the buffer. The o
dest element ldest element
is removed from the buffer. is removed from the buffer.
*/ */
spi::LoggingEventPtr get(); spi::LoggingEventPtr get();
/** /**
Get the number of elements in the buffer. This numbe Get the number of elements in the buffer. This numb
r is er is
guaranteed to be in the range 0 to <code>maxSize</co guaranteed to be in the range 0 to <code>maxSize</c
de> ode>
(inclusive). (inclusive).
*/ */
int length() const int length() const
{ return numElems; } { return numElems; }
/** /**
Resize the cyclic buffer to <code>newSize</code>. Resize the cyclic buffer to <code>newSize</code>.
@throws IllegalArgumentException if <code>newSize</c @throws IllegalArgumentException if <code>newSize</
ode> is negative. code> is negative.
*/ */
void resize(int newSize); void resize(int newSize);
}; // class CyclicBuffer }; // class CyclicBuffer
} //namespace helpers } //namespace helpers
}; //namespace log4cxx } //namespace log4cxx
#endif //_LOG4CXX_HELPERS_CYCLICBUFFER_H #endif //_LOG4CXX_HELPERS_CYCLICBUFFER_H
 End of changes. 10 change blocks. 
78 lines changed or deleted 80 lines changed or added


 dailyrollingfileappender.h   dailyrollingfileappender.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_DAILY_ROLLING_FILE_APPENDER_H #ifndef _LOG4CXX_DAILYROLLINGFILEAPPENDER_H
#define _LOG4CXX_DAILY_ROLLING_FILE_APPENDER_H #define _LOG4CXX_DAILYROLLINGFILEAPPENDER_H
#include <log4cxx/fileappender.h>
#include <log4cxx/helpers/timezone.h>
namespace log4cxx
{
namespace helpers
{
class DateFormat;
}
/**
* RollingCalendar is a helper class to DailyRollingFileAppender.
* Given a periodicity type and the current time, it computes the
* start of the next interval.
* */
class LOG4CXX_EXPORT RollingCalendar
{
public:
// The code assumes that the following constants are in a in
creasing
// sequence.
typedef enum PeriodicityType
{
TOP_OF_TROUBLE =-1,
TOP_OF_MINUTE = 0,
TOP_OF_HOUR = 1,
HALF_DAY = 2,
TOP_OF_DAY = 3,
TOP_OF_WEEK = 4,
TOP_OF_MONTH = 5,
};
RollingCalendar();
RollingCalendar(const helpers::TimeZonePtr& timeZone);
inline void setType(PeriodicityType type)
{ this->type = type; }
/**
This method computes the roll over period by looping over th
e
periods, starting with the shortest, and stopping when the r
0 is
different from from r1, where r0 is the epoch formatted acco
rding
the datePattern (supplied by the user) and r1 is the
epoch+nextMillis(i) formatted according to datePattern. All
date
formatting is done in GMT and not local format because the t
est
logic is based on comparisons relative to 1970-01-01 00:00:0
0
GMT (the epoch).
*/
PeriodicityType computeTriggeringPeriod(const String& datePa
ttern);
void printPeriodicity();
int64_t getNextCheckMillis(int64_t now);
/** #if defined(_MSC_VER)
Gets the time zone. #pragma warning ( push )
@return the time zone object associated with this calendar. #pragma warning ( disable: 4231 4251 4275 4786 )
*/ #endif
inline const helpers::TimeZonePtr getTimeZone() const
{ return timeZone; }
/** #include <log4cxx/appender.h>
Sets the time zone with the given time zone value. #include <log4cxx/fileappender.h>
@return value the given time zone. #include <log4cxx/spi/optionhandler.h>
*/ #include <log4cxx/rolling/rollingfileappenderskeleton.h>
inline void setTimeZone(const helpers::TimeZonePtr& timeZone
)
{ this->timeZone = timeZone; }
protected: namespace log4cxx {
PeriodicityType type; namespace helpers {
helpers::TimeZonePtr timeZone; class Pool;
static helpers::TimeZonePtr GMT_TIMEZONE; }
};
class DailyRollingFileAppender; namespace spi {
typedef helpers::ObjectPtrT<DailyRollingFileAppender> DailyRollingFi class ErrorHandler;
leAppenderPtr; typedef log4cxx::helpers::ObjectPtrT<ErrorHandler> ErrorHandlerPtr;
}
/** /**
DailyRollingFileAppender extends {@link FileAppender} so that the DailyRollingFileAppender extends {@link log4cxx::FileAppender FileAppend
underlying file is rolled over at a user chosen frequency. er} so that the
underlying file is rolled over at a user chosen frequency.
<p>The rolling schedule is specified by the <b>DatePattern</b> <p>The rolling schedule is specified by the <b>DatePattern</b>
option. This pattern should follow the helpers::DateFormat option. This pattern should follow the
conventions. In particular, you <em>must</em> escape literal text {@link log4cxx::helpers::SimpleDateFormat SimpleDateFormat}
within a pair of single quotes. A formatted version of the date conventions. In particular, you <em>must</em> escape literal text
pattern is used as the suffix for the rolled file name. within a pair of single quotes. A formatted version of the date
pattern is used as the suffix for the rolled file name.
<p>For example, if the <b>File</b> option is set to <p>For example, if the <b>File</b> option is set to
<code>/foo/bar.log</code> and the <b>DatePattern</b> set to <code>/foo/bar.log</code> and the <b>DatePattern</b> set to
<code>'.'yyyy-MM-dd</code>, on 2001-02-16 at midnight, the logging <code>'.'yyyy-MM-dd</code>, on 2001-02-16 at midnight, the logging
file <code>/foo/bar.log</code> will be copied to file <code>/foo/bar.log</code> will be copied to
<code>/foo/bar.log.2001-02-16</code> and logging for 2001-02-17 <code>/foo/bar.log.2001-02-16</code> and logging for 2001-02-17
will continue in <code>/foo/bar.log</code> until it rolls over will continue in <code>/foo/bar.log</code> until it rolls over
the next day. the next day.
<p>Is is possible to specify monthly, weekly, half-daily, daily, <p>Is is possible to specify monthly, weekly, half-daily, daily,
hourly, or minutely rollover schedules. hourly, or minutely rollover schedules.
<p><table border="1" cellpadding="2"> <p><table border="1" cellpadding="2">
<tr> <tr>
<th>DatePattern</th> <th>DatePattern</th>
<th>Rollover schedule</th> <th>Rollover schedule</th>
<th>Example</th> <th>Example</th>
<tr> <tr>
<td><code>'.'yyyy-MM</code> <td><code>'.'yyyy-MM</code>
<td>Rollover at the beginning of each month</td> <td>Rollover at the beginning of each month</td>
<td>At midnight of May 31st, 2002 <code>/foo/bar.log</code> will be <td>At midnight of May 31st, 2002 <code>/foo/bar.log</code> will be
copied to <code>/foo/bar.log.2002-05</code>. Logging for the month copied to <code>/foo/bar.log.2002-05</code>. Logging for the month
of June will be output to <code>/foo/bar.log</code> until it is of June will be output to <code>/foo/bar.log</code> until it is
also rolled over the next month. also rolled over the next month.
<tr> <tr>
<td><code>'.'yyyy-ww</code> <td><code>'.'yyyy-ww</code>
<td>Rollover at the first day of each week. The first day of the <td>Rollover at the first day of each week. The first day of the
week depends on the locale.</td> week depends on the locale.</td>
<td>Assuming the first day of the week is Sunday, on Saturday <td>Assuming the first day of the week is Sunday, on Saturday
midnight, June 9th 2002, the file <i>/foo/bar.log</i> will be midnight, June 9th 2002, the file <i>/foo/bar.log</i> will be
copied to <i>/foo/bar.log.2002-23</i>. Logging for the 24th week copied to <i>/foo/bar.log.2002-23</i>. Logging for the 24th week
of 2002 will be output to <code>/foo/bar.log</code> until it is of 2002 will be output to <code>/foo/bar.log</code> until it is
rolled over the next week. rolled over the next week.
<tr> <tr>
<td><code>'.'yyyy-MM-dd</code> <td><code>'.'yyyy-MM-dd</code>
<td>Rollover at midnight each day.</td> <td>Rollover at midnight each day.</td>
<td>At 00:00 AM March 8th, 2002, <code>/foo/bar.log</code> will be <td>At midnight, on March 8th, 2002, <code>/foo/bar.log</code> will
copied to <code>/foo/bar.log.2002-03-07</code>. Logging for the 8th be copied to <code>/foo/bar.log.2002-03-08</code>. Logging for the
day of March will be output to <code>/foo/bar.log</code> until it 9th day of March will be output to <code>/foo/bar.log</code> until
is rolled over the next day. it is rolled over the next day.
<tr> <tr>
<td><code>'.'yyyy-MM-dd-a</code> <td><code>'.'yyyy-MM-dd-a</code>
<td>Rollover at midnight and midday of each day.</td> <td>Rollover at midnight and midday of each day.</td>
<td>At noon, on March 9th, 2002, <code>/foo/bar.log</code> will be <td>At noon, on March 9th, 2002, <code>/foo/bar.log</code> will be
copied to <code>/foo/bar.log.2002-03-09-AM</code>. Logging for the copied to <code>/foo/bar.log.2002-03-09-AM</code>. Logging for the
afternoon of the 9th will be output to <code>/foo/bar.log</code> afternoon of the 9th will be output to <code>/foo/bar.log</code>
until it is rolled over at midnight. until it is rolled over at midnight.
<tr> <tr>
<td><code>'.'yyyy-MM-dd-HH</code> <td><code>'.'yyyy-MM-dd-HH</code>
<td>Rollover at the top of every hour.</td> <td>Rollover at the top of every hour.</td>
<td>At approximately 11:00.000 o'clock on March 9th, 2002, <td>At approximately 11:00.000 o'clock on March 9th, 2002,
<code>/foo/bar.log</code> will be copied to <code>/foo/bar.log</code> will be copied to
<code>/foo/bar.log.2002-03-09-10</code>. Logging for the 11th hour <code>/foo/bar.log.2002-03-09-10</code>. Logging for the 11th hour
of the 9th of March will be output to <code>/foo/bar.log</code> of the 9th of March will be output to <code>/foo/bar.log</code>
until it is rolled over at the beginning of the next hour. until it is rolled over at the beginning of the next hour.
<tr> <tr>
<td><code>'.'yyyy-MM-dd-HH-mm</code> <td><code>'.'yyyy-MM-dd-HH-mm</code>
<td>Rollover at the beginning of every minute.</td> <td>Rollover at the beginning of every minute.</td>
<td>At approximately 11:23,000, on March 9th, 2001, <td>At approximately 11:23,000, on March 9th, 2001,
<code>/foo/bar.log</code> will be copied to <code>/foo/bar.log</code> will be copied to
<code>/foo/bar.log.2001-03-09-11-22</code>. Logging for the minute <code>/foo/bar.log.2001-03-09-10-22</code>. Logging for the minute
of 11:23 (9th of March) will be output to of 11:23 (9th of March) will be output to
<code>/foo/bar.log</code> until it is rolled over the next minute. <code>/foo/bar.log</code> until it is rolled over the next minute.
</table> </table>
<p>Do not use the colon ":" character in anywhere in the <p>Do not use the colon ":" character in anywhere in the
<b>DatePattern</b> option. The text before the colon is interpeted <b>DatePattern</b> option. The text before the colon is interpeted
as the protocol specificaion of a URL which is probably not what as the protocol specificaion of a URL which is probably not what
you want. you want.
**/ */
class LOG4CXX_EXPORT DailyRollingFileAppender : public FileAppender
{
public:
DECLARE_LOG4CXX_OBJECT(DailyRollingFileAppender)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(DailyRollingFileAppender)
LOG4CXX_CAST_ENTRY_CHAIN(FileAppender)
END_LOG4CXX_CAST_MAP()
/** class LOG4CXX_EXPORT DailyRollingFileAppender : public log4cxx::rolling::
The default constructor does nothing. */ RollingFileAppenderSkeleton {
DailyRollingFileAppender(); DECLARE_LOG4CXX_OBJECT(DailyRollingFileAppender)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(DailyRollingFileAppender)
LOG4CXX_CAST_ENTRY_CHAIN(FileAppender)
END_LOG4CXX_CAST_MAP()
/** /**
Instantiate a <code>DailyRollingFileAppender</code> and open The date pattern used to initiate rollover.
the */
file designated by <code>filename</code>. The opened filenam LogString datePattern;
e will
become the ouput destination for this appender.
*/
DailyRollingFileAppender(LayoutPtr& layout,
const String& filename, const String& datePattern);
~DailyRollingFileAppender(); public:
/**
The default constructor simply calls its {@link
FileAppender#FileAppender parents constructor}. */
DailyRollingFileAppender();
/** /**
The <b>DatePattern</b> takes a string in the same format as Instantiate a DailyRollingFileAppender and open the file designated by
expected by helpers::DateFormat. This options determines the <code>filename</code>. The opened filename will become the ouput
rollover schedule. destination for this appender.
*/
inline void setDatePattern(const String& pattern)
{ datePattern = pattern; }
/** Returns the value of the <b>DatePattern</b> option. */ */
inline const String& getDatePattern() const DailyRollingFileAppender(
{ return datePattern; } const LayoutPtr& layout,
const LogString& filename,
const LogString& datePattern);
void activateOptions(); /**
void setOption(const String& option, The <b>DatePattern</b> takes a string in the same format as
const String& value); expected by {@link log4cxx::helpers::SimpleDateFormat SimpleDateFormat
}. This options determines the
rollover schedule.
*/
void setDatePattern(const LogString& pattern);
protected: /** Returns the value of the <b>DatePattern</b> option. */
/** LogString getDatePattern();
Rollover the current file to a new file.
*/
void rollOver();
/** void setOption(const LogString& option,
* This method differentiates DailyRollingFileAppender from i const LogString& value);
ts
* super class.
*
* <p>Before actually logging, this method will check whether
it is
* time to do a rollover. If it is, it will schedule the next
* rollover time and then rollover.
* */
virtual void subAppend(const spi::LoggingEventPtr& event);
/** /**
The date pattern. By default, the pattern is set to * Prepares DailyRollingFileAppender for use.
"'.'yyyy-MM-dd" meaning daily rollover. */
*/ void activateOptions(log4cxx::helpers::Pool&);
String datePattern;
/** };
The log file will be renamed to the value of the
scheduledFilename variable when the next interval is entered
. For
example, if the rollover period is one hour, the log file wi
ll be
renamed to the value of "scheduledFilename" at the beginning
of
the next hour.
The precise time when a rollover occurs depends on logging LOG4CXX_PTR_DEF(DailyRollingFileAppender);
activity.
*/
String scheduledFilename;
/**
The next time we estimate a rollover should occur. */
int64_t nextCheck;
int64_t now;
helpers::DateFormat * df;
RollingCalendar rc;
};
} }
#endif //_LOG4CXX_DAILY_ROLLING_FILE_APPENDER_H #if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#endif
 End of changes. 43 change blocks. 
236 lines changed or deleted 142 lines changed or added


 datagrampacket.h   datagrampacket.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_HELPERS_DATAGRAM_PACKET #ifndef _LOG4CXX_HELPERS_DATAGRAM_PACKET
#define _LOG4CXX_HELPERS_DATAGRAM_PACKET #define _LOG4CXX_HELPERS_DATAGRAM_PACKET
#include <log4cxx/helpers/objectimpl.h> #include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/inetaddress.h> #include <log4cxx/helpers/inetaddress.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class DatagramPacket;
typedef helpers::ObjectPtrT<DatagramPacket> DatagramPacketPt
r;
/** This class represents a datagram packet. /** This class represents a datagram packet.
<p>Datagram packets are used to implement a connectionless p <p>Datagram packets are used to implement a connectionless
acket packet
delivery service. Each message is routed from one machine to delivery service. Each message is routed from one machine t
another o another
based solely on information contained within that packet. Mu based solely on information contained within that packet. M
ltiple ultiple
packets sent from one machine to another might be routed dif packets sent from one machine to another might be routed di
ferently, fferently,
and might arrive in any order. and might arrive in any order.
*/ */
class LOG4CXX_EXPORT DatagramPacket : public helpers::Object class LOG4CXX_EXPORT DatagramPacket : public helpers::Objec
Impl tImpl
{ {
protected: protected:
/** the data for this packet. */ /** the data for this packet. */
void * buf; void * buf;
/** The offset of the data for this packet. */ /** The offset of the data for this packet. */
int offset; int offset;
/** The length of the data for this packet. */ /** The length of the data for this packet. */
int length; int length;
/** The IP address for this packet. */ /** The IP address for this packet. */
InetAddress address; InetAddressPtr address;
/** The UDP port number of the remote host. */ /** The UDP port number of the remote host. */
int port; int port;
public: public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(DatagramPacket) DECLARE_ABSTRACT_LOG4CXX_OBJECT(DatagramPacket)
BEGIN_LOG4CXX_CAST_MAP() BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(DatagramPacket) LOG4CXX_CAST_ENTRY(DatagramPacket)
END_LOG4CXX_CAST_MAP() END_LOG4CXX_CAST_MAP()
/** Constructs a DatagramPacket for receiving packet /** Constructs a DatagramPacket for receiving packe
s of length ts of length
<code>length</code>. */ <code>length</code>. */
DatagramPacket(void * buf, int length); DatagramPacket(void * buf, int length);
/** Constructs a datagram packet for sending packets /** Constructs a datagram packet for sending packet
of length s of length
<code>length</code> to the specified port number on <code>length</code> to the specified port number on
the specified the specified
host. */ host. */
DatagramPacket(void * buf, int length, InetAddress a DatagramPacket(void * buf, int length, InetAddressP
ddress, int port); tr address, int port);
/** Constructs a DatagramPacket for receiving packet /** Constructs a DatagramPacket for receiving packe
s of length ts of length
<code>length</code>, specifying an offset into the b <code>length</code>, specifying an offset into the
uffer. */ buffer. */
DatagramPacket(void * buf, int offset, int length); DatagramPacket(void * buf, int offset, int length);
/** Constructs a datagram packet for sending packets /** Constructs a datagram packet for sending packet
of length s of length
<code>length</code> with offset <code>offset</code> <code>length</code> with offset <code>offset</code>
to the to the
specified port number on the specified host. */ specified port number on the specified host. */
DatagramPacket(void * buf, int offset, int length, I DatagramPacket(void * buf, int offset, int length,
netAddress address, InetAddressPtr address,
int port); int port);
~DatagramPacket(); ~DatagramPacket();
/** Returns the IP address of the machine to which t /** Returns the IP address of the machine to which
his datagram this datagram
is being sent or from which the datagram was receive is being sent or from which the datagram was receiv
d. */ ed. */
inline InetAddress getAddress() const inline InetAddressPtr getAddress() const
{ return address; } { return address; }
/** Returns the data received or the data to be sent /** Returns the data received or the data to be sen
. */ t. */
inline void * getData() const inline void * getData() const
{ return buf; } { return buf; }
/** Returns the length of the data to be sent or the /** Returns the length of the data to be sent or th
length of the e length of the
data received. */ data received. */
inline int getLength() const inline int getLength() const
{ return length; } { return length; }
/** Returns the offset of the data to be sent or the /** Returns the offset of the data to be sent or th
offset of the e offset of the
data received. */ data received. */
inline int getOffset() const inline int getOffset() const
{ return offset; } { return offset; }
/** Returns the port number on the remote host to wh /** Returns the port number on the remote host to w
ich this hich this
datagram is being sent or from which the datagram w datagram is being sent or from which the datagram
as received. */ was received. */
inline int getPort() const inline int getPort() const
{ return port; } { return port; }
inline void setAddress(InetAddress address) inline void setAddress(InetAddressPtr address1)
{ this->address = address; } { this->address = address1; }
/** Set the data buffer for this packet. */ /** Set the data buffer for this packet. */
inline void setData(void * buf) inline void setData(void * buf1)
{ this->buf = buf; } { this->buf = buf1; }
/** Set the data buffer for this packet. */ /** Set the data buffer for this packet. */
inline void setData(void * buf, int offset, int leng inline void setData(void * buf1, int offset1, int l
th) ength1)
{ this->buf = buf; this->offset = offset; th { this->buf = buf1; this->offset = offset1;
is->length = length; } this->length = length1; }
/** Set the length for this packet. */ /** Set the length for this packet. */
inline void setLength(int length) inline void setLength(int length1)
{ this->length = length; } { this->length = length1; }
inline void setPort(int port) inline void setPort(int port1)
{ this->port = port; } { this->port = port1; }
}; // class DatagramSocketImpl private:
} // namespace helpers //
}; // namespace log4cxx // prevent copy and assignment statements
DatagramPacket(const DatagramPacket&);
DatagramPacket& operator=(const DatagramPacket&);
#endif // _LOG4CXX_HELPERS_DATAGRAM_SOCKET_IMPL }; // class DatagramPacket
LOG4CXX_PTR_DEF(DatagramPacket);
} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_DATAGRAM_PACKET
 End of changes. 25 change blocks. 
109 lines changed or deleted 109 lines changed or added


 datagramsocket.h   datagramsocket.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_HELPERS_DATAGRAM_SOCKET_H #ifndef _LOG4CXX_HELPERS_DATAGRAM_SOCKET_H
#define _LOG4CXX_HELPERS_DATAGRAM_SOCKET_H #define _LOG4CXX_HELPERS_DATAGRAM_SOCKET_H
#include <log4cxx/helpers/objectimpl.h> #include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/inetaddress.h> #include <log4cxx/helpers/inetaddress.h>
#include <log4cxx/helpers/pool.h>
#include <log4cxx/helpers/datagrampacket.h>
extern "C" { struct apr_socket_t; }
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class DatagramPacket; /** This class represents a socket for sending and receivin
typedef helpers::ObjectPtrT<DatagramPacket> DatagramPacketPt g
r; datagram packets.*/
class LOG4CXX_EXPORT DatagramSocket : public helpers::Objec
tImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(DatagramSocket)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(DatagramSocket)
END_LOG4CXX_CAST_MAP()
class DatagramSocket; /** Constructs a datagram socket and binds it to an
typedef helpers::ObjectPtrT<DatagramSocket> DatagramSocketPt y available port
r; on the local host machine.*/
DatagramSocket();
/** This class represents a socket for sending and receiving /** Constructs a datagram socket and binds it to th
datagram packets.*/ e specified
class LOG4CXX_EXPORT DatagramSocket : public helpers::Object port on the local host machine. */
Impl DatagramSocket(int port);
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(DatagramSocket)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(DatagramSocket)
END_LOG4CXX_CAST_MAP()
/** Constructs a datagram socket and binds it to any /** Creates a datagram socket, bound to the specif
available port ied local
on the local host machine.*/ address. */
DatagramSocket(); DatagramSocket(int port, InetAddressPtr laddr);
/** Constructs a datagram socket and binds it to the /** ensure the socket is closed. */
specified ~DatagramSocket();
port on the local host machine. */
DatagramSocket(int port);
/** Creates a datagram socket, bound to the specifi /** Binds a datagram socket to a local port and ad
ed local dress.*/
address. */ void bind(int lport, InetAddressPtr laddress);
DatagramSocket(int port, InetAddress laddr);
/** ensure the socket is closed. */ /** Creates a datagram socket.*/
~DatagramSocket(); void create();
/** Binds a datagram socket to a local port and add /** Closes this datagram socket */
ress.*/ void close();
void bind(int lport, InetAddress laddress);
/** Creates a datagram socket.*/ /** Connects the socket to a remote address for thi
void create(); s socket. */
void connect(InetAddressPtr address, int port);
/** Closes this datagram socket */ /** Returns the address to which this socket is con
void close(); nected. */
inline InetAddressPtr getInetAddress() const
{ return address; }
/** Connects the socket to a remote address for this /** Gets the local address to which the socket is b
socket. */ ound. */
void connect(InetAddress address, int port); inline InetAddressPtr getLocalAddress() const
{ return localAddress; }
/** Returns the address to which this socket is conn /** Returns the port number on the local host to w
ected. */ hich this
inline InetAddress getInetAddress() const socket is bound. */
{ return address; } inline int getLocalPort() const
{ return localPort; }
/** Gets the local address to which the socket is bo /** Returns the port for this socket */
und. */ inline int getPort() const
inline InetAddress getLocalAddress() const { return port; }
{ return localAddress; }
/** Returns the port number on the local host to wh /** Returns the binding state of the socket. **/
ich this inline bool isBound() const
socket is bound. */ { return localPort != 0; }
inline int getLocalPort() const
{ return localPort; }
/** Returns the port for this socket */ /** Returns wether the socket is closed or not. */
inline int getPort() const inline bool isClosed() const
{ return port; } { return socket != 0; }
/** Returns the binding state of the socket. **/ /** Returns the connection state of the socket. */
inline bool isBound() const inline bool isConnected() const
{ return localPort != 0; } { return port != 0; }
/** Returns wether the socket is closed or not. */ /** Receives a datagram packet from this socket. *
inline bool isClosed() const /
{ return fd != 0; } void receive(DatagramPacketPtr& p);
/** Returns the connection state of the socket. */ /** Sends a datagram packet from this socket. */
inline bool isConnected() const void send(DatagramPacketPtr& p);
{ return port != 0; }
/** Receives a datagram packet from this socket. */ private:
void receive(DatagramPacketPtr& p); DatagramSocket(const DatagramSocket&);
DatagramSocket& operator=(const DatagramSocket&);
/** The APR socket */
apr_socket_t *socket;
/** Sends a datagram packet from this socket. */ /** The memory pool for the socket */
void send(DatagramPacketPtr& p); Pool socketPool;
protected: InetAddressPtr address;
/** The file descriptor object for this socket. */
int fd;
InetAddress address; InetAddressPtr localAddress;
InetAddress localAddress;
int port;
/** The local port number to which this socket is co int port;
nnected. */
int localPort;
}; /** The local port number to which this socket is c
} // namespace helpers onnected. */
}; // namespace log4cxx int localPort;
};
LOG4CXX_PTR_DEF(DatagramSocket);
} // namespace helpers
} // namespace log4cxx
#endif //_LOG4CXX_HELPERS_DATAGRAM_SOCKET_H #endif //_LOG4CXX_HELPERS_DATAGRAM_SOCKET_H
 End of changes. 26 change blocks. 
88 lines changed or deleted 95 lines changed or added


 dateformat.h   dateformat.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_HELPERS_DATE_FORMAT_H #ifndef _LOG4CXX_HELPERS_DATE_FORMAT_H
#define _LOG4CXX_HELPERS_DATE_FORMAT_H #define _LOG4CXX_HELPERS_DATE_FORMAT_H
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/helpers/timezone.h> #include <log4cxx/helpers/timezone.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
/**
Concrete class for formatting and parsing dates in a
locale-sensitive manner.
*/
class LOG4CXX_EXPORT DateFormat
{
public:
DateFormat(const String& dateFormat);
DateFormat(const String& dateFormat, const TimeZoneP
tr& timeZone);
virtual void format(ostream& os, int64_t time) const
;
String format(int64_t timeMillis) const;
protected: /**
TimeZonePtr timeZone; * DateFormat is an abstract class for date/time formatting
String dateFormat; * patterned after java.text.DateFormat.
}; */
} // namespace helpers class LOG4CXX_EXPORT DateFormat : public ObjectImpl {
}; // namespace log4cxx public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(DateFormat)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(DateFormat)
END_LOG4CXX_CAST_MAP()
/**
* Destructor
*/
virtual ~DateFormat();
/**
* Formats an log4cxx_time_t into a date/time string.
* @param s string to which the date/time string is appen
ded.
* @param tm date to be formatted.
* @param p memory pool used during formatting.
*/
virtual void format(LogString &s, log4cxx_time_t tm, log
4cxx::helpers::Pool& p) const = 0;
/**
* Sets the time zone.
* @param zone the given new time zone.
*/
virtual void setTimeZone(const TimeZonePtr& zone);
/**
* Format an integer consistent with the format method.
* @param s string to which the numeric string is appende
d.
* @param n integer value.
* @param p memory pool used during formatting.
* @remarks This method is used by CachedDateFormat to
* format the milliseconds.
*/
virtual void numberFormat(LogString& s, int n, log4cxx::
helpers::Pool& p) const;
protected:
/**
* Constructor.
*/
DateFormat();
private:
/**
* Copy constructor definition to prevent copying.
*/
DateFormat(const DateFormat&);
/**
* Assignment definition to prevent assignment.
*/
DateFormat& operator=(const DateFormat&);
};
LOG4CXX_PTR_DEF(DateFormat);
} // namespace helpers
} // namespace log4cxx
#endif //_LOG4CXX_HELPERS_DATE_FORMAT_H #endif //_LOG4CXX_HELPERS_DATE_FORMAT_H
 End of changes. 4 change blocks. 
27 lines changed or deleted 72 lines changed or added


 datelayout.h   datelayout.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_HELPERS_DATE_LAYOUT_H #ifndef _LOG4CXX_HELPERS_DATE_LAYOUT_H
#define _LOG4CXX_HELPERS_DATE_LAYOUT_H #define _LOG4CXX_HELPERS_DATE_LAYOUT_H
#include <log4cxx/layout.h> #include <log4cxx/layout.h>
#include <log4cxx/helpers/dateformat.h>
#include <log4cxx/helpers/timezone.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class DateFormat; /**
class TimeZone; This abstract layout takes care of all the date related opt
typedef helpers::ObjectPtrT<TimeZone> TimeZonePtr; ions and
formatting work.
/** */
This abstract layout takes care of all the date related opti class LOG4CXX_EXPORT DateLayout : public Layout
ons and {
formatting work. private:
*/ LogString timeZoneID;
class LOG4CXX_EXPORT DateLayout : public Layout LogString dateFormatOption;
{
public:
/**
String constant designating no time information. Cur
rent value of
this constant is <b>NULL</b>.
*/
static String NULL_DATE_FORMAT;
/**
String constant designating relative time. Current v
alue of
this constant is <b>RELATIVE</b>.
*/
static String RELATIVE_TIME_DATE_FORMAT;
static String DATE_FORMAT_OPTION;
static String TIMEZONE_OPTION;
private:
String timeZoneID;
String dateFormatOption;
protected:
DateFormat * dateFormat;
public: protected:
DateLayout(); DateFormatPtr dateFormat;
virtual ~DateLayout();
virtual void activateOptions(); public:
virtual void setOption(const String& option, const S DateLayout(const LogString& dateLayoutOption);
tring& value); virtual ~DateLayout();
/** virtual void activateOptions(log4cxx::helpers::Pool
The value of the <b>DateFormat</b> option should be & p);
either an virtual void setOption(const LogString& option, con
argument to the constructor of helpers::DateFormat o st LogString& value);
r one of
the srings <b>"NULL"</b>, <b>"RELATIVE"</b>, <b>"ABS
OLUTE"</b>,
<b>"DATE"</b> or <b>"ISO8601</b>.
*/
inline void setDateFormat(const String& dateFormat)
{ this->dateFormatOption = dateFormat; }
/** /**
Returns value of the <b>DateFormat</b> option. The value of the <b>DateFormat</b> option should be
*/ either an
inline const String& getDateFormat() const argument to the constructor of helpers::DateFormat
{ return dateFormatOption; } or one of
the strings <b>"NULL"</b>, <b>"RELATIVE"</b>, <b>"A
BSOLUTE"</b>,
<b>"DATE"</b> or <b>"ISO8601</b>.
*/
inline void setDateFormat(const LogString& dateForm
at1)
{ this->dateFormatOption.assign(dateFormat1); }
/** /**
The <b>TimeZoneID</b> option is a time zone ID strin Returns value of the <b>DateFormat</b> option.
g in the format */
expected by the <code>locale</code> C++ standard cla inline const LogString& getDateFormat() const
ss. { return dateFormatOption; }
*/
inline void setTimeZone(const String& timeZone)
{ this->timeZoneID = timeZone; }
/** /**
Returns value of the <b>TimeZone</b> option. The <b>TimeZoneID</b> option is a time zone ID stri
*/ ng in the format
inline const String& getTimeZone() const expected by the <code>locale</code> C++ standard cl
{ return timeZoneID; } ass.
*/
inline void setTimeZone(const LogString& timeZone)
{ this->timeZoneID.assign(timeZone); }
void formatDate(ostream &os, const spi::LoggingEvent /**
Ptr& event) const; Returns value of the <b>TimeZone</b> option.
*/
inline const LogString& getTimeZone() const
{ return timeZoneID; }
protected: void formatDate(LogString &s,
/** const spi::LoggingEventPtr& event,
Sets the DateFormat used to format date and time in log4cxx::helpers::Pool& p) const;
the time zone
determined by <code>timeZone</code> parameter. The
helpers::DateFormat DateFormat used
will depend on the <code>dateFormatType</code>.
<p>The recognized types are #NULL_DATE_FORMAT, private:
#RELATIVE_TIME_DATE_FORMAT, //
helpers::AbsoluteTimeDateFormat#ABS_TIME_DATE_FORMAT // prevent copy and assignment
, DateLayout(const DateLayout&);
helpers::AbsoluteTimeDateFormat#DATE_AND_TIME_DATE_F DateLayout& operator=(const DateLayout&);
ORMAT and
helpers::AbsoluteTimeDateFormat#ISO8601_DATE_FORMAT.
If the
<code>dateFormatType</code> is not one of the above,
then the
argument is assumed to be a date pattern for
helpers::DateFormat.
*/
void setDateFormat(const String& dateFormatType,
const TimeZonePtr& timeZone);
}; };
} // namespace helpers } // namespace helpers
}; // namespace log4cxx } // namespace log4cxx
#endif // _LOG4CXX_HELPERS_DATE_LAYOUT_H #endif // _LOG4CXX_HELPERS_DATE_LAYOUT_H
 End of changes. 13 change blocks. 
104 lines changed or deleted 70 lines changed or added


 datetimedateformat.h   datetimedateformat.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_HELPERS_DATE_TIME_DATE_FORMAT_H #ifndef _LOG4CXX_HELPERS_DATE_TIME_DATE_FORMAT_H
#define _LOG4CXX_HELPERS_DATE_TIME_DATE_FORMAT_H #define _LOG4CXX_HELPERS_DATE_TIME_DATE_FORMAT_H
#include <log4cxx/helpers/dateformat.h> #include <log4cxx/helpers/simpledateformat.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
/** /**
Formats a date in the format <b>\%d-\%m-\%Y \%H:\%M:\%S,\%Q< Formats a date in the format <b>dd MMM yyyy HH:mm:ss,SSS</b
/b> for example, > for example,
"06 Nov 1994 15:49:37,459". "06 Nov 1994 15:49:37,459".
*/ */
class LOG4CXX_EXPORT DateTimeDateFormat : public DateFormat class LOG4CXX_EXPORT DateTimeDateFormat : public SimpleDate
{ Format
public: {
DateTimeDateFormat(const TimeZonePtr& timeZone) public:
: DateFormat(_T("%d %b %Y %H:%M:%S,%Q"), timeZone) DateTimeDateFormat()
{} : SimpleDateFormat(LOG4CXX_STR("dd MMM yyyy HH:mm:
}; ss,SSS")) {}
} // namespace helpers DateTimeDateFormat(const std::locale* locale)
}; // namespace log4cxx : SimpleDateFormat(LOG4CXX_STR("dd MMM yyyy HH:mm
:ss,SSS"), locale) {}
};
} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_DATE_TIME_DATE_FORMAT_H #endif // _LOG4CXX_HELPERS_DATE_TIME_DATE_FORMAT_H
 End of changes. 3 change blocks. 
22 lines changed or deleted 27 lines changed or added


 defaultrepositoryselector.h   defaultrepositoryselector.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_SPI_DEFAULT_REPOSITORY_SELECTOR_H #ifndef _LOG4CXX_SPI_DEFAULT_REPOSITORY_SELECTOR_H
#define _LOG4CXX_SPI_DEFAULT_REPOSITORY_SELECTOR_H #define _LOG4CXX_SPI_DEFAULT_REPOSITORY_SELECTOR_H
#include <log4cxx/spi/repositoryselector.h> #include <log4cxx/spi/repositoryselector.h>
#include <log4cxx/helpers/objectimpl.h> #include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/spi/loggerrepository.h> #include <log4cxx/spi/loggerrepository.h>
namespace log4cxx namespace log4cxx
{ {
namespace spi namespace spi
{ {
class LOG4CXX_EXPORT DefaultRepositorySelector : class LOG4CXX_EXPORT DefaultRepositorySelector :
public virtual RepositorySelector, public virtual RepositorySelector,
public virtual helpers::ObjectImpl public virtual helpers::ObjectImpl
{ {
public: public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(DefaultRepositorySel DECLARE_ABSTRACT_LOG4CXX_OBJECT(DefaultRepositorySe
ector) lector)
BEGIN_LOG4CXX_CAST_MAP() BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(RepositorySelector) LOG4CXX_CAST_ENTRY(RepositorySelector)
END_LOG4CXX_CAST_MAP() END_LOG4CXX_CAST_MAP()
DefaultRepositorySelector(const LoggerRepositoryPtr&
repository)
: repository(repository)
{
}
virtual LoggerRepositoryPtr& getLoggerRepository() DefaultRepositorySelector(const LoggerRepositoryPtr
{ & repository1);
return repository; void addRef() const;
} void releaseRef() const;
virtual LoggerRepositoryPtr& getLoggerRepository();
private: private:
LoggerRepositoryPtr repository; LoggerRepositoryPtr repository;
}; };
} // namespace spi } // namespace spi
}; // namespace log4cxx } // namespace log4cxx
#endif //_LOG4CXX_SPI_DEFAULT_REPOSITORY_SELECTOR_H #endif //_LOG4CXX_SPI_DEFAULT_REPOSITORY_SELECTOR_H
 End of changes. 4 change blocks. 
32 lines changed or deleted 28 lines changed or added


 denyallfilter.h   denyallfilter.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_VARIA_DENY_ALL_FILTER_H #ifndef _LOG4CXX_FILTER_DENY_ALL_FILTER_H
#define _LOG4CXX_VARIA_DENY_ALL_FILTER_H #define _LOG4CXX_FILTER_DENY_ALL_FILTER_H
#if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/spi/filter.h> #include <log4cxx/spi/filter.h>
namespace log4cxx namespace log4cxx
{ {
namespace varia namespace filter
{ {
/** /**
This filter drops all logging events. This filter drops all logging events.
<p>You can add this filter to the end of a filter chain to <p>You can add this filter to the end of a filter chain to
switch from the default "accept all unless instructed otherw switch from the default "accept all unless instructed other
ise" wise"
filtering behaviour to a "deny all unless instructed otherwi filtering behaviour to a "deny all unless instructed otherw
se" ise"
behaviour. behaviour.
*/ */
class DenyAllFilter;
typedef helpers::ObjectPtrT<DenyAllFilter> DenyAllFilterPtr;
class LOG4CXX_EXPORT DenyAllFilter : public spi::Filter class LOG4CXX_EXPORT DenyAllFilter : public spi::Filter
{ {
public: public:
typedef spi::Filter BASE_CLASS; DenyAllFilter() : spi::Filter() {
DECLARE_LOG4CXX_OBJECT(DenyAllFilter) }
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(DenyAllFilter)
LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
END_LOG4CXX_CAST_MAP()
/** typedef spi::Filter BASE_CLASS;
Always returns the integer constant {@link spi::Filt DECLARE_LOG4CXX_OBJECT(DenyAllFilter)
er#DENY DENY} BEGIN_LOG4CXX_CAST_MAP()
regardless of the {@link spi::LoggingEvent LoggingEv LOG4CXX_CAST_ENTRY(DenyAllFilter)
ent} parameter. LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
@param event The LoggingEvent to filter. END_LOG4CXX_CAST_MAP()
@return Always returns {@link spi::Filter#DENY DENY}
.
*/
FilterDecision decide(const spi::LoggingEventPtr& ev
ent) const
{ return spi::Filter::DENY; }
}; // class DenyAllFilter
} // namespace varia
}; // namespace log4cxx
#endif // _LOG4CXX_VARIA_DENY_ALL_FILTER_H /**
Always returns the integer constant {@link spi::Fil
ter#DENY DENY}
regardless of the {@link spi::LoggingEvent LoggingE
vent} 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
LOG4CXX_PTR_DEF(DenyAllFilter);
} // namespace filter
} // namespace log4cxx
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#endif // _LOG4CXX_FILTER_DENY_ALL_FILTER_H
 End of changes. 6 change blocks. 
44 lines changed or deleted 35 lines changed or added


 domconfigurator.h   domconfigurator.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_XML_DOM_CONFIGURATOR_H #ifndef _LOG4CXX_XML_DOM_CONFIGURATOR_H
#define _LOG4CXX_XML_DOM_CONFIGURATOR_H #define _LOG4CXX_XML_DOM_CONFIGURATOR_H
#include <log4cxx/config.h> #if defined(_MSC_VER)
#pragma warning (push)
#ifdef HAVE_XML #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/helpers/tchar.h> #include <log4cxx/logstring.h>
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/objectimpl.h>
#include <map> #include <map>
#include <log4cxx/appender.h> #include <log4cxx/appender.h>
#include <log4cxx/layout.h> #include <log4cxx/layout.h>
#include <log4cxx/logger.h> #include <log4cxx/logger.h>
#include <log4cxx/helpers/properties.h> #include <log4cxx/helpers/properties.h>
#include <log4cxx/spi/configurator.h> #include <log4cxx/spi/configurator.h>
#include <log4cxx/helpers/charsetdecoder.h>
#include <log4cxx/spi/filter.h>
#include <log4cxx/rolling/triggeringpolicy.h>
#include <log4cxx/rolling/rollingpolicy.h>
#include <log4cxx/file.h>
#include <log4cxx/config/propertysetter.h>
extern "C" {
struct apr_xml_doc;
struct apr_xml_elem;
}
namespace log4cxx namespace log4cxx
{ {
namespace spi
{
class LoggerRepository;
typedef helpers::ObjectPtrT<LoggerRepository> LoggerReposito
ryPtr;
class Filter;
typedef helpers::ObjectPtrT<Filter> FilterPtr;
class AppenderAttachable; namespace xml
typedef helpers::ObjectPtrT<AppenderAttachable> AppenderAtta {
chablePtr;
class OptionHandler;
typedef helpers::ObjectPtrT<OptionHandler> OptionHandlerPtr;
}
namespace helpers /**
{ Use this class to initialize the log4cxx environment using a
class XMLDOMDocument; DOM tree.
typedef helpers::ObjectPtrT<XMLDOMDocument> XMLDOMDocumentPt
r;
class XMLDOMElement; <p>Sometimes it is useful to see how log4cxx is reading confi
typedef helpers::ObjectPtrT<XMLDOMElement> XMLDOMElementPtr; guration
} files. You can enable log4cxx internal logging by setting the
<code>debug</code> attribute in the
<code>log4cxx</code> element. As in
<pre>
&lt;log4j:configuration <b>debug="true"</b> xmlns:log
4j="http://jakarta.apache.org/log4j/">
...
&lt;/log4j:configuration>
</pre>
namespace config <p>There are sample XML files included in the package.
{ */
class PropertySetter; class LOG4CXX_EXPORT DOMConfigurator :
} virtual public spi::Configurator,
virtual public helpers::ObjectImpl
{
protected:
typedef std::map<LogString, AppenderPtr> AppenderMa
p;
/**
Used internally to parse appenders by IDREF name.
*/
AppenderPtr findAppenderByName(
log4cxx::helpers::Pool& p,
log4cxx::helpers::CharsetDecoderPtr& utf8De
coder,
apr_xml_elem* elem,
apr_xml_doc* doc,
const LogString& appenderName,
AppenderMap& appenders);
namespace xml /**
{ Used internally to parse appenders by IDREF element
class AppenderMap .
{ */
public: AppenderPtr findAppenderByReference(
AppenderPtr get(const String& appenderName); log4cxx::helpers::Pool& p,
void put(const String& appenderName, AppenderPtr app log4cxx::helpers::CharsetDecoderPtr& utf8De
ender); coder,
apr_xml_elem* appenderRef,
apr_xml_doc* doc,
AppenderMap& appenders);
protected: /**
std::map<String, AppenderPtr> map; Used internally to parse an appender element.
}; */
AppenderPtr parseAppender(
log4cxx::helpers::Pool& p,
log4cxx::helpers::CharsetDecoderPtr& utf8Decode
r,
apr_xml_elem* appenderElement,
apr_xml_doc* doc,
AppenderMap& appenders);
/** /**
Use this class to initialize the log4cxx environment using a DOM tree. Used internally to parse an {@link spi::ErrorHandle
r ErrorHandler } element.
*/
void parseErrorHandler(
log4cxx::helpers::Pool& p,
log4cxx::helpers::CharsetDecoderPtr& utf8Decode
r,
apr_xml_elem* element,
AppenderPtr& appender,
apr_xml_doc* doc,
AppenderMap& appenders);
<p>Sometimes it is useful to see how log4cxx is reading configuration /**
files. You can enable log4cxx internal logging by setting the Used internally to parse a filter element.
<code>debug</code> attribute in the */
<code>log4cxx</code> element. As in void parseFilters(
<pre> log4cxx::helpers::Pool& p,
&lt;log4j:configuration <b>debug="true"</b> xmlns:log4j="http://jaka log4cxx::helpers::CharsetDecoderPtr& utf8Decoder
rta.apache.org/log4j/"> ,
... apr_xml_elem* element,
&lt;/log4j:configuration> std::vector<log4cxx::spi::FilterPtr>& filters);
</pre>
<p>There are sample XML files included in the package. /**
*/ Used internally to parse a logger element.
class LOG4CXX_EXPORT DOMConfigurator : */
virtual public spi::Configurator, void parseLogger(
virtual public helpers::ObjectImpl log4cxx::helpers::Pool& p,
{ log4cxx::helpers::CharsetDecoderPtr& utf8Decode
protected: r,
/** apr_xml_elem* loggerElement,
Used internally to parse appenders by IDREF name. apr_xml_doc* doc,
*/ AppenderMap& appenders);
AppenderPtr findAppenderByName(helpers::XMLDOMDocume
ntPtr doc,
const String& appenderName);
/** /**
Used internally to parse appenders by IDREF element. Used internally to parse the logger factory elemen
*/ t.
AppenderPtr findAppenderByReference( */
helpers::XMLDOMElementPtr appenderRef); void parseLoggerFactory(
log4cxx::helpers::Pool& p,
log4cxx::helpers::CharsetDecoderPtr& utf8Decode
r,
apr_xml_elem* factoryElement);
/** /**
Used internally to parse an appender element. Used internally to parse the logger factory elemen
*/ t.
AppenderPtr parseAppender(helpers::XMLDOMElementPtr */
appenderElement); log4cxx::helpers::ObjectPtr parseTriggeringPolicy(
log4cxx::helpers::Pool& p,
log4cxx::helpers::CharsetDecoderPtr& utf8Decode
r,
apr_xml_elem* factoryElement);
/** /**
Used internally to parse an {@link spi::ErrorHandler Used internally to parse the logger factory elemen
ErrorHandler } element. t.
*/ */
void parseErrorHandler(helpers::XMLDOMElementPtr ele log4cxx::rolling::RollingPolicyPtr parseRollingPoli
ment, AppenderPtr appender); cy(
log4cxx::helpers::Pool& p,
log4cxx::helpers::CharsetDecoderPtr& utf8Decode
r,
apr_xml_elem* factoryElement);
/** /**
Used internally to parse a filter element. Used internally to parse the root logger element.
*/ */
void parseFilters(helpers::XMLDOMElementPtr element, void parseRoot(log4cxx::helpers::Pool& p,
AppenderPtr appender); log4cxx::helpers::CharsetDecoderPtr& utf8Decode
r,
apr_xml_elem* rootElement, apr_xml_doc* doc, Ap
penderMap& appenders);
/** /**
Used internally to parse a logger element. Used internally to parse the children of a logger
*/ element.
void parseLogger(helpers::XMLDOMElementPtr loggerEle */
ment); void parseChildrenOfLoggerElement(
log4cxx::helpers::Pool& p,
log4cxx::helpers::CharsetDecoderPtr& utf8De
coder,
apr_xml_elem* catElement,
LoggerPtr logger, bool isRoot,
apr_xml_doc* doc,
AppenderMap& appenders);
/** /**
Used internally to parse the logger factory element Used internally to parse a layout element.
. */
*/ LayoutPtr parseLayout(
void parseLoggerFactory(helpers::XMLDOMElementPtr fa log4cxx::helpers::Pool& p,
ctoryElement); log4cxx::helpers::CharsetDecoderPtr& utf8Decode
r,
apr_xml_elem* layout_element);
/** /**
Used internally to parse the roor category element. Used internally to parse a level element.
*/ */
void parseRoot(helpers::XMLDOMElementPtr rootElement void parseLevel(
); log4cxx::helpers::Pool& p,
log4cxx::helpers::CharsetDecoderPtr& utf8De
coder,
apr_xml_elem* element,
LoggerPtr logger, bool isRoot);
/** void setParameter(
Used internally to parse the children of a category log4cxx::helpers::Pool& p,
element. log4cxx::helpers::CharsetDecoderPtr& utf8De
*/ coder,
void parseChildrenOfLoggerElement(helpers::XMLDOMEle apr_xml_elem* elem,
mentPtr catElement, log4cxx::config::PropertySetter& propSetter);
LoggerPtr logger, bool isRoot);
/** /**
Used internally to parse a layout element. Used internally to configure the log4cxx framework
*/ from
LayoutPtr parseLayout(helpers::XMLDOMElementPtr layo an in-memory representation of an XML document.
ut_element); */
void parse(
log4cxx::helpers::Pool& p,
log4cxx::helpers::CharsetDecoderPtr& utf8Decode
r,
apr_xml_elem* element,
apr_xml_doc* doc,
AppenderMap& appenders);
/** public:
Used internally to parse a level element. DOMConfigurator();
*/
void parseLevel(helpers::XMLDOMElementPtr element,
LoggerPtr logger, bool isRoot);
void setParameter(helpers::XMLDOMElementPtr elem, DECLARE_LOG4CXX_OBJECT(DOMConfigurator)
config::PropertySetter& propSetter); BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(spi::Configurator)
END_LOG4CXX_CAST_MAP()
/** DOMConfigurator(log4cxx::helpers::Pool& p);
Used internally to configure the log4cxx framework
by parsing a DOM
tree of XML elements based on <a
href="docs/log4j.dtd">log4j.dtd</a>.
*/ void addRef() const;
void parse(helpers::XMLDOMElementPtr element); void releaseRef() const;
public: /**
DECLARE_LOG4CXX_OBJECT(DOMConfigurator) A static version of #doConfigure.
BEGIN_LOG4CXX_CAST_MAP() */
LOG4CXX_CAST_ENTRY(spi::Configurator) static void configure(const std::string& filename);
END_LOG4CXX_CAST_MAP() #if LOG4CXX_WCHAR_T_API
static void configure(const std::wstring& filename)
;
#endif
#if LOG4CXX_UNICHAR_API
static void configure(const std::basic_string<UniCh
ar>& filename);
#endif
#if LOG4CXX_CFSTRING_API
static void configure(const CFStringRef& filename);
#endif
/**
Like #configureAndWatch(const std::string& configFi
lename, long delay)
except that the default delay as defined by
log4cxx::helpers::FileWatchdog#DEFAULT_DELAY is use
d.
@param configFilename A log4j configuration file in
XML format.
*/
static void configureAndWatch(const std::string& co
nfigFilename);
#if LOG4CXX_WCHAR_T_API
static void configureAndWatch(const std::wstring& c
onfigFilename);
#endif
#if LOG4CXX_UNICHAR_API
static void configureAndWatch(const std::basic_stri
ng<UniChar>& configFilename);
#endif
#if LOG4CXX_CFSTRING_API
static void configureAndWatch(const CFStringRef& co
nfigFilename);
#endif
/**
Read the configuration file <code>configFilename</c
ode> if it
exists. Moreover, a thread will be created that wil
l periodically
check if <code>configFilename</code> has been creat
ed or
modified. The period is determined by the <code>del
ay</code>
argument. If a change or file creation is detected,
then
<code>configFilename</code> is read to configure lo
g4cxx.
/** @param configFilename A log4j configuration file in
A static version of #doConfigure. XML format.
*/ @param delay The delay in milliseconds to wait betw
static void configure(const String& filename); een each check.
*/
static void configureAndWatch(const std::string& co
nfigFilename,
long delay);
#if LOG4CXX_WCHAR_T_API
static void configureAndWatch(const std::wstring& c
onfigFilename,
long delay);
#endif
#if LOG4CXX_UNICHAR_API
static void configureAndWatch(const std::basic_stri
ng<UniChar>& configFilename,
long delay);
#endif
#if LOG4CXX_CFSTRING_API
static void configureAndWatch(const CFStringRef& co
nfigFilename,
long delay);
#endif
/** /**
Like #configureAndWatch(const String& configFilename Interpret the XML file pointed by <code>filename</c
, long delay) ode> and set up
except that the default delay as defined by log4cxx accordingly.
FileWatchdog#DEFAULT_DELAY is used. <p>The configuration is done relative to the hierar
@param configFilename A log4j configuration file in chy parameter.
XML format. @param filename The file to parse.
*/ @param repository The hierarchy to operation upon.
static void configureAndWatch(const String& configFi */
lename); void doConfigure(const File& filename,
spi::LoggerRepositoryPtr& repository);
/** protected:
Read the configuration file <code>configFilename</co static LogString getAttribute(
de> if it log4cxx::helpers::CharsetDecoderPtr& utf8Decode
exists. Moreover, a thread will be created that will r,
periodically apr_xml_elem*,
check if <code>configFilename</code> has been create const std::string& attrName);
d or
modified. The period is determined by the <code>dela
y</code>
argument. If a change or file creation is detected,
then
<code>configFilename</code> is read to configure log
4cxx.
@param configFilename A log4j configuration file in LogString subst(const LogString& value);
XML format.
@param delay The delay in milliseconds to wait betwe
en each check.
*/
static void configureAndWatch(const String& configFi
lename,
long delay);
/** protected:
Interpret the XML file pointed by <code>filename</co helpers::Properties props;
de> and set up spi::LoggerRepositoryPtr repository;
log4cxx accordingly. spi::LoggerFactoryPtr loggerFactory;
<p>The configuration is done relative to the hierarc
hy parameter.
@param filename The file to parse.
@param repository The hierarchy to operation upon.
*/
void doConfigure(const String& filename,
spi::LoggerRepositoryPtr& repository);
protected: private:
String subst(const String& value); // prevent assignment or copy statements
DOMConfigurator(const DOMConfigurator&);
DOMConfigurator& operator=(const DOMConfigurator&);
protected: };
void * appenderBag; LOG4CXX_PTR_DEF(DOMConfigurator);
} // namespace xml
} // namespace log4cxx
helpers::Properties props; #if defined(_MSC_VER)
spi::LoggerRepositoryPtr repository; #pragma warning (pop)
spi::LoggerFactoryPtr loggerFactory; #endif
};
} // namespace xml
}; // namespace log4cxx
#endif // HAVE_XML
#endif // _LOG4CXX_XML_DOM_CONFIGURATOR_H #endif // _LOG4CXX_XML_DOM_CONFIGURATOR_H
 End of changes. 37 change blocks. 
199 lines changed or deleted 309 lines changed or added


 errorhandler.h   errorhandler.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_SPI_ERROR_HANDLER_H #ifndef _LOG4CXX_SPI_ERROR_HANDLER_H
#define _LOG4CXX_SPI_ERROR_HANDLER_H #define _LOG4CXX_SPI_ERROR_HANDLER_H
#if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/spi/optionhandler.h> #include <log4cxx/spi/optionhandler.h>
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/object.h>
#include <log4cxx/helpers/exception.h> #include <log4cxx/helpers/exception.h>
#include <log4cxx/appender.h>
#include <log4cxx/spi/loggingevent.h>
namespace log4cxx namespace log4cxx
{ {
class Appender;
typedef log4cxx::helpers::ObjectPtrT<Appender> AppenderPtr;
class Logger;
typedef helpers::ObjectPtrT<Logger> LoggerPtr;
namespace spi namespace spi
{ {
class ErrorCode class ErrorCode
{ {
public: public:
enum enum
{ {
GENERIC_FAILURE = 0, GENERIC_FAILURE = 0,
WRITE_FAILURE = 1, WRITE_FAILURE = 1,
FLUSH_FAILURE = 2, FLUSH_FAILURE = 2,
CLOSE_FAILURE = 3, CLOSE_FAILURE = 3,
FILE_OPEN_FAILURE = 4, FILE_OPEN_FAILURE = 4,
MISSING_LAYOUT = 5, MISSING_LAYOUT = 5,
ADDRESS_PARSE_FAILURE = 6 ADDRESS_PARSE_FAILURE = 6
}; };
}; };
class LoggingEvent; /**
typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr; Appenders may delegate their error handling to
<code>ErrorHandlers</code>.
class ErrorHandler; <p>Error handling is a particularly tedious to get right be
typedef log4cxx::helpers::ObjectPtrT<ErrorHandler> ErrorHand cause by
lerPtr; definition errors are hard to predict and to reproduce.
/** <p>Please take the time to contact the author in case you d
Appenders may delegate their error handling to iscover
<code>ErrorHandlers</code>. that errors are not properly handled. You are most welcome
to
suggest new error handling policies or criticize existing p
olicies.
*/
class LOG4CXX_EXPORT ErrorHandler : public virtual OptionHa
ndler
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(ErrorHandler)
virtual ~ErrorHandler() {}
<p>Error handling is a particularly tedious to get right bec /**
ause by Add a reference to a logger to which the failing ap
definition errors are hard to predict and to reproduce. pender might
be attached to. The failing appender will be search
ed and
replaced only in the loggers you add through this m
ethod.
<p>Please take the time to contact the author in case you di @param logger One of the loggers that will be searc
scover hed for the failing
that errors are not properly handled. You are most welcome t appender in view of replacement.
o */
suggest new error handling policies or criticize existing po virtual void setLogger(const LoggerPtr& logger) = 0
licies. ;
*/
class LOG4CXX_EXPORT ErrorHandler : public virtual OptionHan
dler
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(ErrorHandler)
virtual ~ErrorHandler() {}
/** /**
Add a reference to a logger to which the failing app Equivalent to the error(const String&, helpers::Exc
ender might eption&, int,
be attached to. The failing appender will be searche spi::LoggingEvent&) with the the event parameteter
d and set to
replaced only in the loggers you add through this me null.
thod. */
virtual void error(const LogString& message, const
std::exception& e,
int errorCode) const = 0;
@param logger One of the loggers that will be search /**
ed for the failing This method is normally used to just print the erro
appender in view of replacement. r message
*/ passed as a parameter.
virtual void setLogger(const LoggerPtr& logger) = 0; */
virtual void error(const LogString& message) const
= 0;
/** /**
Equivalent to the error(const String&, helpers::Exce This method is invoked to handle the error.
ption&, int,
spi::LoggingEvent&) with the the event parameteter s
et to
null.
*/
virtual void error(const String& message, helpers::E
xception& e,
int errorCode) const = 0;
/** @param message The message assoicated with the erro
This method is normally used to just print the error r.
message @param e The Exption that was thrown when the error
passed as a parameter. occured.
*/ @param errorCode The error code associated with the
virtual void error(const String& message) const = 0; error.
@param event The logging event that the failing app
ender is asked
to log.
*/
virtual void error(const LogString& message, const
std::exception& e,
int errorCode, const LoggingEventPtr& event
) const = 0;
/** /**
This method is invoked to handle the error. Set the appender for which errors are handled. This
method is
usually called when the error handler is configured
.
*/
virtual void setAppender(const AppenderPtr& appende
r) = 0;
@param message The message assoicated with the error /**
. Set the appender to fallback upon in case of failur
@param e The Exption that was thrown when the error e.
occured. */
@param errorCode The error code associated with the virtual void setBackupAppender(const AppenderPtr& a
error. ppender) = 0;
@param event The logging event that the failing appe };
nder is asked
to log.
*/
virtual void error(const String& message, helpers::E
xception& e,
int errorCode, const LoggingEventPtr& event)
const = 0;
/** LOG4CXX_PTR_DEF(ErrorHandler);
Set the appender for which errors are handled. This } //namespace spi
method is } //namespace log4cxx
usually called when the error handler is configured.
*/
virtual void setAppender(const AppenderPtr& appender
) = 0;
/** #if defined(_MSC_VER)
Set the appender to fallback upon in case of failure #pragma warning ( pop )
. #endif
*/
virtual void setBackupAppender(const AppenderPtr& ap
pender) = 0;
};
} //namespace spi
}; //namespace log4cxx
#endif //_LOG4CXX_SPI_ERROR_HANDLER_H #endif //_LOG4CXX_SPI_ERROR_HANDLER_H
 End of changes. 19 change blocks. 
112 lines changed or deleted 114 lines changed or added


 exception.h   exception.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_HELPERS_EXCEPTION_H #ifndef _LOG4CXX_HELPERS_EXCEPTION_H
#define _LOG4CXX_HELPERS_EXCEPTION_H #define _LOG4CXX_HELPERS_EXCEPTION_H
#include <log4cxx/helpers/tchar.h> #include <exception>
#include <log4cxx/log4cxx.h>
#include <log4cxx/logstring.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
/** The class Exception and its subclasses indicate conditio /** The class Exception and its subclasses indicate conditi
ns that a ons that a
reasonable application might want to catch. reasonable application might want to catch.
*/ */
class LOG4CXX_EXPORT Exception class LOG4CXX_EXPORT Exception : public ::std::exception
{ {
public: public:
Exception() {} Exception(const char* msg);
Exception(const String& message): message(message) { Exception(const LogString& msg);
} Exception(const Exception& src);
inline const String& getMessage() { return message; Exception& operator=(const Exception& src);
} const char* what() const throw();
private:
enum { MSG_SIZE = 128 };
char msg[MSG_SIZE + 1];
}; // class Exception
protected: /** RuntimeException is the parent class of those exception
String message; s that can be
thrown during the normal operation of the process.
*/
class LOG4CXX_EXPORT RuntimeException : public Exception
{
public:
RuntimeException(log4cxx_status_t stat);
RuntimeException(const LogString& msg);
RuntimeException(const RuntimeException& msg);
RuntimeException& operator=(const RuntimeException&
src);
private:
static LogString formatMessage(log4cxx_status_t sta
t);
}; // class RuntimeException
}; // class Exception /** Thrown when an application attempts to use null in a ca
se where an
object is required.
*/
class LOG4CXX_EXPORT NullPointerException : public Runtime
Exception
{
public:
NullPointerException(const LogString& msg);
NullPointerException(const NullPointerException& ms
g);
NullPointerException& operator=(const NullPointerEx
ception& src);
}; // class NullPointerException
/** RuntimeException is the parent class of those exceptions /** Thrown to indicate that a method has been passed
that can be an illegal or inappropriate argument.*/
thrown during the normal operation of the process. class LOG4CXX_EXPORT IllegalArgumentException : public Runt
*/ imeException
class LOG4CXX_EXPORT RuntimeException : public Exception {
{ public:
public: IllegalArgumentException(const LogString& msg);
RuntimeException() {} IllegalArgumentException(const IllegalArgumentException&
RuntimeException(const String& message) );
: Exception(message) {} IllegalArgumentException& operator=(const IllegalArgumen
}; // class RuntimeException tException&);
}; // class IllegalArgumentException
/** Thrown when an application attempts to use null in a cas /** Signals that an I/O exception of some sort has occurred
e where an . This class
object is required. is the general class of exceptions produced by failed or in
*/ terrupted
class LOG4CXX_EXPORT NullPointerException : public RuntimeE I/O operations.
xception */
{ class LOG4CXX_EXPORT IOException : public Exception
public: {
NullPointerException() {} public:
NullPointerException(const String& message) IOException();
: RuntimeException(message) {} IOException(log4cxx_status_t stat);
}; // class NullPointerException IOException(const LogString& msg);
IOException(const IOException &src);
IOException& operator=(const IOException&);
private:
static LogString formatMessage(log4cxx_status_t stat);
};
/** Thrown to indicate that a method has been passed class LOG4CXX_EXPORT MissingResourceException : public Exce
an illegal or inappropriate argument.*/ ption
class LOG4CXX_EXPORT IllegalArgumentException : public Runti {
meException public:
{ MissingResourceException(const LogString& key);
public: MissingResourceException(const MissingResourceException
IllegalArgumentException(const String& message) &src);
: RuntimeException(message) {} MissingResourceException& operator=(const MissingResour
}; // class IllegalArgumentException ceException&);
private:
static LogString formatMessage(const LogString& key);
};
/** Signals that an I/O exception of some sort has occurred. class LOG4CXX_EXPORT PoolException : public Exception
This class {
is the general class of exceptions produced by failed or int public:
errupted PoolException(log4cxx_status_t stat);
I/O operations. PoolException(const PoolException &src);
*/ PoolException& operator=(const PoolException&);
class LOG4CXX_EXPORT IOException : public Exception private:
{ static LogString formatMessage(log4cxx_status_t stat)
}; ;
} // namespace helpers };
}; // namespace log4cxx
class LOG4CXX_EXPORT MutexException : public Exception
{
public:
MutexException(log4cxx_status_t stat);
MutexException(const MutexException &src);
MutexException& operator=(const MutexException&);
private:
static LogString formatMessage(log4cxx_status_t stat)
;
};
class LOG4CXX_EXPORT InterruptedException : public Exceptio
n
{
public:
InterruptedException();
InterruptedException(log4cxx_status_t stat);
InterruptedException(const InterruptedException &src)
;
InterruptedException& operator=(const InterruptedExce
ption&);
private:
static LogString formatMessage(log4cxx_status_t stat)
;
};
class LOG4CXX_EXPORT ThreadException
: public Exception {
public:
ThreadException(log4cxx_status_t stat);
ThreadException(const LogString& msg);
ThreadException(const ThreadException &src);
ThreadException& operator=(const ThreadException&);
private:
static LogString formatMessage(log4cxx_status_t stat)
;
};
class LOG4CXX_EXPORT TranscoderException : public Exception
{
public:
TranscoderException(log4cxx_status_t stat);
TranscoderException(const TranscoderException &src);
TranscoderException& operator=(const TranscoderExcept
ion&);
private:
static LogString formatMessage(log4cxx_status_t stat)
;
};
class LOG4CXX_EXPORT IllegalMonitorStateException
: public Exception {
public:
IllegalMonitorStateException(const LogString& msg);
IllegalMonitorStateException(const IllegalMonitorStat
eException& msg);
IllegalMonitorStateException& operator=(const Illegal
MonitorStateException& msg);
};
/**
Thrown when an application tries to create an instance of a
class using
the newInstance method in class Class, but the specified cl
ass object
cannot be instantiated because it is an interface or is an
abstract class.
*/
class LOG4CXX_EXPORT InstantiationException : public Except
ion
{
public:
InstantiationException(const LogString& msg);
InstantiationException(const InstantiationException
& msg);
InstantiationException& operator=(const Instantiati
onException& msg);
};
/**
Thrown when an application tries to load in a class through
its
string name but no definition for the class with the specif
ied name
could be found.
*/
class LOG4CXX_EXPORT ClassNotFoundException : public Except
ion
{
public:
ClassNotFoundException(const LogString& className);
ClassNotFoundException(const ClassNotFoundException& ms
g);
ClassNotFoundException& operator=(const ClassNotFoundEx
ception& msg);
private:
static LogString formatMessage(const LogString& classNa
me);
};
class NoSuchElementException : public Exception {
public:
NoSuchElementException();
NoSuchElementException(const NoSuchElementException&)
;
NoSuchElementException& operator=(const NoSuchElement
Exception&);
};
class IllegalStateException : public Exception {
public:
IllegalStateException();
IllegalStateException(const IllegalStateException&);
IllegalStateException& operator=(const IllegalStateEx
ception&);
};
/** Thrown to indicate that there is an error in the underl
ying
protocol, such as a TCP error.
*/
class LOG4CXX_EXPORT SocketException : public IOException
{
public:
SocketException(const LogString& msg);
SocketException(log4cxx_status_t status);
SocketException(const SocketException&);
SocketException& operator=(const SocketException&);
};
/** Signals that an error occurred while attempting to conn
ect a socket
to a remote address and port. Typically, the connection was
refused
remotely (e.g., no process is listening on the remote addre
ss/port).
*/
class LOG4CXX_EXPORT ConnectException : public SocketExcept
ion
{
public:
ConnectException(log4cxx_status_t status);
ConnectException(const ConnectException& src);
ConnectException& operator=(const ConnectException&);
};
class LOG4CXX_EXPORT ClosedChannelException : public Socket
Exception
{
public:
ClosedChannelException();
ClosedChannelException(const ClosedChannelException& sr
c);
ClosedChannelException& operator=(const ClosedChannelEx
ception&);
};
/** Signals that an error occurred while attempting to bind
a socket to
a local address and port. Typically, the port is in use, or
the
requested local address could not be assigned.
*/
class LOG4CXX_EXPORT BindException : public SocketException
{
public:
BindException(log4cxx_status_t status);
BindException(const BindException&);
BindException& operator=(const BindException&);
};
/** Signals that an I/O operation has been interrupted. An
InterruptedIOException is thrown to indicate that an input
or output
transfer has been terminated because the thread performing
it was
interrupted. The field bytesTransferred indicates how many
bytes were
successfully transferred before the interruption occurred.
*/
class LOG4CXX_EXPORT InterruptedIOException : public IOExce
ption
{
public:
InterruptedIOException(const LogString& msg);
InterruptedIOException(const InterruptedIOException&);
InterruptedIOException& operator=(const InterruptedIOE
xception&);
};
/** Signals that an I/O operation has been interrupted. An
InterruptedIOException is thrown to indicate that an input
or output
transfer has been terminated because the thread performing
it was
interrupted. The field bytesTransferred indicates how many
bytes were
successfully transferred before the interruption occurred.
*/
class LOG4CXX_EXPORT SocketTimeoutException : public Interr
uptedIOException
{
public:
SocketTimeoutException();
SocketTimeoutException(const SocketTimeoutException&);
SocketTimeoutException& operator=(const SocketTimeoutE
xception&);
};
} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_EXCEPTION_H #endif // _LOG4CXX_HELPERS_EXCEPTION_H
 End of changes. 9 change blocks. 
66 lines changed or deleted 320 lines changed or added


 fallbackerrorhandler.h   fallbackerrorhandler.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
skipping to change at line 28 skipping to change at line 29
#define _LOG4CXX_VARIA_FALLBACK_ERROR_HANDLER_H #define _LOG4CXX_VARIA_FALLBACK_ERROR_HANDLER_H
#include <log4cxx/spi/errorhandler.h> #include <log4cxx/spi/errorhandler.h>
#include <log4cxx/helpers/objectimpl.h> #include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/appender.h> #include <log4cxx/appender.h>
#include <log4cxx/logger.h> #include <log4cxx/logger.h>
#include <vector> #include <vector>
namespace log4cxx namespace log4cxx
{ {
namespace varia namespace varia
{ {
/** /**
The <code>FallbackErrorHandler</code> implements the ErrorHa The <code>FallbackErrorHandler</code> implements the ErrorH
ndler andler
interface such that a secondary appender may be specified. interface such that a secondary appender may be specified.
This This
secondary appender takes over if the primary appender fails secondary appender takes over if the primary appender fails
for for
whatever reason. whatever reason.
<p>The error message is printed on <code>System.err</code>, <p>The error message is printed on <code>System.err</code>,
and and
logged in the new secondary appender. logged in the new secondary appender.
*/ */
class LOG4CXX_EXPORT FallbackErrorHandler : class LOG4CXX_EXPORT FallbackErrorHandler :
public virtual spi::ErrorHandler, public virtual spi::ErrorHandler,
public virtual helpers::ObjectImpl public virtual helpers::ObjectImpl
{ {
private: private:
AppenderPtr backup; AppenderPtr backup;
AppenderPtr primary; AppenderPtr primary;
std::vector<LoggerPtr> loggers; std::vector<LoggerPtr> loggers;
public: public:
DECLARE_LOG4CXX_OBJECT(FallbackErrorHandler) DECLARE_LOG4CXX_OBJECT(FallbackErrorHandler)
BEGIN_LOG4CXX_CAST_MAP() BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(spi::OptionHandler) LOG4CXX_CAST_ENTRY(spi::OptionHandler)
LOG4CXX_CAST_ENTRY(spi::ErrorHandler) LOG4CXX_CAST_ENTRY(spi::ErrorHandler)
END_LOG4CXX_CAST_MAP() END_LOG4CXX_CAST_MAP()
FallbackErrorHandler(); FallbackErrorHandler();
void addRef() const;
void releaseRef() const;
/** /**
<em>Adds</em> the logger passed as parameter to the <em>Adds</em> the logger passed as parameter to the
list of list of
loggers that we need to search for in case of append loggers that we need to search for in case of appen
er failure. der failure.
*/ */
void setLogger(const LoggerPtr& logger); void setLogger(const LoggerPtr& logger);
/** /**
No options to activate. No options to activate.
*/ */
void activateOptions(); void activateOptions(log4cxx::helpers::Pool& p);
void setOption(const String& name, const String& value); void setOption(const LogString& option, const LogSt
ring& value);
/** /**
Prints the message and the stack trace of the except Prints the message and the stack trace of the excep
ion on tion on
<code>System.err</code>. <code>System.err</code>.
*/ */
void error(const String& message, helpers::Exception void error(const LogString& message, const std::exc
& e, eption& e,
int errorCode) const; int errorCode) const;
/** /**
Prints the message and the stack trace of the except Prints the message and the stack trace of the excep
ion on tion on
<code>System.err</code>. <code>System.err</code>.
*/ */
void error(const String& message, helpers::Exception void error(const LogString& message, const std::exc
& e, eption& e,
int errorCode, const spi::LoggingEventPtr& e int errorCode, const spi::LoggingEventPtr&
vent) const; event) const;
/** /**
Print a the error message passed as parameter on Print a the error message passed as parameter on
<code>System.err</code>. <code>System.err</code>.
*/ */
void error(const String& message) const {} void error(const LogString& /* message */) const {}
/** /**
Return the backup appender. Return the backup appender.
*/ */
const AppenderPtr& getBackupAppender() const const AppenderPtr& getBackupAppender() const
{ return backup; } { return backup; }
/** /**
The appender to which this error handler is attached The appender to which this error handler is attache
. d.
*/ */
void setAppender(const AppenderPtr& primary); void setAppender(const AppenderPtr& primary);
/** /**
Set the backup appender. Set the backup appender.
*/ */
void setBackupAppender(const AppenderPtr& backup); void setBackupAppender(const AppenderPtr& backup);
}; };
} // namespace varia } // namespace varia
}; // namespace log4cxx } // namespace log4cxx
#endif //_LOG4CXX_VARIA_FALLBACK_ERROR_HANDLER_H #endif //_LOG4CXX_VARIA_FALLBACK_ERROR_HANDLER_H
 End of changes. 13 change blocks. 
85 lines changed or deleted 89 lines changed or added


 fileappender.h   fileappender.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_FILE_APPENDER_H #ifndef _LOG4CXX_FILE_APPENDER_H
#define _LOG4CXX_FILE_APPENDER_H #define _LOG4CXX_FILE_APPENDER_H
#include <log4cxx/config.h> #include <log4cxx/logger.h>
#include <log4cxx/helpers/tchar.h> #include <log4cxx/logstring.h>
#include <log4cxx/writerappender.h> #include <log4cxx/writerappender.h>
#include <fstream> #include <log4cxx/file.h>
#include <log4cxx/helpers/pool.h>
namespace log4cxx namespace log4cxx
{ {
class FileAppender; namespace helpers {
typedef helpers::ObjectPtrT<FileAppender> FileAppenderPtr; class Pool;
}
/** /**
* FileAppender appends log events to a file. * FileAppender appends log events to a file.
* *
* <p>Support for <code>java.io.Writer</code> and console appending * <p>Support for <code>java.io.Writer</code> and console appending
* has been deprecated and then removed. See the replacement * has been deprecated and then removed. See the replacement
* solutions: WriterAppender and ConsoleAppender. * solutions: WriterAppender and ConsoleAppender.
*/ */
class LOG4CXX_EXPORT FileAppender : public WriterAppender class LOG4CXX_EXPORT FileAppender : public WriterAppender
{ {
protected: protected:
/** Append to or truncate the file? The default value for th /** Append to or truncate the file? The default value for t
is his
variable is <code>true</code>, meaning that by default a variable is <code>true</code>, meaning that by default a
<code>FileAppender</code> will append to an existing file an <code>FileAppender</code> will append to an existing file a
d nd
not truncate it. not truncate it.
<p>This option is meaningful only if the FileAppender opens <p>This option is meaningful only if the FileAppender opens
the the
file. file.
*/ */
bool fileAppend; bool fileAppend;
/** /**
The name of the log file. */ The name of the log file. */
String fileName; LogString fileName;
/** /**
Do we do bufferedIO? */ Do we do bufferedIO? */
bool bufferedIO; bool bufferedIO;
/** /**
How big should the IO buffer be? Default is 8K. */ How big should the IO buffer be? Default is 8K. */
int bufferSize; int bufferSize;
#ifdef UNICODE public:
std::wofstream ofs; DECLARE_LOG4CXX_OBJECT(FileAppender)
#else BEGIN_LOG4CXX_CAST_MAP()
std::ofstream ofs; LOG4CXX_CAST_ENTRY(FileAppender)
#endif LOG4CXX_CAST_ENTRY_CHAIN(WriterAppender)
END_LOG4CXX_CAST_MAP()
public: /**
DECLARE_LOG4CXX_OBJECT(FileAppender) The default constructor does not do anything.
BEGIN_LOG4CXX_CAST_MAP() */
LOG4CXX_CAST_ENTRY(FileAppender) FileAppender();
LOG4CXX_CAST_ENTRY_CHAIN(WriterAppender)
END_LOG4CXX_CAST_MAP()
/** /**
The default constructor does not do anything. Instantiate a <code>FileAppender</code> and open the file
*/ designated by <code>filename</code>. The opened filename wi
FileAppender(); ll
become the output destination for this appender.
/** <p>If the <code>append</code> parameter is true, the file w
Instantiate a <code>FileAppender</code> and open the file ill be
designated by <code>filename</code>. The opened filename wil appended to. Otherwise, the file designated by
l <code>filename</code> will be truncated before being opened
become the output destination for this appender. .
<p>If the <code>append</code> parameter is true, the file wi <p>If the <code>bufferedIO</code> parameter is <code>true</
ll be code>,
appended to. Otherwise, the file designated by then buffered IO will be used to write to the output file.
<code>filename</code> will be truncated before being opened.
<p>If the <code>bufferedIO</code> parameter is <code>true</c */
ode>, FileAppender(const LayoutPtr& layout, const LogString& file
then buffered IO will be used to write to the output file. name, bool append,
bool bufferedIO, int bufferSize);
*/ /**
FileAppender(const LayoutPtr& layout, const String& filename Instantiate a FileAppender and open the file designated by
, bool append, <code>filename</code>. The opened filename will become the
bool bufferedIO, int bufferSize); output
destination for this appender.
/** <p>If the <code>append</code> parameter is true, the file w
Instantiate a FileAppender and open the file designated by ill be
<code>filename</code>. The opened filename will become the o appended to. Otherwise, the file designated by
utput <code>filename</code> will be truncated before being opened
destination for this appender. .
*/
FileAppender(const LayoutPtr& layout, const LogString& file
name, bool append);
<p>If the <code>append</code> parameter is true, the file wi /**
ll be Instantiate a FileAppender and open the file designated by
appended to. Otherwise, the file designated by <code>filename</code>. The opened filename will become the
<code>filename</code> will be truncated before being opened. output
*/ destination for this appender.
FileAppender(const LayoutPtr& layout, const String& filename
, bool append);
/** <p>The file will be appended to. */
Instantiate a FileAppender and open the file designated by FileAppender(const LayoutPtr& layout, const LogString& file
<code>filename</code>. The opened filename will become the o name);
utput
destination for this appender.
<p>The file will be appended to. */ ~FileAppender();
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
The <b>File</b> property takes a string value which should b "System.out" or "System.err" are no longer honored.</b>
e the
name of the file to append to.
<p><b>Note that the special values <p>Note: Actual opening of the file is made when
"System.out" or "System.err" are no longer honored.</b> #activateOptions is called, not when the options are set.
*/
virtual void setFile(const LogString& file);
<p>Note: Actual opening of the file is made when /**
#activateOptions is called, not when the options are set. * Sets and <i>opens</i> the file where the log output will
/ go. The specified file must be writable.
void setFile(const String& file);
/** <p>If there was already an opened file, then the previous f
Sets and <i>opens</i> the file where the log output will ile
go. The specified file must be writable. is closed first.
<p>If there was already an opened file, then the previous fi <p><b>Do not use this method directly. To configure a FileA
le ppender
is closed first. or one of its subclasses, set its properties one by one and
then
call activateOptions.</b>
<p><b>Do not use this method directly. To configure a FileAp @param file The path to the log file.
pender @param append If true will append to fileName. Otherwise wi
or one of its subclasses, set its properties one by one and ll
then truncate fileName.
call activateOptions.</b> @param bufferedIO Do we do bufferedIO?
@param bufferSize How big should the IO buffer be?
@param p memory pool for operation.
*/
virtual void setFile(const LogString& file, bool append,
bool bufferedIO, size_t bufferSize,
log4cxx::helpers::Pool& p);
@param file The path to the log file. /**
@param append If true will append to fileName. Otherwise wil Returns the value of the <b>Append</b> option.
l */
truncate fileName. inline bool getAppend() const { return fileAppend; }
@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>File</b> option. */
Returns the value of the <b>Append</b> option. inline LogString getFile() const { return fileName; }
*/
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 f
<p>Sets and <i>opens</i> the file where the log output will ile
go. The specified file must be writable. is closed first.*/
void activateOptions(log4cxx::helpers::Pool& p);
void setOption(const LogString& option,
const LogString& value);
<p>If there was already an opened file, then the previous file /**
is closed first.*/ Get the value of the <b>BufferedIO</b> option.
void activateOptions();
void setOption(const String& option,
const String& value);
protected: <p>BufferedIO will significatnly increase performance on he
/** avily
Closes the previously opened file. loaded systems.
*/
virtual void closeWriter();
/** */
Closes the previously opened file. inline bool getBufferedIO() const { return bufferedIO; }
*/
void closeFile();
public: /**
/** Get the size of the IO buffer.
Get the value of the <b>BufferedIO</b> option. */
inline int getBufferSize() const { return bufferSize; }
<p>BufferedIO will significatnly increase performance on heavily /**
loaded systems. The <b>Append</b> option takes a boolean value. It is set t
o
<code>true</code> by default. If true, then <code>File</cod
e>
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
inline bool getBufferedIO() const { return bufferedIO; } #activateOptions is called, not when the options are set.
*/
void setAppend(bool fileAppend1);
/** /**
Get the size of the IO buffer. The <b>BufferedIO</b> option takes a boolean value. It is s
*/ et to
inline int getBufferSize() const { return bufferSize; } <code>false</code> by default. If true, then <code>File</co
de>
will be opened in buffered mode.
/** BufferedIO will significantly increase performance on heavi
The <b>Append</b> option takes a boolean value. It is set to ly
<code>true</code> by default. If true, then <code>File</code> loaded systems.
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. void setBufferedIO(bool bufferedIO);
*/
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. Set the size of the IO buffer.
*/
void setBufferSize(int bufferSize1) { this->bufferSize = bu
fferSize1; }
*/ /**
void setBufferedIO(bool bufferedIO); * Replaces double backslashes with single backslashes
* for compatibility with paths from earlier XML configur
ations files.
* @param name file name
* @return corrected file name
*/
static LogString stripDuplicateBackslashes(const LogString&
name);
/** private:
Set the size of the IO buffer. FileAppender(const FileAppender&);
*/ FileAppender& operator=(const FileAppender&);
void setBufferSize(int bufferSize) { this->bufferSize = bufferSize;
} }; // class FileAppender
LOG4CXX_PTR_DEF(FileAppender);
}; // class FileAppender
} // namespace log4cxx } // namespace log4cxx
#endif #endif
 End of changes. 43 change blocks. 
181 lines changed or deleted 193 lines changed or added


 filewatchdog.h   filewatchdog.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_HELPERS_FILEWATCHDOG_H #ifndef _LOG4CXX_HELPERS_FILEWATCHDOG_H
#define _LOG4CXX_HELPERS_FILEWATCHDOG_H #define _LOG4CXX_HELPERS_FILEWATCHDOG_H
#include <log4cxx/helpers/tchar.h> #include <log4cxx/logstring.h>
#include <log4cxx/helpers/thread.h>
#include <time.h> #include <time.h>
#include <log4cxx/helpers/pool.h>
#include <log4cxx/helpers/thread.h>
#include <log4cxx/file.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
/** /**
Check every now and then that a certain file has not changed Check every now and then that a certain file has not change
. If it d. If it
has, then call the #doOnChange method. has, then call the #doOnChange method.
*/ */
class LOG4CXX_EXPORT FileWatchdog : public Thread class LOG4CXX_EXPORT FileWatchdog
{ {
public: public:
/** virtual ~FileWatchdog();
The default delay between every file modification ch /**
eck, set to 60 The default delay between every file modification c
seconds. */ heck, set to 60
static long DEFAULT_DELAY /*= 60000*/; seconds. */
static long DEFAULT_DELAY /*= 60000*/;
protected: protected:
/** /**
The name of the file to observe for changes. The name of the file to observe for changes.
*/ */
String filename; File file;
/** /**
The delay to observe between every check. The delay to observe between every check.
By default set DEFAULT_DELAY.*/ By default set DEFAULT_DELAY.*/
long delay; long delay;
time_t lastModif; log4cxx_time_t lastModif;
bool warnedAlready; bool warnedAlready;
bool interrupted; volatile unsigned int interrupted;
protected: protected:
FileWatchdog(const String& filename); FileWatchdog(const File& filename);
virtual void doOnChange() = 0; virtual void doOnChange() = 0;
void checkAndConfigure(); void checkAndConfigure();
public: public:
/** /**
Set the delay to observe between each check of the f Set the delay to observe between each check of the
ile changes. file changes.
*/ */
void setDelay(long delay) void setDelay(long delay1)
{ this->delay = delay; } { this->delay = delay1; }
void run(); void start();
void start();
}; private:
} // namespace helpers static void* LOG4CXX_THREAD_FUNC run(apr_thread_t* thre
}; // namespace log4cxx ad, void* data);
Pool pool;
Thread thread;
FileWatchdog(const FileWatchdog&);
FileWatchdog& operator=(const FileWatchdog&);
};
} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_FILEWATCHDOG_H #endif // _LOG4CXX_HELPERS_FILEWATCHDOG_H
 End of changes. 10 change blocks. 
50 lines changed or deleted 63 lines changed or added


 filter.h   filter.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_SPI_FILTER_H #ifndef _LOG4CXX_SPI_FILTER_H
#define _LOG4CXX_SPI_FILTER_H #define _LOG4CXX_SPI_FILTER_H
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/objectimpl.h> #include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/spi/optionhandler.h> #include <log4cxx/spi/optionhandler.h>
#include <log4cxx/spi/loggingevent.h>
namespace log4cxx namespace log4cxx
{ {
namespace spi namespace spi
{ {
class Filter; class Filter;
typedef helpers::ObjectPtrT<Filter> FilterPtr; LOG4CXX_PTR_DEF(Filter);
class LoggingEvent;
typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr;
/** /**
Users should extend this class to implement customized logging Users should extend this class to implement customized logging
event filtering. Note that Logger and event filtering. Note that Logger and
AppenderSkeleton, the parent class of all standard AppenderSkeleton, the parent class of all standard
appenders, have built-in filtering rules. It is suggested that you appenders, have built-in filtering rules. It is suggested that you
first use and understand the built-in rules before rushing to write first use and understand the built-in rules before rushing to write
your own custom filters. your own custom filters.
<p>This abstract class assumes and also imposes that filters be <p>This abstract class assumes and also imposes that filters be
skipping to change at line 69 skipping to change at line 68
<p>If the value #ACCEPT is returned, then the log <p>If the value #ACCEPT is returned, then the log
event is logged without consulting the remaining filters. event is logged without consulting the remaining filters.
<p>The philosophy of log4cxx filters is largely inspired from the <p>The philosophy of log4cxx filters is largely inspired from the
Linux ipchains. Linux ipchains.
<p>Note that filtering is only supported by the {@link <p>Note that filtering is only supported by the {@link
xml::DOMConfigurator DOMConfigurator}. xml::DOMConfigurator DOMConfigurator}.
*/ */
class LOG4CXX_EXPORT Filter : public virtual OptionHandler, class LOG4CXX_EXPORT Filter : public virtual OptionHandler,
public virtual helpers::ObjectImpl public virtual helpers::ObjectImpl
{ {
public: /**
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Filter) Points to the next filter in the filter chain.
BEGIN_LOG4CXX_CAST_MAP() */
LOG4CXX_CAST_ENTRY(Filter) FilterPtr next;
LOG4CXX_CAST_ENTRY(spi::OptionHandler) public:
END_LOG4CXX_CAST_MAP() Filter();
/**
Points to the next filter in the filter chain. void addRef() const;
*/ void releaseRef() const;
FilterPtr next;
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Filter)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(Filter)
LOG4CXX_CAST_ENTRY(spi::OptionHandler)
END_LOG4CXX_CAST_MAP()
log4cxx::spi::FilterPtr getNext() const;
void setNext(const log4cxx::spi::FilterPtr& newNext
);
enum FilterDecision enum FilterDecision
{ {
/** /**
The log event must be dropped immediately without consulting The log event must be dropped immediately without consulting
with the remaining filters, if any, in the chain. * with the remaining filters, if any, in the chain.
/ */
DENY = -1, DENY = -1,
/** /**
This filter is neutral with respect to the log event. The This filter is neutral with respect to the log event. The
remaining filters, if any, should be consulted for a final deci sion. remaining filters, if any, should be consulted for a final deci sion.
*/ */
NEUTRAL = 0, NEUTRAL = 0,
/** /**
The log event must be logged immediately without consulting wit h The log event must be logged immediately without consulting wit h
the remaining filters, if any, in the chain. the remaining filters, if any, in the chain.
*/ */
ACCEPT = 1 ACCEPT = 1
}; };
/** /**
Usually filters options become active when set. We provide a Usually filters options become active when set. We provide a
default do-nothing implementation for convenience. default do-nothing implementation for convenience.
*/ */
void activateOptions() {} void activateOptions(log4cxx::helpers::Pool& p);
void setOption(const String& option, const String& value) {} void setOption(const LogString& option, const LogString& value)
;
/** /**
<p>If the decision is <code>DENY</code>, then the event will be <p>If the decision is <code>DENY</code>, then the event will be
dropped. If the decision is <code>NEUTRAL</code>, then the next dropped. If the decision is <code>NEUTRAL</code>, then the next
filter, if any, will be invoked. If the decision is ACCEPT then filter, if any, will be invoked. If the decision is ACCEPT then
the event will be logged without consulting with other filters in the event will be logged without consulting with other filters in
the chain. the chain.
@param event The LoggingEvent to decide upon. @param event The LoggingEvent to decide upon.
@return The decision of the filter. */ @return The decision of the filter. */
virtual FilterDecision decide(const LoggingEventPtr& event) con st = 0; virtual FilterDecision decide(const LoggingEventPtr& event) con st = 0;
}; };
} }
} }
#endif //_LOG4CXX_SPI_FILTER_H #endif //_LOG4CXX_SPI_FILTER_H
 End of changes. 10 change blocks. 
36 lines changed or deleted 45 lines changed or added


 formattinginfo.h   formattinginfo.h 
/* /*
* Copyright 2003,2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LOG4CXX_HELPER_FORMATTING_INFO_H #ifndef _LOG4CXX_HELPER_FORMATTING_INFO_H
#define _LOG4CXX_HELPER_FORMATTING_INFO_H #define _LOG4CXX_HELPER_FORMATTING_INFO_H
#include <log4cxx/config.h> #include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/logstring.h>
namespace log4cxx namespace log4cxx {
{ namespace pattern {
namespace helpers
{
/**
FormattingInfo instances contain the information obtained wh
en parsing
formatting modifiers in conversion modifiers.
*/
class LOG4CXX_EXPORT FormattingInfo
{
public:
int minChar; class FormattingInfo;
int maxChar; typedef helpers::ObjectPtrT<FormattingInfo> FormattingInfoPtr;
bool leftAlign;
FormattingInfo(); /**
void reset(); * Modifies the output of a pattern converter for a specified minimum
void dump(); * and maximum width and alignment.
*
*
*
*
*/
class LOG4CXX_EXPORT FormattingInfo : public virtual log4cxx::helpers::Obje
ctImpl {
}; // class FormattingInfo /**
} // namespace helpers * Minimum length.
}; // namespace log4cxx */
const int minLength;
#endif // _LOG4CXX_HELPER_FORMATTING_INFO_H /**
* Maximum length.
*/
const int maxLength;
/**
* Alignment.
*/
const bool leftAlign;
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(FormattingInfo)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(FormattingInfo)
END_LOG4CXX_CAST_MAP()
/**
* Creates new instance.
* @param leftAlign left align if true.
* @param minLength minimum length.
* @param maxLength maximum length.
*/
FormattingInfo(
const bool leftAlign, const int minLength, const int maxLength);
/**
* Gets default instance.
* @return default instance.
*/
static FormattingInfoPtr getDefault();
/**
* Determine if left aligned.
* @return true if left aligned.
*/
inline bool isLeftAligned() const {
return leftAlign;
}
/**
* Get minimum length.
* @return minimum length.
*/
inline int getMinLength() const {
return minLength;
}
/**
* Get maximum length.
* @return maximum length.
*/
inline int getMaxLength() const {<