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 {
return maxLength;
}
/**
* Adjust the content of the buffer based on the specified lengths and al
ignment.
*
* @param fieldStart start of field in buffer.
* @param buffer buffer to be modified.
*/
void format(const int fieldStart, LogString& buffer) const;
};
LOG4CXX_PTR_DEF(FormattingInfo);
}
}
#endif
 End of changes. 7 change blocks. 
27 lines changed or deleted 26 lines changed or added


 hierarchy.h   hierarchy.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_HIERARCHY_H #ifndef _LOG4CXX_HIERARCHY_H
#define _LOG4CXX_HIERARCHY_H #define _LOG4CXX_HIERARCHY_H
#if defined(_MSC_VER)
#pragma warning (push)
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/spi/loggerrepository.h> #include <log4cxx/spi/loggerrepository.h>
#include <log4cxx/spi/loggerfactory.h> #include <log4cxx/spi/loggerfactory.h>
#include <vector> #include <vector>
#include <map> #include <map>
#include <log4cxx/provisionnode.h> #include <log4cxx/provisionnode.h>
#include <log4cxx/helpers/objectimpl.h> #include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/criticalsection.h>
#include <log4cxx/spi/hierarchyeventlistener.h> #include <log4cxx/spi/hierarchyeventlistener.h>
#include <log4cxx/helpers/pool.h>
namespace log4cxx namespace log4cxx
{ {
namespace spi /**
{ This class is specialized in retrieving loggers by name and also
class HierarchyEventListener; maintaining the logger hierarchy.
typedef log4cxx::helpers::ObjectPtrT<HierarchyEventListener>
HierarchyEventListenerPtr;
typedef std::vector<HierarchyEventListenerPtr> HierarchyEven
tListenerList;
}
/** <p><em>The casual user does not have to deal with this class
This class is specialized in retrieving loggers by name and also directly.</em>
maintaining the logger hierarchy.
<p><em>The casual user does not have to deal with this class <p>The structure of the logger hierarchy is maintained by the
directly.</em> #getLogger method. The hierarchy is such that children link
to their parent but parents do not have any pointers to their
children. Moreover, loggers can be instantiated in any order, in
particular descendant before ancestor.
<p>The structure of the logger hierarchy is maintained by the <p>In case a descendant is created before a particular ancestor,
#getLogger method. The hierarchy is such that children link then it creates a provision node for the ancestor and adds itself
to their parent but parents do not have any pointers to their to the provision node. Other descendants of the same ancestor add
children. Moreover, loggers can be instantiated in any order, in themselves to the previously created provision node.
particular descendant before ancestor. */
class LOG4CXX_EXPORT Hierarchy :
public virtual spi::LoggerRepository,
public virtual helpers::ObjectImpl
{
private:
log4cxx::helpers::Pool pool;
log4cxx::helpers::Mutex mutex;
bool configured;
<p>In case a descendant is created before a particular ancestor, spi::LoggerFactoryPtr defaultFactory;
then it creates a provision node for the ancestor and adds itself spi::HierarchyEventListenerList listeners;
to the provision node. Other descendants of the same ancestor add
themselves to the previously created provision node.
*/
class LOG4CXX_EXPORT Hierarchy :
public virtual spi::LoggerRepository,
public virtual helpers::ObjectImpl
{
private:
spi::LoggerFactoryPtr defaultFactory;
spi::HierarchyEventListenerList listeners;
typedef std::map<String, LoggerPtr> LoggerMap; typedef std::map<LogString, LoggerPtr> LoggerMap;
LoggerMap loggers; LoggerMap* loggers;
typedef std::map<String, ProvisionNode> ProvisionNodeMap; typedef std::map<LogString, ProvisionNode> ProvisionNodeMap;
ProvisionNodeMap provisionNodes; ProvisionNodeMap* provisionNodes;
LoggerPtr root; LoggerPtr root;
int thresholdInt; int thresholdInt;
LevelPtr threshold; LevelPtr threshold;
bool emittedNoAppenderWarning; bool emittedNoAppenderWarning;
bool emittedNoResourceBundleWarning; bool emittedNoResourceBundleWarning;
/** public:
Map synchronization DECLARE_ABSTRACT_LOG4CXX_OBJECT(Hierarchy)
*/ BEGIN_LOG4CXX_CAST_MAP()
mutable helpers::CriticalSection mapCs; LOG4CXX_CAST_ENTRY(spi::LoggerRepository)
END_LOG4CXX_CAST_MAP()
public: /**
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Hierarchy) Create a new logger hierarchy.
BEGIN_LOG4CXX_CAST_MAP() */
LOG4CXX_CAST_ENTRY(spi::LoggerRepository) Hierarchy();
END_LOG4CXX_CAST_MAP()
/** ~Hierarchy();
Create a new logger hierarchy.
@param root The root of the new hierarchy.
*/ void addRef() const;
Hierarchy(const LoggerPtr& root); void releaseRef() const;
~Hierarchy(); void addHierarchyEventListener(const spi::HierarchyEventListene rPtr& listener);
public: /**
void addHierarchyEventListener(const spi::HierarchyEventList This call will clear all logger definitions from the internal
enerPtr& listener); hashtable. Invoking this method will irrevocably mess up the
logger hierarchy.
/** <p>You should <em>really</em> know what you are doing before
This call will clear all logger definitions from the interna invoking this method.
l */
hashtable. Invoking this method will irrevocably mess up the void clear();
logger hierarchy.
<p>You should <em>really</em> know what you are doing before void emitNoAppenderWarning(const LoggerPtr& logger);
invoking this method.
*/
public:
void clear();
public: /**
void emitNoAppenderWarning(const LoggerPtr& logger); Check if the named logger exists in the hierarchy. If so return
its reference, otherwise returns <code>null</code>.
/** @param name The name of the logger to search for.
Check if the named logger exists in the hierarchy. If so ret
urn
its reference, otherwise returns <code>null</code>.
@param name The name of the logger to search for. */
LoggerPtr exists(const LogString& name);
*/ /**
public: The string form of {@link #setThreshold(const LevelPtr&) setThr
LoggerPtr exists(const String& name); eshold}.
*/
void setThreshold(const LogString& levelStr);
/** /**
The string form of {@link #setThreshold(const LevelPtr&) set Enable logging for logging requests with level <code>l</code> o
Threshold}. r
*/ higher. By default all levels are enabled.
public:
void setThreshold(const String& levelStr);
/** @param l The minimum level for which logging requests a
Enable logging for logging requests with level <code>l</code> or re sent to
higher. By default all levels are enabled. their appenders. */
void setThreshold(const LevelPtr& l);
@param l The minimum level for which logging requests are se void fireAddAppenderEvent(const LoggerPtr& logger, const Append
nt to erPtr& appender);
their appenders. */
public:
void setThreshold(const LevelPtr& l);
public: void fireRemoveAppenderEvent(const LoggerPtr& logger,
void fireAddAppenderEvent(const LoggerPtr& logger, const App const AppenderPtr& appender);
enderPtr& appender);
public: /**
void fireRemoveAppenderEvent(const LoggerPtr& logger, Returns a Level representation of the <code>enable</code>
const AppenderPtr& appender); state.
*/
const LevelPtr& getThreshold() const;
/** /**
Returns a Level representation of the <code>enable</code> Return a new logger instance named as the first parameter using
state. the default factory.
*/
public:
const LevelPtr& getThreshold() const;
/** <p>If a logger of that name already exists, then it will be
Return a new logger instance named as the first parameter us returned. Otherwise, a new logger will be instantiated and
ing then linked with its existing ancestors as well as children.
the default factory.
<p>If a logger of that name already exists, then it will be @param name The name of the logger to retrieve.
returned. Otherwise, a new logger will be instantiated and
then linked with its existing ancestors as well as children.
@param name The name of the logger to retrieve. */
LoggerPtr getLogger(const LogString& name);
*/ /**
public: Return a new logger instance named as the first parameter using
LoggerPtr getLogger(const String& name); <code>factory</code>.
/** <p>If a logger of that name already exists, then it will be
Return a new logger instance named as the first parameter us returned. Otherwise, a new logger will be instantiated by the
ing <code>factory</code> parameter and linked with its existing
<code>factory</code>. ancestors as well as children.
<p>If a logger of that name already exists, then it will be @param name The name of the logger to retrieve.
returned. Otherwise, a new logger will be instantiated by t @param factory The factory that will make the new logger instan
he ce.
<code>factory</code> parameter and linked with its existing
ancestors as well as children.
@param name The name of the logger to retrieve. */
@param factory The factory that will make the new logger ins LoggerPtr getLogger(const LogString& name,
tance. const spi::LoggerFactoryPtr& factory);
*/ /**
public: Returns all the currently defined loggers in this hierarchy as
LoggerPtr getLogger(const String& name, spi::LoggerFactoryPt a LoggerList.
r factory);
/** <p>The root logger is <em>not</em> included in the returned
Returns all the currently defined loggers in this hierarchy LoggerList. */
as LoggerList getCurrentLoggers() const;
a LoggerList.
<p>The root logger is <em>not</em> included in the returned /**
LoggerList. */ Get the root of this hierarchy.
public: */
LoggerList getCurrentLoggers() const; LoggerPtr getRootLogger() const;
/** /**
Get the root of this hierarchy. This method will return <code>true</code> if this repository is
*/ disabled for <code>level</code> object passed as parameter and
public: <code>false</code> otherwise. See also the
LoggerPtr getRootLogger() const; {@link #setThreshold(const LevelPtr&) setThreshold} method. */
bool isDisabled(int level) const;
/** /**
This method will return <code>true</code> if this repository Reset all values contained in this hierarchy instance to their
is default. This removes all appenders from all categories, sets
disabled for <code>level</code> object passed as parameter a the level of all non-root categories to <code>null</code>,
nd sets their additivity flag to <code>true</code> and sets the le
<code>false</code> otherwise. See also the vel
{@link #setThreshold(const LevelPtr&) setThreshold} method. of the root logger to DEBUG. Moreover,
*/ message disabling is set its default "off" value.
public:
bool isDisabled(int level) const;
/** <p>Existing categories are not removed. They are just reset.
Reset all values contained in this hierarchy instance to the
ir
default. This removes all appenders from all categories, se
ts
the level of all non-root categories to <code>null</code>,
sets their additivity flag to <code>true</code> and sets the
level
of the root logger to {@link Level#DEBUG DEBUG}. Moreover,
message disabling is set its default "off" value.
<p>Existing categories are not removed. They are just reset. <p>This method should be used sparingly and with care as it wil
l
block all logging until it is completed.</p>
*/
void resetConfiguration();
<p>This method should be used sparingly and with care as it /**
will Used by subclasses to add a renderer to the hierarchy passed as
block all logging until it is completed.</p> parameter.
*/ */
public: /**
void resetConfiguration(); Shutting down a hierarchy will <em>safely</em> close and remove
all appenders in all categories including the root logger.
/** <p>Some appenders such as {@link net::SocketAppender SocketAppe
Used by subclasses to add a renderer to the hierarchy passed nder}
as parameter. and AsyncAppender need to be closed before the
*/ application exists. Otherwise, pending logging events might be
public: lost.
/**
Shutting down a hierarchy will <em>safely</em> close and rem
ove
all appenders in all categories including the root logger.
<p>Some appenders such as {@link net::SocketAppender SocketA <p>The <code>shutdown</code> method is careful to close nested
ppender} appenders before closing regular appenders. This is allows
and AsyncAppender need to be closed before the configurations where a regular appender is attached to a logger
application exists. Otherwise, pending logging events might and again to a nested appender.
be */
lost. void shutdown();
<p>The <code>shutdown</code> method is careful to close nest virtual bool isConfigured();
ed virtual void setConfigured(bool configured);
appenders before closing regular appenders. This is allows
configurations where a regular appender is attached to a log
ger
and again to a nested appender.
*/
public:
void shutdown(); private:
/** /**
This method loops through all the *potential* parents of This method loops through all the *potential* parents of
'cat'. There 3 possible cases: 'cat'. There 3 possible cases:
1) No entry for the potential parent of 'cat' exists 1) No entry for the potential parent of 'cat' exists
We create a ProvisionNode for this potential parent and inse We create a ProvisionNode for this potential parent and insert
rt 'cat' in that provision node.
'cat' in that provision node.
2) There entry is of type Logger for the potential parent. 2) There entry is of type Logger for the potential parent.
The entry is 'cat's nearest existing parent. We update cat's The entry is 'cat's nearest existing parent. We update cat's
parent field with this entry. We also break from the loop parent field with this entry. We also break from the loop
because updating our parent's parent is our parent's because updating our parent's parent is our parent's
responsibility. responsibility.
3) There entry is of type ProvisionNode for this potential p arent. 3) There entry is of type ProvisionNode for this potential pare nt.
We add 'cat' to the list of children for this potential pare We add 'cat' to the list of children for this potential parent.
nt. */
*/ void updateParents(LoggerPtr logger);
private:
void updateParents(LoggerPtr& logger);
/** /**
We update the links for all the children that placed themsel We update the links for all the children that placed themselves
ves in the provision node 'pn'. The second argument 'cat' is a
in the provision node 'pn'. The second argument 'cat' is a reference for the newly created Logger, parent of all the
reference for the newly created Logger, parent of all the children in 'pn'
children in 'pn'
We loop on all the children 'c' in 'pn': We loop on all the children 'c' in 'pn':
If the child 'c' has been already linked to a child of If the child 'c' has been already linked to a child of
'cat' then there is no need to update 'c'. 'cat' then there is no need to update 'c'.
Otherwise, we set cat's parent field to c's parent and set Otherwise, we set cat's parent field to c's parent and set
c's parent field to cat. c's parent field to cat.
*/ */
private: Hierarchy(const Hierarchy&);
Hierarchy& operator=(const Hierarchy&);
void updateChildren(ProvisionNode& pn, LoggerPtr logger);
};
void updateChildren(ProvisionNode& pn, LoggerPtr& logger);
};
} //namespace log4cxx } //namespace log4cxx
#if defined(_MSC_VER)
#pragma warning (pop)
#endif
#endif //_LOG4CXX_HIERARCHY_H #endif //_LOG4CXX_HIERARCHY_H
 End of changes. 64 change blocks. 
233 lines changed or deleted 204 lines changed or added


 hierarchyeventlistener.h   hierarchyeventlistener.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_HIERARCHY_EVENT_LISTENER_H #ifndef _LOG4CXX_SPI_HIERARCHY_EVENT_LISTENER_H
#define _LOG4CXX_SPI_HIERARCHY_EVENT_LISTENER_H #define _LOG4CXX_SPI_HIERARCHY_EVENT_LISTENER_H
#if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/helpers/object.h> #include <log4cxx/helpers/object.h>
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
#include <vector> #include <vector>
namespace log4cxx namespace log4cxx
{ {
class Logger; class Logger;
typedef helpers::ObjectPtrT<Logger> LoggerPtr; class Appender;
class Appender;
typedef helpers::ObjectPtrT<Appender> AppenderPtr;
namespace spi namespace spi
{ {
class HierarchyEventListener;
typedef log4cxx::helpers::ObjectPtrT<HierarchyEventListener>
HierarchyEventListenerPtr;
typedef std::vector<HierarchyEventListenerPtr> HierarchyEven
tListenerList;
/** Listen to events occuring within a Hierarchy.*/ /** Listen to events occuring within a Hierarchy.*/
class LOG4CXX_EXPORT HierarchyEventListener : class LOG4CXX_EXPORT HierarchyEventListener :
public virtual log4cxx::helpers::Object public virtual log4cxx::helpers::Object
{ {
public: public:
virtual ~HierarchyEventListener() {} virtual ~HierarchyEventListener() {}
virtual void addAppenderEvent(const LoggerPtr& logge virtual void addAppenderEvent(
r, const AppenderPtr& const log4cxx::helpers::ObjectPtrT<Logger>& logger,
appender) = 0; const log4cxx::helpers::ObjectPtrT<Appender>& appender
) = 0;
virtual void removeAppenderEvent(const LoggerPtr& lo virtual void removeAppenderEvent(
gger, const log4cxx::helpers::ObjectPtrT<Logger>& logger,
const AppenderPtr& appender) = 0; const log4cxx::helpers::ObjectPtrT<Appender>& appender
}; ) = 0;
} // namespace spi };
}; // namespace log4cxx LOG4CXX_PTR_DEF(HierarchyEventListener);
LOG4CXX_LIST_DEF(HierarchyEventListenerList, HierarchyEvent
ListenerPtr);
} // namespace spi
} // namespace log4cxx
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#endif //_LOG4CXX_SPI_HIERARCHY_EVENT_LISTENER_H #endif //_LOG4CXX_SPI_HIERARCHY_EVENT_LISTENER_H
 End of changes. 7 change blocks. 
31 lines changed or deleted 40 lines changed or added


 htmllayout.h   htmllayout.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_HTML_LAYOUT_H #ifndef _LOG4CXX_HTML_LAYOUT_H
#define _LOG4CXX_HTML_LAYOUT_H #define _LOG4CXX_HTML_LAYOUT_H
#if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/layout.h> #include <log4cxx/layout.h>
#include <log4cxx/helpers/iso8601dateformat.h> #include <log4cxx/helpers/iso8601dateformat.h>
namespace log4cxx namespace log4cxx
{ {
class HTMLLayout; /**
typedef helpers::ObjectPtrT<HTMLLayout> HTMLLayoutPtr; This layout outputs events in a HTML table.
*/
/** class LOG4CXX_EXPORT HTMLLayout : public Layout
This layout outputs events in a HTML table. {
*/ private:
class LOG4CXX_EXPORT HTMLLayout : public Layout // Print no location info by default
{ bool locationInfo; //= false
protected:
static String TRACE_PREFIX;
private:
/**
A string constant used in naming the option for setting the
the
location information flag. Current value of this string
constant is <b>LocationInfo</b>.
*/
static String LOCATION_INFO_OPTION;
/**
A string constant used in naming the option for setting the
the
HTML document title. Current value of this string
constant is <b>Title</b>.
*/
static String TITLE_OPTION;
// Print no location info by default
bool locationInfo; //= false
String title; LogString title;
helpers::ISO8601DateFormat dateFormat; helpers::ISO8601DateFormat dateFormat;
public: public:
DECLARE_LOG4CXX_OBJECT(HTMLLayout) DECLARE_LOG4CXX_OBJECT(HTMLLayout)
BEGIN_LOG4CXX_CAST_MAP() BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(HTMLLayout) LOG4CXX_CAST_ENTRY(HTMLLayout)
LOG4CXX_CAST_ENTRY_CHAIN(Layout) LOG4CXX_CAST_ENTRY_CHAIN(Layout)
END_LOG4CXX_CAST_MAP() END_LOG4CXX_CAST_MAP()
HTMLLayout(); HTMLLayout();
/** /**
The <b>LocationInfo</b> option takes a boolean value. By The <b>LocationInfo</b> option takes a boolean value. By
default, it is set to false which means there will be no loc default, it is set to false which means there will be no lo
ation cation
information output by this layout. If the the option is set information output by this layout. If the the option is set
to to
true, then the file name and line number of the statement true, then the file name and line number of the statement
at the origin of the log statement will be output. at the origin of the log statement will be output.
<p>If you are embedding this layout within an <p>If you are embedding this layout within an
{@link net::SMTPAppender SMTPAppender} then make sure {@link net::SMTPAppender SMTPAppender} then make sure
to set the <b>LocationInfo</b> option of that appender as we to set the <b>LocationInfo</b> option of that appender as w
ll. ell.
*/ */
inline void setLocationInfo(bool flocationInfoag) inline void setLocationInfo(bool locationInfoFlag)
{ this->locationInfo = locationInfo; } { this->locationInfo = locationInfoFlag; }
/** /**
Returns the current value of the <b>LocationInfo</b> option. Returns the current value of the <b>LocationInfo</b> option
*/ .
inline bool getLocationInfo() const */
{ return locationInfo; } inline bool getLocationInfo() const
{ return locationInfo; }
/** /**
The <b>Title</b> option takes a String value. This option se The <b>Title</b> option takes a String value. This option s
ts the ets the
document title of the generated HTML document. document title of the generated HTML document.
<p>Defaults to 'Log4cxx Log Messages'. <p>Defaults to 'Log4cxx Log Messages'.
*/ */
inline void setTitle(const String& title) inline void setTitle(const LogString& title1)
{ this->title = title; } { this->title.assign(title1); }
/** /**
Returns the current value of the <b>Title</b> option. Returns the current value of the <b>Title</b> option.
*/ */
inline const String& getTitle() const inline const LogString& getTitle() const
{ return title; } { return title; }
/** /**
Returns the content type output by this layout, i.e "text/ht Returns the content type output by this layout, i.e "text/h
ml". tml".
*/ */
virtual String getContentType() const { return _T("text/html virtual LogString getContentType() const { return LOG4CXX_S
"); } TR("text/html"); }
/** /**
No options to activate. No options to activate.
*/ */
virtual void activateOptions() {} virtual void activateOptions(log4cxx::helpers::Pool& /* p *
/) {}
/** /**
Set options Set options
*/ */
virtual void setOption(const String& option, const String& v virtual void setOption(const LogString& option, const LogSt
alue); ring& value);
virtual void format(ostream& output, const spi::LoggingEvent virtual void format(LogString& output,
Ptr& event) const; const spi::LoggingEventPtr& event, log4cxx::helpers::P
ool& pool) const;
/** /**
Append appropriate HTML headers. Append appropriate HTML headers.
*/ */
virtual void appendHeader(ostream& output); virtual void appendHeader(LogString& output, log4cxx::helpe
rs::Pool& pool);
/** /**
Append the appropriate HTML footers. Append the appropriate HTML footers.
*/ */
virtual void appendFooter(ostream& output); virtual void appendFooter(LogString& output, log4cxx::helpe
rs::Pool& pool);
/** /**
The HTML layout handles the throwable contained in logging The HTML layout handles the throwable contained in logging
events. Hence, this method return <code>false</code>. */ events. Hence, this method return <code>false</code>. */
virtual bool ignoresThrowable() const virtual bool ignoresThrowable() const
{ return false; } { return false; }
}; // class HtmlLayout }; // class HtmlLayout
LOG4CXX_PTR_DEF(HTMLLayout);
} // namespace log4cxx } // namespace log4cxx
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#endif // _LOG4CXX_HTML_LAYOUT_H #endif // _LOG4CXX_HTML_LAYOUT_H
 End of changes. 21 change blocks. 
108 lines changed or deleted 102 lines changed or added


 inetaddress.h   inetaddress.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_INETADDRESS_H #ifndef _LOG4CXX_HELPER_INETADDRESS_H
#define _LOG4CXX_HELPER_INETADDRESS_H #define _LOG4CXX_HELPER_INETADDRESS_H
#include <log4cxx/helpers/tchar.h> #if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/logstring.h>
#include <vector> #include <vector>
#include <log4cxx/helpers/exception.h> #include <log4cxx/helpers/exception.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class LOG4CXX_EXPORT UnknownHostException : public Exception class LOG4CXX_EXPORT UnknownHostException : public Exceptio
{ n
}; {
public:
UnknownHostException(const LogString& msg);
UnknownHostException(const UnknownHostException& src)
;
UnknownHostException& operator=(const UnknownHostExce
ption& src);
};
class LOG4CXX_EXPORT InetAddress class InetAddress;
{ LOG4CXX_PTR_DEF(InetAddress);
public: LOG4CXX_LIST_DEF(InetAddressList, InetAddressPtr);
InetAddress();
/** Returns the raw IP address of this InetAddress class LOG4CXX_EXPORT InetAddress : public ObjectImpl
object. {
*/ public:
int getAddress() const; DECLARE_ABSTRACT_LOG4CXX_OBJECT(InetAddress)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(InetAddress)
END_LOG4CXX_CAST_MAP()
/** Determines all the IP addresses of a host, given InetAddress(const LogString& hostName, const LogStr
the host's name. ing& hostAddr);
*/
static std::vector<InetAddress> getAllByName(const S
tring& host);
/** Determines the IP address of a host, given the h /** Determines all the IP addresses of a host, give
ost's name. n the host's name.
*/ */
static InetAddress getByName(const String& host); static InetAddressList getAllByName(const LogString
& host);
/** Returns the IP address string "%d.%d.%d.%d". /** Determines the IP address of a host, given the
*/ host's name.
String getHostAddress() const; */
static InetAddressPtr getByName(const LogString& ho
st);
/** Gets the host name for this IP address. /** Returns the IP address string "%d.%d.%d.%d".
*/ */
String getHostName() const; LogString getHostAddress() const;
/** Returns the local host. /** Gets the host name for this IP address.
*/ */
static InetAddress getLocalHost(); LogString getHostName() const;
/** Utility routine to check if the InetAddress is a /** Returns the local host.
n IP multicast address. */
*/ static InetAddressPtr getLocalHost();
bool isMulticastAddress() const;
/** Converts this IP address to a String. /** Returns an InetAddress which can be used as any
*/ * address, for example when listening on a port f
String toString() const; rom any
* remote addresss.
*/
static InetAddressPtr anyAddress();
int address; /** Converts this IP address to a String.
}; // class InetAddress */
} // namespace helpers LogString toString() const;
}; // namespace log4cxx
private:
LogString ipAddrString;
LogString hostNameString;
}; // class InetAddress
} // namespace helpers
} // namespace log4cxx
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#endif // _LOG4CXX_HELPER_INETADDRESS_H #endif // _LOG4CXX_HELPER_INETADDRESS_H
 End of changes. 13 change blocks. 
48 lines changed or deleted 79 lines changed or added


 iso8601dateformat.h   iso8601dateformat.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_ISO_8601_DATE_FORMAT_H #ifndef _LOG4CXX_HELPERS_ISO_8601_DATE_FORMAT_H
#define _LOG4CXX_HELPERS_ISO_8601_DATE_FORMAT_H #define _LOG4CXX_HELPERS_ISO_8601_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>\%Y-\%m-\%d \%H:\%M:\%S,\%Q< Formats a date in the format <b>yyyy-MM-dd HH:mm:ss,SSS</b>
/b> for example for example
"1999-11-27 15:49:37,459". "1999-11-27 15:49:37,459".
<p>Refer to the <p>Refer to the
<a href=http://www.cl.cam.ac.uk/~mgk25/iso-time.html>summary <a href=http://www.cl.cam.ac.uk/~mgk25/iso-time.html>summar
of the y of the
International Standard Date and Time Notation</a> for more International Standard Date and Time Notation</a> for more
information on this format. information on this format.
*/ */
class LOG4CXX_EXPORT ISO8601DateFormat : public DateFormat class LOG4CXX_EXPORT ISO8601DateFormat : public SimpleDateF
{ ormat
public: {
ISO8601DateFormat(const TimeZonePtr& timeZone) public:
: DateFormat(_T("%Y-%m-%d %H:%M:%S,%Q"), timeZone) ISO8601DateFormat()
{} : SimpleDateFormat(LOG4CXX_STR("yyyy-MM-dd HH:mm:s
}; s,SSS")) {}
} // namespace helpers };
}; // namespace log4cxx } // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_ISO_8601_DATE_FORMAT_H #endif // _LOG4CXX_HELPERS_ISO_8601_DATE_FORMAT_H
 End of changes. 4 change blocks. 
27 lines changed or deleted 29 lines changed or added


 layout.h   layout.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_LAYOUT_H #ifndef _LOG4CXX_LAYOUT_H
#define _LOG4CXX_LAYOUT_H #define _LOG4CXX_LAYOUT_H
#if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/helpers/objectimpl.h> #include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
#include <log4cxx/spi/optionhandler.h> #include <log4cxx/spi/optionhandler.h>
#include <log4cxx/spi/loggingevent.h>
namespace log4cxx namespace log4cxx
{ {
class Layout; /**
typedef helpers::ObjectPtrT<Layout> LayoutPtr; Extend this abstract class to create your own log layout format.
*/
namespace spi class LOG4CXX_EXPORT Layout :
{ public virtual spi::OptionHandler,
class LoggingEvent; public virtual helpers::ObjectImpl
typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr; {
} public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Layout)
/** BEGIN_LOG4CXX_CAST_MAP()
Extend this abstract class to create your own log layout format. LOG4CXX_CAST_ENTRY(Layout)
*/ LOG4CXX_CAST_ENTRY(spi::OptionHandler)
class LOG4CXX_EXPORT Layout : END_LOG4CXX_CAST_MAP()
public virtual spi::OptionHandler,
public virtual helpers::ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Layout)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(Layout)
LOG4CXX_CAST_ENTRY(spi::OptionHandler)
END_LOG4CXX_CAST_MAP()
virtual ~Layout() {} virtual ~Layout();
void addRef() const;
void releaseRef() const;
/** /**
Implement this method to create your own layout format. Implement this method to create your own layout format.
*/ */
virtual void format(ostream& output, const spi::LoggingEvent virtual void format(LogString& output,
Ptr& event) const = 0; const spi::LoggingEventPtr& event, log4cxx::helpers::Po
ol& pool) const = 0;
/** /**
Returns the content type output by this layout. The base cla Returns the content type output by this layout. The base cl
ss ass
returns "text/plain". returns "text/plain".
*/ */
virtual String getContentType() const { return _T("text/plai virtual LogString getContentType() const;
n"); }
/** /**
Append the header for the layout format. The base class does Append the header for the layout format. The base class doe
nothing. s
*/ nothing.
virtual void appendHeader(ostream& output) {} */
virtual void appendHeader(LogString& output, log4cxx::helpe
rs::Pool& p);
/** /**
Append the footer for the layout format. The base class does Append the footer for the layout format. The base class doe
nothing. s
*/ nothing.
virtual void appendFooter(ostream& output) {} */
virtual void appendFooter(LogString& output, log4cxx::helpe
rs::Pool& p);
/** /**
If the layout handles the throwable object contained within If the layout handles the throwable object contained within
{@link spi::LoggingEvent LoggingEvent}, then the layout shou {@link spi::LoggingEvent LoggingEvent}, then the layout sho
ld return uld return
<code>false</code>. Otherwise, if the layout ignores throwab <code>false</code>. Otherwise, if the layout ignores throwa
le ble
object, then the layout should return <code>true</code>. object, then the layout should return <code>true</code>.
<p>The SimpleLayout, TTCCLayout, <p>The SimpleLayout, TTCCLayout,
PatternLayout all return <code>true</code>. The {@link PatternLayout all return <code>true</code>. The {@link
xml::XMLLayout XMLLayout} returns <code>false</code>. xml::XMLLayout XMLLayout} returns <code>false</code>.
*/ */
virtual bool ignoresThrowable() const = 0; virtual bool ignoresThrowable() const = 0;
}; };
LOG4CXX_PTR_DEF(Layout);
} }
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#endif // _LOG4CXX_LAYOUT_H #endif // _LOG4CXX_LAYOUT_H
 End of changes. 12 change blocks. 
63 lines changed or deleted 72 lines changed or added


 level.h   level.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.
*/ */
#include <log4cxx/helpers/tchar.h>
#include <limits.h>
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/objectptr.h>
#ifndef _LOG4CXX_LEVEL_H #ifndef _LOG4CXX_LEVEL_H
#define _LOG4CXX_LEVEL_H #define _LOG4CXX_LEVEL_H
// Windows specific : #include <log4cxx/logstring.h>
// wingdi.h defines ERROR #include <limits.h>
#ifdef ERROR #include <log4cxx/helpers/objectimpl.h>
#define OLD_ERROR ERROR #include <log4cxx/helpers/objectptr.h>
#undef ERROR
#endif
// Windows specific :
// atldef.h defines DEBUG
#ifdef DEBUG
#define OLD_DEBUG DEBUG
#undef DEBUG
#endif
namespace log4cxx namespace log4cxx
{ {
class Level; class Level;
/** smart pointer to a Level instance */ /** smart pointer to a Level instance */
typedef helpers::ObjectPtrT<Level> LevelPtr; LOG4CXX_PTR_DEF(Level);
/**
Defines the minimum set of levels recognized by the system, that is
<code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>,
<code>WARN</code>, <code>INFO</code>, <code>DEBUG</code> and
<code>ALL</code>.
<p>The <code>Level</code> class may be subclassed to define a larger
level set.
*/
class LOG4CXX_EXPORT Level : public helpers::ObjectImpl
{
public:
class LOG4CXX_EXPORT LevelClass : public helpers::Class
{
protected:
LevelClass(const String& className) : helpers::Class
(className) {}
public:
LevelClass() : helpers::Class(_T("Level")) {}
virtual const LevelPtr& toLevel(const String& sArg)
const
{ return Level::toLevel(sArg); }
virtual const LevelPtr& toLevel(int val) const
{ return Level::toLevel(val); }
};
DECLARE_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(Level, LevelClass)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(Level)
END_LOG4CXX_CAST_MAP()
/**
Instantiate a Level object.
*/
Level(int level, const String& levelStr, int syslogEquivalen
t);
/**
Convert the string passed as argument to a level. If the
conversion fails, then this method returns #DEBUG.
*/
static const LevelPtr& toLevel(const String& sArg);
/** /**
Convert an integer passed as argument to a level. If the Defines the minimum set of levels recognized by the system, that is
conversion fails, then this method returns #DEBUG. <code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>,
*/ <code>WARN</code>, <code>INFO</code>, <code>DEBUG</code> and
static const LevelPtr& toLevel(int val); <code>ALL</code>.
<p>The <code>Level</code> class may be subclassed to define a large
r
level set.
*/
class LOG4CXX_EXPORT Level : public helpers::ObjectImpl
{
public:
class LOG4CXX_EXPORT LevelClass : public helpers::Class
{
public:
LevelClass() : helpers::Class() {}
/** virtual LogString getName() const {
Convert an integer passed as argument to a level. If the return LOG4CXX_STR("Level");
conversion fails, then this method returns the specified def }
ault.
*/
static const LevelPtr& toLevel(int val, const LevelPtr& defa
ultLevel);
/** virtual LevelPtr toLevel(const LogString& sArg) con
Convert the string passed as argument to a level. If the st
conversion fails, then this method returns the value of { return Level::toLevelLS(sArg); }
<code>defaultLevel</code>.
*/
static const LevelPtr& toLevel(const String& sArg,
const LevelPtr& defaultLevel);
enum virtual LevelPtr toLevel(int val) const
{ { return Level::toLevel(val); }
OFF_INT = INT_MAX, };
FATAL_INT = 50000,
ERROR_INT = 40000,
WARN_INT = 30000,
INFO_INT = 20000,
DEBUG_INT = 10000,
ALL_INT = INT_MIN
};
/** DECLARE_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(Level, LevelClass)
The <code>ALL</code> level designates all the levels BEGIN_LOG4CXX_CAST_MAP()
*/ LOG4CXX_CAST_ENTRY(Level)
static const LevelPtr ALL; END_LOG4CXX_CAST_MAP()
/** /**
The <code>FATAL</code> level designates very severe error Instantiate a Level object.
events that will presumably lead the application to abort. */
*/ Level(int level,
static const LevelPtr FATAL; const LogString& name,
int syslogEquivalent);
/** /**
The <code>ERROR</code> level designates error events that Convert the string passed as argument to a level. If the
might still allow the application to continue running. */ conversion fails, then this method returns DEBUG.
static const LevelPtr ERROR; * @param sArg level name.
*/
static LevelPtr toLevel(const std::string& sArg);
/**
Convert the string passed as argument to a level. If the
conversion fails, then this method returns the value of
<code>defaultLevel</code>.
* @param sArg level name.
* @param defaultLevel level to return if no match.
* @return
*/
static LevelPtr toLevel(const std::string& sArg,
const LevelPtr& defaultLevel);
/**
* Get the name of the level in the current encoding.
* @param name buffer to which name is appended.
*/
void toString(std::string& name) const;
/** #if LOG4CXX_WCHAR_T_API
The <code>WARN</code> level designates potentially harmful s /**
ituations. Convert the string passed as argument to a level. If the
*/ conversion fails, then this method returns DEBUG.
static const LevelPtr WARN; * @param sArg level name.
*/
static LevelPtr toLevel(const std::wstring& sArg);
/**
Convert the string passed as argument to a level. If the
conversion fails, then this method returns the value of
<code>defaultLevel</code>.
* @param sArg level name.
* @param defaultLevel level to return if no match.
* @return
*/
static LevelPtr toLevel(const std::wstring& sArg,
const LevelPtr& defaultLevel);
/**
* Get the name of the level.
* @param name buffer to which name is appended.
*/
void toString(std::wstring& name) const;
#endif
#if LOG4CXX_UNICHAR_API
/**
Convert the string passed as argument to a level. If the
conversion fails, then this method returns DEBUG.
* @param sArg level name.
*/
static LevelPtr toLevel(const std::basic_string<UniChar>& s
Arg);
/**
Convert the string passed as argument to a level. If the
conversion fails, then this method returns the value of
<code>defaultLevel</code>.
* @param sArg level name.
* @param defaultLevel level to return if no match.
* @return
*/
static LevelPtr toLevel(const std::basic_string<UniChar>& s
Arg,
const LevelPtr& defaultLevel);
/**
* Get the name of the level.
* @param name buffer to which name is appended.
*/
void toString(std::basic_string<UniChar>& name) const;
#endif
#if LOG4CXX_CFSTRING_API
/**
Convert the string passed as argument to a level. If the
conversion fails, then this method returns DEBUG.
* @param sArg level name.
*/
static LevelPtr toLevel(const CFStringRef& sArg);
/**
Convert the string passed as argument to a level. If the
conversion fails, then this method returns the value of
<code>defaultLevel</code>.
* @param sArg level name.
* @param defaultLevel level to return if no match.
* @return
*/
static LevelPtr toLevel(const CFStringRef& sArg,
const LevelPtr& defaultLevel);
/**
* Get the name of the level.
* @param name buffer to which name is appended.
*/
void toString(CFStringRef& name) const;
#endif
/**
Convert the string passed as argument to a level. If the
conversion fails, then this method returns DEBUG.
* @param sArg level name.
*/
static LevelPtr toLevelLS(const LogString& sArg);
/**
Convert the string passed as argument to a level. If the
conversion fails, then this method returns the value of
<code>defaultLevel</code>.
* @param sArg level name.
* @param defaultLevel level to return if no match.
* @return
*/
static LevelPtr toLevelLS(const LogString& sArg,
const LevelPtr& defaultLevel);
/**
Returns the string representation of this level.
* @return level name.
*/
LogString toString() const;
/** /**
The <code>INFO</code> level designates informational message Convert an integer passed as argument to a level. If the
s conversion fails, then this method returns DEBUG.
that highlight the progress of the application at coarse-gra */
ined static LevelPtr toLevel(int val);
level. */
static const LevelPtr INFO;
/** /**
The <code>DEBUG</code> level designates fine-grained Convert an integer passed as argument to a level. If the
informational events that are most useful to debug an conversion fails, then this method returns the specified de
application. */ fault.
static const LevelPtr DEBUG; */
static LevelPtr toLevel(int val, const LevelPtr& defaultLev
el);
/** enum {
The <code>OFF</code> level designates not set level OFF_INT = INT_MAX,
*/ FATAL_INT = 50000,
static const LevelPtr OFF; ERROR_INT = 40000,
WARN_INT = 30000,
INFO_INT = 20000,
DEBUG_INT = 10000,
TRACE_INT = 5000,
ALL_INT = INT_MIN
};
/** static LevelPtr getAll();
Two levels are equal if their level fields are equal. static LevelPtr getFatal();
*/ static LevelPtr getError();
virtual bool equals(const LevelPtr& level) const; static LevelPtr getWarn();
static LevelPtr getInfo();
static LevelPtr getDebug();
static LevelPtr getTrace();
static LevelPtr getOff();
inline bool operator==(const Level& level) const /**
{ return (this->level == level.level); } Two levels are equal if their level fields are equal.
*/
virtual bool equals(const LevelPtr& level) const;
inline bool operator!=(const Level& level) const inline bool operator==(const Level& level1) const
{ return (this->level != level.level); } { return (this->level == level1.level); }
/** inline bool operator!=(const Level& level1) const
Return the syslog equivalent of this level as an integer. { return (this->level != level1.level); }
*/
virtual int getSyslogEquivalent() const;
/** /**
Returns <code>true</code> if this level has a higher or equa Return the syslog equivalent of this level as an integer.
l */
level than the level passed as argument, <code>false</code> inline int getSyslogEquivalent() const {
otherwise. return syslogEquivalent;
}
<p>You should think twice before overriding the default /**
implementation of <code>isGreaterOrEqual</code> method. Returns <code>true</code> if this level has a higher or equ
al
level than the level passed as argument, <code>false</code>
otherwise.
*/ <p>You should think twice before overriding the default
virtual bool isGreaterOrEqual(const LevelPtr& level) const; implementation of <code>isGreaterOrEqual</code> method.
/** */
Returns the string representation of this priority. virtual bool isGreaterOrEqual(const LevelPtr& level) const;
*/
virtual const String& toString() const;
/** /**
Returns the integer representation of this level. Returns the integer representation of this level.
*/ */
virtual int toInt() const; inline int toInt() const {
return level;
}
public: private:
int level; int level;
String levelStr; LogString name;
int syslogEquivalent; int syslogEquivalent;
}; Level(const Level&);
Level& operator=(const Level&);
};
} }
#define DECLARE_LOG4CXX_LEVEL(level)\ #define DECLARE_LOG4CXX_LEVEL(level)\
public:\ public:\
class Class##level : public Level::LevelClass\ class Class##level : public Level::LevelClass\
{\ {\
public:\ public:\
Class##level() : Level::LevelClass(_T(#level)) {}\ Class##level() : Level::LevelClass() {}\
virtual const LevelPtr& toLevel(const String& sArg) const\ virtual LogString getName() const { return LOG4CXX_STR(#level); } \
{ return level::toLevel(sArg); }\ virtual LevelPtr toLevel(const LogString& sArg) const\
virtual const LevelPtr& toLevel(int val) const\ { return level::toLevelLS(sArg); }\
{ return level::toLevel(val); }\ virtual LevelPtr toLevel(int val) const\
{ return level::toLevel(val); }\
};\ };\
DECLARE_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(level, Class##level) DECLARE_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(level, Class##level)
#define IMPLEMENT_LOG4CXX_LEVEL(level) \ #define IMPLEMENT_LOG4CXX_LEVEL(level) \
IMPLEMENT_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(level, Class##level) IMPLEMENT_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(level, Class##level)
#endif //_LOG4CXX_LEVEL_H #endif //_LOG4CXX_LEVEL_H
 End of changes. 27 change blocks. 
173 lines changed or deleted 233 lines changed or added


 levelmatchfilter.h   levelmatchfilter.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_LEVEL_MATCH_FILTER_H #ifndef _LOG4CXX_FILTER_LEVEL_MATCH_FILTER_H
#define _LOG4CXX_VARIA_LEVEL_MATCH_FILTER_H #define _LOG4CXX_FILTER_LEVEL_MATCH_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>
#include <log4cxx/level.h> #include <log4cxx/level.h>
namespace log4cxx namespace log4cxx
{ {
class Level; class Level;
namespace varia namespace filter
{ {
/** /**
This is a very simple filter based on level matching. This is a very simple filter based on level matching.
<p>The filter admits two options <b>LevelToMatch</b> and <p>The filter admits two options <b>LevelToMatch</b> and
<b>AcceptOnMatch</b>. If there is an exact match between the <b>AcceptOnMatch</b>. If there is an exact match between th
value e value
of the <b>LevelToMatch</b> option and the level of the {@lin of the <b>LevelToMatch</b> option and the level of the {@li
k nk
spi::LoggingEvent LoggingEvent}, then the #decide method ret spi::LoggingEvent LoggingEvent}, then the #decide method re
urns {@link turns {@link
spi::Filter#ACCEPT ACCEPT} in case the <b>AcceptOnMatch</b> spi::Filter#ACCEPT ACCEPT} in case the <b>AcceptOnMatch</b>
option value is set to <code>true</code>, if it is <code>fal option value is set to <code>true</code>, if it is <code>fa
se</code> lse</code>
then {@link spi::Filter#DENY DENY} is returned. If there is then {@link spi::Filter#DENY DENY} is returned. If there is
no match, no match,
{@link spi::Filter#NEUTRAL NEUTRAL} is returned. {@link spi::Filter#NEUTRAL NEUTRAL} is returned.
*/ */
class LevelMatchFilter;
typedef helpers::ObjectPtrT<LevelMatchFilter> LevelMatchFilt
erPtr;
class LOG4CXX_EXPORT LevelMatchFilter : public spi::Filter class LOG4CXX_EXPORT LevelMatchFilter : public spi::Filter
{ {
private: private:
static String LEVEL_TO_MATCH_OPTION; bool acceptOnMatch;
static String ACCEPT_ON_MATCH_OPTION; LevelPtr levelToMatch;
bool acceptOnMatch; public:
LevelPtr levelToMatch; typedef spi::Filter BASE_CLASS;
DECLARE_LOG4CXX_OBJECT(LevelMatchFilter)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(LevelMatchFilter)
LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
END_LOG4CXX_CAST_MAP()
public: LevelMatchFilter();
typedef spi::Filter BASE_CLASS;
DECLARE_LOG4CXX_OBJECT(LevelMatchFilter)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(LevelMatchFilter)
LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
END_LOG4CXX_CAST_MAP()
LevelMatchFilter(); /**
Set options
*/
virtual void setOption(const LogString& option,
const LogString& value);
/** void setLevelToMatch(const LogString& levelToMatch)
Set options ;
*/
virtual void setOption(const String& option,
const String& value);
void setLevelToMatch(const String& levelToMatch); LogString getLevelToMatch() const;
const String& getLevelToMatch() const; inline void setAcceptOnMatch(bool acceptOnMatch1)
{ this->acceptOnMatch = acceptOnMatch1; }
inline void setAcceptOnMatch(bool acceptOnMatch) inline bool getAcceptOnMatch() const
{ this->acceptOnMatch = acceptOnMatch; } { return acceptOnMatch; }
inline bool getAcceptOnMatch() const /**
{ return acceptOnMatch; } Return the decision of this filter.
/** Returns {@link spi::Filter#NEUTRAL NEUTRAL} if the
Return the decision of this filter. <b>LevelToMatch</b> option is not set or if there i
s not match.
Otherwise, if there is a match, then the returned d
ecision is
{@link spi::Filter#ACCEPT ACCEPT} if the <b>AcceptO
nMatch</b>
property is set to <code>true</code>. The returned
decision is
{@link spi::Filter#DENY DENY} if the
<b>AcceptOnMatch</b> property is set to false.
*/
FilterDecision decide(const spi::LoggingEventPtr& e
vent) const;
}; // class LevelMatchFilter
LOG4CXX_PTR_DEF(LevelMatchFilter);
} // namespace filter
} // namespace log4cxx
Returns {@link spi::Filter#NEUTRAL NEUTRAL} if the #if defined(_MSC_VER)
<b>LevelToMatch</b> option is not set or if there is #pragma warning ( pop )
not match. #endif
Otherwise, if there is a match, then the returned de
cision is
{@link spi::Filter#ACCEPT ACCEPT} if the <b>AcceptOn
Match</b>
property is set to <code>true</code>. The returned d
ecision is
{@link spi::Filter#DENY DENY} if the
<b>AcceptOnMatch</b> property is set to false.
*/
FilterDecision decide(const spi::LoggingEventPtr& ev
ent) const;
}; // class LevelMatchFilter
} // namespace varia
}; // namespace log4cxx
#endif // _LOG4CXX_VARIA_STRING_MATCH_FILTER_H #endif // _LOG4CXX_FILTER_STRING_MATCH_FILTER_H
 End of changes. 17 change blocks. 
74 lines changed or deleted 80 lines changed or added


 levelrangefilter.h   levelrangefilter.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_LEVEL_RANGE_FILTER_H #ifndef _LOG4CXX_FILTER_LEVEL_RANGE_FILTER_H
#define _LOG4CXX_VARIA_LEVEL_RANGE_FILTER_H #define _LOG4CXX_FILTER_LEVEL_RANGE_FILTER_H
#include <log4cxx/spi/filter.h> #include <log4cxx/spi/filter.h>
#include <log4cxx/level.h> #include <log4cxx/level.h>
namespace log4cxx namespace log4cxx
{ {
namespace varia namespace filter
{ {
/** /**
This is a very simple filter based on level matching, which This is a very simple filter based on level matching, which
can be can be
used to reject messages with priorities outside a certain ra used to reject messages with priorities outside a certain r
nge. ange.
<p>The filter admits three options <b>LevelMin</b>, <b>Level
Max</b>
and <b>AcceptOnMatch</b>.
<p>If the level of the {@link spi::LoggingEvent LoggingEvent <p>The filter admits three options <b>LevelMin</b>, <b>Leve
} is not lMax</b>
between Min and Max (inclusive), then {@link spi::Filter#DEN and <b>AcceptOnMatch</b>.
Y DENY}
is returned.
<p> If the Logging event level is within the specified range <p>If the level of the {@link spi::LoggingEvent LoggingEven
, then if t} is not
<b>AcceptOnMatch</b> is true, {@link spi::Filter#ACCEPT ACCE between Min and Max (inclusive), then {@link spi::Filter#DE
PT} is NY DENY}
returned, and if <b>AcceptOnMatch</b> is false, is returned.
{@link spi::Filter#NEUTRAL NEUTRAL} is returned.
<p>If <code>LevelMin</code>w is not defined, then there is n <p> If the Logging event level is within the specified rang
o e, then if
minimum acceptable level (ie a level is never rejected for <b>AcceptOnMatch</b> is true, {@link spi::Filter#ACCEPT ACC
being too "low"/unimportant). If <code>LevelMax</code> is n EPT} is
ot returned, and if <b>AcceptOnMatch</b> is false,
defined, then there is no maximum acceptable level (ie a {@link spi::Filter#NEUTRAL NEUTRAL} is returned.
level is never rejected for beeing too "high"/important).
<p>Refer to the {@link <p>If <code>LevelMin</code>w is not defined, then there is
AppenderSkeleton#setThreshold setThreshold} method no
available to <code>all</code> appenders extending minimum acceptable level (ie a level is never rejected for
AppenderSkeleton for a more convenient way to being too "low"/unimportant). If <code>LevelMax</code> is
filter out events by level. not
*/ defined, then there is no maximum acceptable level (ie a
class LevelRangeFilter; level is never rejected for beeing too "high"/important).
typedef helpers::ObjectPtrT<LevelRangeFilter> LevelRangeFilt
erPtr;
class LOG4CXX_EXPORT LevelRangeFilter : public spi::Filter <p>Refer to the {@link
{ AppenderSkeleton#setThreshold setThreshold} method
private: available to <code>all</code> appenders extending
static String LEVEL_MIN_OPTION; AppenderSkeleton for a more convenient way to
static String LEVEL_MAX_OPTION; filter out events by level.
static String ACCEPT_ON_MATCH_OPTION; */
/** class LOG4CXX_EXPORT LevelRangeFilter : public spi::Filter
Do we return ACCEPT when a match occurs. Default is {
<code>false</code>, so that later filters get run by private:
default /**
*/ Do we return ACCEPT when a match occurs. Default is
bool acceptOnMatch; <code>false</code>, so that later filters get run b
LevelPtr levelMin; y default
LevelPtr levelMax; */
bool acceptOnMatch;
LevelPtr levelMin;
LevelPtr levelMax;
public: public:
typedef spi::Filter BASE_CLASS; typedef spi::Filter BASE_CLASS;
DECLARE_LOG4CXX_OBJECT(LevelRangeFilter) DECLARE_LOG4CXX_OBJECT(LevelRangeFilter)
BEGIN_LOG4CXX_CAST_MAP() BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(LevelRangeFilter) LOG4CXX_CAST_ENTRY(LevelRangeFilter)
LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS) LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
END_LOG4CXX_CAST_MAP() END_LOG4CXX_CAST_MAP()
LevelRangeFilter(); LevelRangeFilter();
/** /**
Set options Set options
*/ */
virtual void setOption(const String& option, virtual void setOption(const LogString& option,
const String& value); const LogString& value);
/** /**
Set the <code>LevelMin</code> option. Set the <code>LevelMin</code> option.
*/ */
void setLevelMin(const LevelPtr& levelMin) void setLevelMin(const LevelPtr& levelMin1)
{ this->levelMin = levelMin; } { this->levelMin = levelMin1; }
/** /**
Get the value of the <code>LevelMin</code> option. Get the value of the <code>LevelMin</code> option.
*/ */
const LevelPtr& getLevelMin() const const LevelPtr& getLevelMin() const
{ return levelMin; } { return levelMin; }
/** /**
Set the <code>LevelMax</code> option. Set the <code>LevelMax</code> option.
*/ */
void setLevelMax(const LevelPtr& levelMax) void setLevelMax(const LevelPtr& levelMax1)
{ this->levelMax = levelMax; } { this->levelMax = levelMax1; }
/** /**
Get the value of the <code>LevelMax</code> option. Get the value of the <code>LevelMax</code> option.
*/ */
const LevelPtr& getLevelMax() const const LevelPtr& getLevelMax() const
{ return levelMax; } { return levelMax; }
/** /**
Set the <code>AcceptOnMatch</code> option. Set the <code>AcceptOnMatch</code> option.
*/ */
inline void setAcceptOnMatch(bool acceptOnMatch) inline void setAcceptOnMatch(bool acceptOnMatch1)
{ this->acceptOnMatch = acceptOnMatch; } { this->acceptOnMatch = acceptOnMatch1; }
/** /**
Get the value of the <code>AcceptOnMatch</code> opti Get the value of the <code>AcceptOnMatch</code> opt
on. ion.
*/ */
inline bool getAcceptOnMatch() const inline bool getAcceptOnMatch() const
{ return acceptOnMatch; } { return acceptOnMatch; }
/** /**
Return the decision of this filter. Return the decision of this filter.
Returns {@link spi::Filter#NEUTRAL NEUTRAL} if the Returns {@link spi::Filter#NEUTRAL NEUTRAL} if the
<b>LevelToMatch</b> option is not set or if there is <b>LevelToMatch</b> option is not set or if there i
not match. s not match.
Otherwise, if there is a match, then the returned de Otherwise, if there is a match, then the returned d
cision is ecision is
{@link spi::Filter#ACCEPT ACCEPT} if the {@link spi::Filter#ACCEPT ACCEPT} if the
<b>AcceptOnMatch</b> property is set to <code>true</ <b>AcceptOnMatch</b> property is set to <code>true<
code>. The /code>. The
returned decision is {@link spi::Filter#DENY DENY} i returned decision is {@link spi::Filter#DENY DENY}
f the if the
<b>AcceptOnMatch</b> property is set to false. <b>AcceptOnMatch</b> property is set to false.
*/ */
FilterDecision decide(const spi::LoggingEventPtr& ev FilterDecision decide(const spi::LoggingEventPtr& e
ent) const; vent) const;
}; // class LevelMatchFilter }; // class LevelRangeFilter
} // namespace varia LOG4CXX_PTR_DEF(LevelRangeFilter);
}; // namespace log4cxx } // namespace filter
} // namespace log4cxx
#endif // _LOG4CXX_VARIA_LEVEL_RANGE_FILTER_H #endif // _LOG4CXX_FILTER_LEVEL_RANGE_FILTER_H
 End of changes. 21 change blocks. 
122 lines changed or deleted 117 lines changed or added


 loader.h   loader.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_LOADER_H #ifndef _LOG4CXX_HELPERS_LOADER_H
#define _LOG4CXX_HELPERS_LOADER_H #define _LOG4CXX_HELPERS_LOADER_H
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/tchar.h> #include <log4cxx/logstring.h>
#include <log4cxx/helpers/exception.h> #include <log4cxx/helpers/exception.h>
#include <log4cxx/helpers/inputstream.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class Class; class Class;
class LOG4CXX_EXPORT Loader class LOG4CXX_EXPORT Loader
{ {
public: public:
static const Class& loadClass(const String& clazz); static const Class& loadClass(const LogString& claz
static String getResource(const String& name); z);
static istream * getResourceAsStream(const String& n
ame); static InputStreamPtr getResourceAsStream(
}; const LogString& n
} // namespace helpers ame);
}; // namespace log4cxx };
} // namespace helpers
} // namespace log4cxx
#endif //_LOG4CXX_HELPERS_LOADER_H #endif //_LOG4CXX_HELPERS_LOADER_H
 End of changes. 5 change blocks. 
19 lines changed or deleted 23 lines changed or added


 locale.h   locale.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_LOCALE_H #ifndef _LOG4CXX_HELPERS_LOCALE_H
#define _LOG4CXX_HELPERS_LOCALE_H #define _LOG4CXX_HELPERS_LOCALE_H
#include <log4cxx/helpers/tchar.h> #include <log4cxx/logstring.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class LOG4CXX_EXPORT Locale class LOG4CXX_EXPORT Locale
{ {
public: public:
Locale(const String& language); Locale(const LogString& language);
Locale(const String& language, const String& country Locale(const LogString& language, const LogString&
); country);
Locale(const String& language, const String& country Locale(const LogString& language, const LogString&
, country,
const String& variant); const LogString& variant);
static const Locale& getDefault();
static void setDefault(const Locale& newLocale);
const String& getLanguage() const; const LogString& getLanguage() const;
const String& getCountry() const; const LogString& getCountry() const;
const String& getVariant() const; const LogString& getVariant() const;
protected: protected:
String language; Locale(const Locale&);
String country; Locale& operator=(const Locale&);
String variant; const LogString language;
}; // class Locale const LogString country;
} // namespace helpers const LogString variant;
}; // namespace log4cxx }; // class Locale
} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_LOCALE_H #endif // _LOG4CXX_HELPERS_LOCALE_H
 End of changes. 5 change blocks. 
30 lines changed or deleted 30 lines changed or added


 logger.h   logger.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_LOGGER_H #ifndef _LOG4CXX_LOGGER_H
#define _LOG4CXX_LOGGER_H #define _LOG4CXX_LOGGER_H
#include <log4cxx/config.h> #if defined(_MSC_VER)
#include <vector> #pragma warning ( push )
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/helpers/appenderattachableimpl.h> #include <log4cxx/helpers/appenderattachableimpl.h>
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/level.h> #include <log4cxx/level.h>
#include <log4cxx/spi/loggerfactory.h> #include <log4cxx/helpers/pool.h>
#include <log4cxx/spi/loggerrepository.h> #include <log4cxx/helpers/mutex.h>
#include <log4cxx/spi/location/locationinfo.h>
#include <log4cxx/helpers/resourcebundle.h> #include <log4cxx/helpers/resourcebundle.h>
#include <log4cxx/helpers/messagebuffer.h>
namespace log4cxx namespace log4cxx
{ {
namespace spi
{
class LoggerFactory;
typedef helpers::ObjectPtrT<LoggerFactory> LoggerFactoryPtr;
class LoggerRepository; namespace helpers {
typedef helpers::ObjectPtrT<LoggerRepository> LoggerReposito class synchronized;
ryPtr; }
}
class Logger; namespace spi {
/** smart pointer to a Logger class */ class LoggerRepository;
typedef helpers::ObjectPtrT<Logger> LoggerPtr; LOG4CXX_PTR_DEF(LoggerRepository);
class LoggerFactory;
LOG4CXX_PTR_DEF(LoggerFactory);
}
/** vector of {@link Logger loggers} */ class Logger;
typedef std::vector<LoggerPtr> LoggerList; /** smart pointer to a Logger class */
LOG4CXX_PTR_DEF(Logger);
LOG4CXX_LIST_DEF(LoggerList, LoggerPtr);
/** /**
This is the central class in the log4cxx package. Most logging This is the central class in the log4cxx package. Most logging
operations, except configuration, are done through this class. operations, except configuration, are done through this class.
*/ */
class LOG4CXX_EXPORT Logger : class LOG4CXX_EXPORT Logger :
public virtual spi::AppenderAttachable, public virtual log4cxx::spi::AppenderAttachable,
public virtual helpers::ObjectImpl public virtual helpers::ObjectImpl
{ {
public: public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Logger) DECLARE_ABSTRACT_LOG4CXX_OBJECT(Logger)
BEGIN_LOG4CXX_CAST_MAP() BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(Logger) LOG4CXX_CAST_ENTRY(Logger)
LOG4CXX_CAST_ENTRY(spi::AppenderAttachable) LOG4CXX_CAST_ENTRY(spi::AppenderAttachable)
END_LOG4CXX_CAST_MAP() END_LOG4CXX_CAST_MAP()
private:
/**
* Reference to memory pool.
*/
helpers::Pool* pool;
protected: protected:
/** /**
The name of this logger. The name of this logger.
*/ */
String name; LogString name;
/** /**
The assigned level of this logger. The The assigned level of this logger. The
<code>level</code> variable need not be assigned a value in <code>level</code> variable need not be assigned a value in
which case it is inherited form the hierarchy. */ which case it is inherited form the hierarchy. */
LevelPtr level; LevelPtr level;
/** /**
The parent of this logger. All loggers have at least one The parent of this logger. All loggers have at least one
ancestor which is the root logger. */ ancestor which is the root logger. */
LoggerPtr parent; LoggerPtr parent;
/** The resourceBundle for localized messages. /** The resourceBundle for localized messages.
@see setResourceBundle, getResourceBundle
*/
helpers::ResourceBundlePtr resourceBundle;
/** @see setResourceBundle, getResourceBundle
The fully qualified name of the Category class. See also the */
getFQCN helpers::ResourceBundlePtr resourceBundle;
method.
*/
static String FQCN;
// Loggers need to know what Hierarchy they are in // Loggers need to know what Hierarchy they are in
spi::LoggerRepository * repository; log4cxx::spi::LoggerRepository * repository;
helpers::AppenderAttachableImplPtr aai; helpers::AppenderAttachableImplPtr aai;
/** Additivity is set to true by default, that is children inherit /** Additivity is set to true by default, that is children
the appenders of their ancestors by default. If this variable is inherit
set to <code>false</code> then the appenders found in the the appenders of their ancestors by default. If thi
ancestors of this logger are not used. However, the children s variable is
of this logger will inherit its appenders, unless the children set to <code>false</code> then the appenders found
have their additivity flag set to <code>false</code> too. See in the
the user manual for more details. */ ancestors of this logger are not used. However, the
bool additive; children
of this logger will inherit its appenders, unless t
he children
have their additivity flag set to <code>false</code
> too. See
the user manual for more details. */
bool additive;
protected: protected:
friend class DefaultCategoryFactory; friend class DefaultLoggerFactory;
/** /**
This constructor created a new <code>logger</code> instance This constructor created a new <code>logger</code> instance and
and sets its name.
sets its name.
<p>It is intended to be used by sub-classes only. You should <p>It is intended to be used by sub-classes only. You should not
not create categories directly.
create categories directly.
@param name The name of the logger. @param pool lifetime of pool must be longer than logger.
*/ @param name The name of the logger.
Logger(const String& name); */
Logger(log4cxx::helpers::Pool& pool, const LogString& name);
public: public:
~Logger(); ~Logger();
void addRef() const;
void releaseRef() const;
/** /**
Add <code>newAppender</code> to the list of appenders of this Add <code>newAppender</code> to the list of appenders of this
Logger instance. Logger instance.
<p>If <code>newAppender</code> is already in the list of <p>If <code>newAppender</code> is already in the list of
appenders, then it won't be added again. appenders, then it won't be added again.
*/ */
virtual void addAppender(const AppenderPtr& newAppender); virtual void addAppender(const AppenderPtr& newAppender);
/**
If <code>assertion</code> parameter is <code>false</code>, then
logs <code>msg</code> as an #error statement.
@param assertion
@param msg The message to print if <code>assertion</code> is
false.
*/
void assertLog(bool assertion, const String& msg);
/** /**
Call the appenders in the hierrachy starting at Call the appenders in the hierrachy starting at
<code>this</code>. If no appenders could be found, emit a <code>this</code>. If no appenders could be found, emit a
warning. warning.
<p>This method calls all the appenders inherited from the <p>This method calls all the appenders inherited from the
hierarchy circumventing any evaluation of whether to log or not hierarchy circumventing any evaluation of whether to log or not
to log the particular log request. to log the particular log request.
@param event the event to log. */ @param event the event to log.
void callAppenders(const spi::LoggingEventPtr& event); @param p memory pool for any allocations needed to process request.
*/
void callAppenders(const log4cxx::spi::LoggingEventPtr& event, log4
cxx::helpers::Pool& p) const;
/** /**
Close all attached appenders implementing the AppenderAttachable Close all attached appenders implementing the AppenderAttachable
interface. interface.
*/ */
void closeNestedAppenders(); void closeNestedAppenders();
/** /**
Log a message string with the {@link Level#DEBUG DEBUG} level. Log a message string with the DEBUG level.
<p>This method first checks if this logger is <code>DEBUG</code> <p>This method first checks if this logger is <code>DEBUG</code>
enabled by comparing the level of this logger with the {@link enabled by comparing the level of this logger with the
Level#DEBUG DEBUG} level. If this logger is DEBUG level. If this logger is
<code>DEBUG</code> enabled, it proceeds to call all the <code>DEBUG</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag. hierarchy depending on the value of the additivity flag.
@param message the message string to log. @param msg the message string to log.
@param file the file where the log statement was written. @param location location of source of logging request.
@param line the line where the log statement was written. */
*/ void debug(const std::string& msg, const log4cxx::spi::LocationInfo
void debug(const String& message, const char* file=0, int line=-1); & location) const;
/**
Log a message string with the DEBUG level.
<p>This method first checks if this logger is <code>DEBUG</code>
enabled by comparing the level of this logger with the
DEBUG level. If this logger is
<code>DEBUG</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void debug(const std::string& msg) const;
#if LOG4CXX_WCHAR_T_API
/** /**
Log a message string with the {@link Level#ERROR ERROR} level. Log a message string with the DEBUG level.
<p>This method first checks if this logger is <code>DEBUG</code>
enabled by comparing the level of this logger with the
DEBUG level. If this logger is
<code>DEBUG</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void debug(const std::wstring& msg, const log4cxx::spi::LocationInf
o& location) const;
/**
Log a message string with the DEBUG level.
<p>This method first checks if this logger is <code>DEBUG</code>
enabled by comparing the level of this logger with the
DEBUG level. If this logger is
<code>DEBUG</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void debug(const std::wstring& msg) const;
#endif
#if LOG4CXX_UNICHAR_API
/**
Log a message string with the DEBUG level.
<p>This method first checks if this logger is <code>DEBUG</code>
enabled by comparing the level of this logger with the
DEBUG level. If this logger is
<code>DEBUG</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void debug(const std::basic_string<UniChar>& msg, const log4cxx::sp
i::LocationInfo& location) const;
/**
Log a message string with the DEBUG level.
<p>This method first checks if this logger is <code>DEBUG</code>
enabled by comparing the level of this logger with the
DEBUG level. If this logger is
<code>DEBUG</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void debug(const std::basic_string<UniChar>& msg) const;
#endif
#if LOG4CXX_CFSTRING_API
/**
Log a message string with the DEBUG level.
<p>This method first checks if this logger is <code>DEBUG</code>
enabled by comparing the level of this logger with the
DEBUG level. If this logger is
<code>DEBUG</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void debug(const CFStringRef& msg, const log4cxx::spi::LocationInfo
& location) const;
/**
Log a message string with the DEBUG level.
<p>This method first checks if this logger is <code>DEBUG</code>
enabled by comparing the level of this logger with the
DEBUG level. If this logger is
<code>DEBUG</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void debug(const CFStringRef& msg) const;
#endif
/**
Log a message string with the ERROR level.
<p>This method first checks if this logger is <code>ERROR</code> <p>This method first checks if this logger is <code>ERROR</code>
enabled by comparing the level of this logger with the {@link enabled by comparing the level of this logger with the
Level#ERROR ERROR} level. If this logger is ERROR level. If this logger is
<code>ERROR</code> enabled, it proceeds to call all the <code>ERROR</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag. hierarchy depending on the value of the additivity flag.
@param message the message string to log. @param msg the message string to log.
@param file the file where the log statement was written. @param location location of source of logging request.
@param line the line where the log statement was written. */
*/ void error(const std::string& msg, const log4cxx::spi::LocationInfo
void error(const String& message, const char* file=0, int line=-1); & location) const;
/**
Log a message string with the ERROR level.
<p>This method first checks if this logger is <code>ERROR</code>
enabled by comparing the level of this logger with the
ERROR level. If this logger is
<code>ERROR</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void error(const std::string& msg) const;
#if LOG4CXX_WCHAR_T_API
/** /**
Log a message string with the {@link Level#FATAL FATAL} level. Log a message string with the ERROR level.
<p>This method first checks if this logger is <code>ERROR</code>
enabled by comparing the level of this logger with the
ERROR level. If this logger is
<code>ERROR</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void error(const std::wstring& msg) const;
/**
Log a message string with the ERROR level.
<p>This method first checks if this logger is <code>ERROR</code>
enabled by comparing the level of this logger with the
ERROR level. If this logger is
<code>ERROR</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void error(const std::wstring& msg, const log4cxx::spi::LocationInf
o& location) const;
#endif
#if LOG4CXX_UNICHAR_API
/**
Log a message string with the ERROR level.
<p>This method first checks if this logger is <code>ERROR</code>
enabled by comparing the level of this logger with the
ERROR level. If this logger is
<code>ERROR</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void error(const std::basic_string<UniChar>& msg, const log4cxx::sp
i::LocationInfo& location) const;
/**
Log a message string with the ERROR level.
<p>This method first checks if this logger is <code>ERROR</code>
enabled by comparing the level of this logger with the
ERROR level. If this logger is
<code>ERROR</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void error(const std::basic_string<UniChar>& msg) const;
#endif
#if LOG4CXX_CFSTRING_API
/**
Log a message string with the ERROR level.
<p>This method first checks if this logger is <code>ERROR</code>
enabled by comparing the level of this logger with the
ERROR level. If this logger is
<code>ERROR</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void error(const CFStringRef& msg, const log4cxx::spi::LocationInfo
& location) const;
/**
Log a message string with the ERROR level.
<p>This method first checks if this logger is <code>ERROR</code>
enabled by comparing the level of this logger with the
ERROR level. If this logger is
<code>ERROR</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void error(const CFStringRef& msg) const;
#endif
/**
Log a message string with the FATAL level.
<p>This method first checks if this logger is <code>FATAL</code> <p>This method first checks if this logger is <code>FATAL</code>
enabled by comparing the level of this logger with the {@link enabled by comparing the level of this logger with the
Level#FATAL FATAL} level. If this logger is FATAL level. If this logger is
<code>FATAL</code> enabled, it proceeds to call all the <code>FATAL</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag. hierarchy depending on the value of the additivity flag.
@param message the message string to log. @param msg the message string to log.
@param file the file where the log statement was written. @param location location of source of logging request.
@param line the line where the log statement was written. */
*/ void fatal(const std::string& msg, const log4cxx::spi::LocationInfo
void fatal(const String& message, const char* file=0, int line=-1); & location) const;
/**
Log a message string with the ERROR level.
<p>This method first checks if this logger is <code>ERROR</code>
enabled by comparing the level of this logger with the
ERROR level. If this logger is
<code>ERROR</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void fatal(const std::string& msg) const;
#if LOG4CXX_WCHAR_T_API
/**
Log a message string with the ERROR level.
<p>This method first checks if this logger is <code>ERROR</code>
enabled by comparing the level of this logger with the
ERROR level. If this logger is
<code>ERROR</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void fatal(const std::wstring& msg, const log4cxx::spi::LocationInf
o& location) const;
/**
Log a message string with the ERROR level.
<p>This method first checks if this logger is <code>ERROR</code>
enabled by comparing the level of this logger with the
ERROR level. If this logger is
<code>ERROR</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void fatal(const std::wstring& msg) const;
#endif
#if LOG4CXX_UNICHAR_API
/**
Log a message string with the ERROR level.
<p>This method first checks if this logger is <code>ERROR</code>
enabled by comparing the level of this logger with the
ERROR level. If this logger is
<code>ERROR</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void fatal(const std::basic_string<UniChar>& msg, const log4cxx::sp
i::LocationInfo& location) const;
/**
Log a message string with the ERROR level.
<p>This method first checks if this logger is <code>ERROR</code>
enabled by comparing the level of this logger with the
ERROR level. If this logger is
<code>ERROR</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void fatal(const std::basic_string<UniChar>& msg) const;
#endif
#if LOG4CXX_CFSTRING_API
/**
Log a message string with the ERROR level.
<p>This method first checks if this logger is <code>ERROR</code>
enabled by comparing the level of this logger with the
ERROR level. If this logger is
<code>ERROR</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void fatal(const CFStringRef& msg, const log4cxx::spi::LocationInfo
& location) const;
/**
Log a message string with the ERROR level.
<p>This method first checks if this logger is <code>ERROR</code>
enabled by comparing the level of this logger with the
ERROR level. If this logger is
<code>ERROR</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void fatal(const CFStringRef& msg) const;
#endif
/** /**
This method creates a new logging event and logs the event This method creates a new logging event and logs the event
without further checks. without further checks.
@param level the level to log. @param level the level to log.
@param message the message string to log. @param message message.
@param file the file where the log statement was written. @param location location of source of logging request.
@param line the line where the log statement was written. */
*/ void forcedLog(const LevelPtr& level, const std::string& message,
void forcedLog(const LevelPtr& level, const String& message, const log4cxx::spi::LocationInfo& location) const;
const char* file=0, int line=-1); /**
This method creates a new logging event and logs the event
without further checks.
@param level the level to log.
@param message message.
*/
void forcedLog(const LevelPtr& level, const std::string& message) c
onst;
/** #if LOG4CXX_WCHAR_T_API
/**
This method creates a new logging event and logs the event
without further checks.
@param level the level to log.
@param message message.
@param location location of source of logging request.
*/
void forcedLog(const LevelPtr& level, const std::wstring& message,
const log4cxx::spi::LocationInfo& location) const;
/**
This method creates a new logging event and logs the event
without further checks.
@param level the level to log.
@param message message.
*/
void forcedLog(const LevelPtr& level, const std::wstring& message)
const;
#endif
#if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
/**
This method creates a new logging event and logs the event
without further checks.
@param level the level to log.
@param message message.
@param location location of source of logging request.
*/
void forcedLog(const LevelPtr& level, const std::basic_string<UniCh
ar>& message,
const log4cxx::spi::LocationInfo& location) const;
/**
This method creates a new logging event and logs the event
without further checks.
@param level the level to log.
@param message message.
*/
void forcedLog(const LevelPtr& level, const std::basic_string<UniCh
ar>& message) const;
#endif
#if LOG4CXX_CFSTRING_API
/**
This method creates a new logging event and logs the event
without further checks.
@param level the level to log.
@param message message.
@param location location of source of logging request.
*/
void forcedLog(const LevelPtr& level, const CFStringRef& message,
const log4cxx::spi::LocationInfo& location) const;
/**
This method creates a new logging event and logs the event
without further checks.
@param level the level to log.
@param message message.
*/
void forcedLog(const LevelPtr& level, const CFStringRef& message) c
onst;
#endif
/**
This method creates a new logging event and logs the event This method creates a new logging event and logs the event
without further checks. without further checks.
@param fqcn The fully qualified name of the calling logger c lass.
@param level the level to log. @param level the level to log.
@param message the message string to log. @param message the message string to log.
@param file the file where the log statement was written. @param location location of the logging statement.
@param line the line where the log statement was written. */
*/ void forcedLogLS(const LevelPtr& level, const LogString& message,
protected: const log4cxx::spi::LocationInfo& location) const;
void forcedLog(const String& fqcn, const LevelPtr& level, const Str
ing& message,
const char* file=0, int line=-1);
/** /**
Get the additivity flag for this Logger instance. Get the additivity flag for this Logger instance.
*/ */
public:
bool getAdditivity() const; bool getAdditivity() const;
/** /**
Get the appenders contained in this logger as an AppenderLis Get the appenders contained in this logger as an AppenderList.
t. If no appenders can be found, then an empty AppenderList
If no appenders can be found, then an empty AppenderList is returned.
is returned. @return AppenderList An collection of the appenders in this logger.
@return AppenderList An collection of the appenders in this */
logger.*/ AppenderList getAllAppenders() const;
AppenderList getAllAppenders() const;
/** /**
Look for the appender named as <code>name</code>. Look for the appender named as <code>name</code>.
<p>Return the appender with that name if in the list. Return <p>Return the appender with that name if in the list. Return
<code>NULL</code> otherwise. */ <code>NULL</code> otherwise. */
AppenderPtr getAppender(const String& name) const; AppenderPtr getAppender(const LogString& name) const;
/** /**
Starting from this logger, search the logger hierarchy for a Starting from this logger, search the logger hierarchy for a
non-null level and return it. non-null level and return it.
<p>The Logger class is designed so that this method executes as <p>The Logger class is designed so that this method executes as
quickly as possible. quickly as possible.
@throws RuntimeException if all levels are null in the hiera rchy @throws RuntimeException if all levels are null in the hierarchy
*/ */
virtual const LevelPtr& getEffectiveLevel() const; virtual const LevelPtr& getEffectiveLevel() const;
/** /**
Return the the LoggerRepository where this Return the the LoggerRepository where this
<code>Logger</code> is attached. <code>Logger</code> is attached.
*/ */
spi::LoggerRepositoryPtr getLoggerRepository() const; log4cxx::spi::LoggerRepositoryPtr getLoggerRepository() const;
/** /**
Return the logger name. */ * Get the logger name.
inline const String& getName() const * @return logger name as LogString.
{ return name; } */
const LogString getName() const { return name; }
/**
* Get logger name in current encoding.
* @param name buffer to which name is appended.
*/
void getName(std::string& name) const;
#if LOG4CXX_WCHAR_T_API
/**
* Get logger name.
* @param name buffer to which name is appended.
*/
void getName(std::wstring& name) const;
#endif
#if LOG4CXX_UNICHAR_API
/**
* Get logger name.
* @param name buffer to which name is appended.
*/
void getName(std::basic_string<UniChar>& name) const;
#endif
#if LOG4CXX_CFSTRING_API
/**
* Get logger name.
* @param name buffer to which name is appended.
*/
void getName(CFStringRef& name) const;
#endif
/** /**
Returns the parent of this logger. Note that the parent of a Returns the parent of this logger. Note that the parent of a
given logger may change during the lifetime of the logger. given logger may change during the lifetime of the logger.
<p>The root logger will return <code>0</code>. <p>The root logger will return <code>0</code>.
*/ */
const LoggerPtr& getParent() const; LoggerPtr getParent() const;
/** /**
Returns the assigned Level, if any, for this Logger. Returns the assigned Level, if any, for this Logger.
@return Level - the assigned Level, can be null. @return Level - the assigned Level, can be null.
*/ */
const LevelPtr& getLevel() const; LevelPtr getLevel() const;
/** /**
Retrieve a logger by name. * Retrieve a logger by name in current encoding.
* @param name logger name.
*/ */
static LoggerPtr getLogger(const String& name); static LoggerPtr getLogger(const std::string& name);
/**
* Retrieve a logger by name in current encoding.
* @param name logger name.
*/
static LoggerPtr getLogger(const char* const name);
#if LOG4CXX_WCHAR_T_API
/**
* Retrieve a logger by name.
* @param name logger name.
*/
static LoggerPtr getLogger(const std::wstring& name);
/**
* Retrieve a logger by name.
* @param name logger name.
*/
static LoggerPtr getLogger(const wchar_t* const name);
#endif
#if LOG4CXX_UNICHAR_API
/**
* Retrieve a logger by name.
* @param name logger name.
*/
static LoggerPtr getLogger(const std::basic_string<UniChar>& name);
#endif
#if LOG4CXX_CFSTRING_API
/**
* Retrieve a logger by name.
* @param name logger name.
*/
static LoggerPtr getLogger(const CFStringRef& name);
#endif
/**
* Retrieve a logger by name in Unicode.
* @param name logger name.
*/
static LoggerPtr getLoggerLS(const LogString& name);
/** /**
Retrieve the root logger. Retrieve the root logger.
*/ */
static LoggerPtr getRootLogger(); static LoggerPtr getRootLogger();
/** /**
Like #getLogger except that the type of logger Like #getLogger except that the type of logger
instantiated depends on the type returned by the instantiated depends on the type returned by the
LoggerFactory#makeNewLoggerInstance method of the LoggerFactory#makeNewLoggerInstance method of the
<code>factory</code> parameter. <code>factory</code> parameter.
<p>This method is intended to be used by sub-classes. <p>This method is intended to be used by sub-classes.
@param name The name of the logger to retrieve. @param name The name of the logger to retrieve.
@param factory A LoggerFactory implementation that will @param factory A LoggerFactory implementation that will
actually create a new Instance. actually create a new Instance.
*/ */
static LoggerPtr getLogger(const String& name, static LoggerPtr getLoggerLS(const LogString& name,
spi::LoggerFactoryPtr factory); const log4cxx::spi::LoggerFactoryPtr& factory);
/**
Like #getLogger except that the type of logger
instantiated depends on the type returned by the
LoggerFactory#makeNewLoggerInstance method of the
<code>factory</code> parameter.
/** <p>This method is intended to be used by sub-classes.
Return the <em>inherited</em> ResourceBundle for this logger
.
This method walks the hierarchy to find the appropriate reso @param name The name of the logger to retrieve.
urce bundle.
It will return the resource bundle attached to the closest a
ncestor of
this logger, much like the way priorities are searched. In c
ase there
is no bundle in the hierarchy then <code>NULL</code> is retu
rned.
*/
helpers::ResourceBundlePtr getResourceBundle() const;
protected: @param factory A LoggerFactory implementation that will
/** actually create a new Instance.
Returns the string resource coresponding to <code>key</code> */
in this static LoggerPtr getLogger(const std::string& name,
category's inherited resource bundle. const log4cxx::spi::LoggerFactoryPtr& factory);
#if LOG4CXX_WCHAR_T_API
/**
Like #getLogger except that the type of logger
instantiated depends on the type returned by the
LoggerFactory#makeNewLoggerInstance method of the
<code>factory</code> parameter.
If the resource cannot be found, then an {@link #error error <p>This method is intended to be used by sub-classes.
} message
will be logged complaining about the missing resource.
@see #getResourceBundle. @param name The name of the logger to retrieve.
*/
String getResourceBundleString(const String& key) const;
public: @param factory A LoggerFactory implementation that will
/** actually create a new Instance.
Log a message string with the {@link Level#INFO INFO} level. */
static LoggerPtr getLogger(const std::wstring& name,
const log4cxx::spi::LoggerFactoryPtr& factory);
#endif
#if LOG4CXX_UNICHAR_API
/**
Like #getLogger except that the type of logger
instantiated depends on the type returned by the
LoggerFactory#makeNewLoggerInstance method of the
<code>factory</code> parameter.
<p>This method is intended to be used by sub-classes.
@param name The name of the logger to retrieve.
@param factory A LoggerFactory implementation that will
actually create a new Instance.
*/
static LoggerPtr getLogger(const std::basic_string<UniChar>& name,
const log4cxx::spi::LoggerFactoryPtr& factory);
#endif
#if LOG4CXX_CFSTRING_API
/**
Like #getLogger except that the type of logger
instantiated depends on the type returned by the
LoggerFactory#makeNewLoggerInstance method of the
<code>factory</code> parameter.
<p>This method is intended to be used by sub-classes.
@param name The name of the logger to retrieve.
@param factory A LoggerFactory implementation that will
actually create a new Instance.
*/
static LoggerPtr getLogger(const CFStringRef& name,
const log4cxx::spi::LoggerFactoryPtr& factory);
#endif
/**
Return the <em>inherited</em> ResourceBundle for this logger.
This method walks the hierarchy to find the appropriate resource bu
ndle.
It will return the resource bundle attached to the closest ancestor
of
this logger, much like the way priorities are searched. In case the
re
is no bundle in the hierarchy then <code>NULL</code> is returned.
*/
helpers::ResourceBundlePtr getResourceBundle() const;
protected:
/**
Returns the string resource coresponding to <code>key</code> in thi
s
logger's inherited resource bundle.
If the resource cannot be found, then an {@link #error error} messa
ge
will be logged complaining about the missing resource.
@see #getResourceBundle.
*/
LogString getResourceBundleString(const LogString& key) const;
public:
/**
Log a message string with the INFO level.
<p>This method first checks if this logger is <code>INFO</code> <p>This method first checks if this logger is <code>INFO</code>
enabled by comparing the level of this logger with the {@link enabled by comparing the level of this logger with the
Level#INFO INFO} level. If this logger is INFO level. If this logger is
<code>INFO</code> enabled, it proceeds to call all the <code>INFO</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag. hierarchy depending on the value of the additivity flag.
@param message the message string to log. @param msg the message string to log.
@param file the file where the log statement was written. @param location location of source of logging request.
@param line the line where the log statement was written. */
*/ void info(const std::string& msg, const log4cxx::spi::LocationInfo&
void info(const String& message, const char* file=NULL, int line=-1 location) const;
); void info(const std::string& msg) const;
#if LOG4CXX_WCHAR_T_API
/**
Log a message string with the INFO level.
/** <p>This method first checks if this logger is <code>INFO</code>
Is the appender passed as parameter attached to this categor enabled by comparing the level of this logger with the
y? INFO level. If this logger is
*/ <code>INFO</code> enabled, it proceeds to call all the
bool isAttached(const AppenderPtr& appender) const; registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void info(const std::wstring& msg, const log4cxx::spi::LocationInfo&
location) const;
/**
Log a message string with the INFO level.
<p>This method first checks if this logger is <code>INFO</code>
enabled by comparing the level of this logger with the
INFO level. If this logger is
<code>INFO</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void info(const std::wstring& msg) const;
#endif
#if LOG4CXX_UNICHAR_API
/**
Log a message string with the INFO level.
<p>This method first checks if this logger is <code>INFO</code>
enabled by comparing the level of this logger with the
INFO level. If this logger is
<code>INFO</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void info(const std::basic_string<UniChar>& msg, const log4cxx::spi
::LocationInfo& location) const;
/**
Log a message string with the INFO level.
<p>This method first checks if this logger is <code>INFO</code>
enabled by comparing the level of this logger with the
INFO level. If this logger is
<code>INFO</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void info(const std::basic_string<UniChar>& msg) const;
#endif
#if LOG4CXX_CFSTRING_API
/**
Log a message string with the INFO level.
<p>This method first checks if this logger is <code>INFO</code>
enabled by comparing the level of this logger with the
INFO level. If this logger is
<code>INFO</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void info(const CFStringRef& msg, const log4cxx::spi::LocationInfo&
location) const;
/**
Log a message string with the INFO level.
<p>This method first checks if this logger is <code>INFO</code>
enabled by comparing the level of this logger with the
INFO level. If this logger is
<code>INFO</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void info(const CFStringRef& msg) const;
#endif
/**
Is the appender passed as parameter attached to this logger?
*/
bool isAttached(const AppenderPtr& appender) const;
/** /**
* Check whether this logger is enabled for the <code>DEBUG</code> * Check whether this logger is enabled for the <code>DEBUG</code>
* Level. * Level.
* *
* <p> This function is intended to lessen the computational cost o f * <p> This function is intended to lessen the computational cost o f
* disabled log debug statements. * disabled log debug statements.
* *
* <p> For some <code>logger</code> Logger object, when you write, * <p> For some <code>logger</code> Logger object, when you write,
* <pre> * <pre>
* logger->debug("debug message"); * logger->debug("debug message");
* </pre> * </pre>
* *
* <p>You incur the cost constructing the message, concatenation in * <p>You incur the cost constructing the message, concatenation in
* this case, regardless of whether the message is logged or not. * this case, regardless of whether the message is logged or not.
* *
* <p>If you are worried about speed, then you should write * <p>If you are worried about speed, then you should write
* <pre> * <pre>
* if(logger->isDebugEnabled()) { * if(logger->isDebugEnabled()) {
* logger->debug("debug message"); * logger->debug("debug message");
* } * }
* </pre> * </pre>
* *
* <p>This way you will not incur the cost of parameter * <p>This way you will not incur the cost of parameter
* construction if debugging is disabled for <code>logger</code>. O n * construction if debugging is disabled for <code>logger</code>. O n
* the other hand, if the <code>logger</code> is debug enabled, you * the other hand, if the <code>logger</code> is debug enabled, you
* will incur the cost of evaluating whether the logger is debug * will incur the cost of evaluating whether the logger is debug
* enabled twice. Once in <code>isDebugEnabled</code> and once in * enabled twice. Once in <code>isDebugEnabled</code> and once in
* the <code>debug</code>. This is an insignificant overhead * the <code>debug</code>. This is an insignificant overhead
* since evaluating a logger takes about 1%% of the time it * since evaluating a logger takes about 1%% of the time it
* takes to actually log. * takes to actually log.
skipping to change at line 439 skipping to change at line 1011
/** /**
Check whether this logger is enabled for the fatal Level. Check whether this logger is enabled for the fatal Level.
See also #isDebugEnabled. See also #isDebugEnabled.
@return bool - <code>true</code> if this logger is enabled @return bool - <code>true</code> if this logger is enabled
for level fatal, <code>false</code> otherwise. for level fatal, <code>false</code> otherwise.
*/ */
bool isFatalEnabled() const; bool isFatalEnabled() const;
/** /**
Log a localized and parameterized message. Check whether this logger is enabled for the trace level.
See also #isDebugEnabled.
First, the user supplied @return bool - <code>true</code> if this logger is enabled
<code>key</code> is searched in the resource bundle. Next, t for level trace, <code>false</code> otherwise.
he resulting */
pattern is formatted using helpers::StringHelper::format met bool isTraceEnabled() const;
hod with the user
supplied object array <code>params</code>. /**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resu
lting
pattern is formatted using helpers::StringHelper::format method wit
h the user
supplied string array <code>params</code>.
@param level The level of the logging request. @param level The level of the logging request.
@param key The key to be searched in the #resourceBundle. @param key The key to be searched in the ResourceBundle.
@param file The source file of the logging request, may be null. @param locationInfo The location info of the logging request.
@param line The number line of the logging request. @param values The values for the placeholders <code>{0}</code>,
<code>{1}</code> etc. within the pattern.
@see #setResourceBundle @see #setResourceBundle
*/ */
void l7dlog(const LevelPtr& level, const String& key, void l7dlog(const LevelPtr& level, const LogString& key,
const char* file, int line, ...); const log4cxx::spi::LocationInfo& locationInfo,
const std::vector<LogString>& values) const;
/**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resu
lting
pattern is formatted using helpers::StringHelper::format method wit
h the user
supplied string array <code>params</code>.
@param level The level of the logging request.
@param key The key to be searched in the ResourceBundle.
@param locationInfo The location info of the logging request.
@see #setResourceBundle
*/
void l7dlog(const LevelPtr& level, const std::string& key,
const log4cxx::spi::LocationInfo& locationInfo) const;
/**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resu
lting
pattern is formatted using helpers::StringHelper::format method wit
h the user
supplied string array <code>params</code>.
@param level The level of the logging request.
@param key The key to be searched in the ResourceBundle.
@param locationInfo The location info of the logging request.
@param val1 The first value for the placeholders within the pattern
.
@see #setResourceBundle
*/
void l7dlog(const LevelPtr& level, const std::string& key,
const log4cxx::spi::LocationInfo& locationInfo,
const std::string& val1) const;
/**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resu
lting
pattern is formatted using helpers::StringHelper::format method wit
h the user
supplied string array <code>params</code>.
@param level The level of the logging request.
@param key The key to be searched in the ResourceBundle.
@param locationInfo The location info of the logging request.
@param val1 The first value for the placeholders within the pattern
.
@param val2 The second value for the placeholders within the patter
n.
@see #setResourceBundle
*/
void l7dlog(const LevelPtr& level, const std::string& key,
const log4cxx::spi::LocationInfo& locationInfo,
const std::string& val1, const std::string& val2) const
;
/**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resu
lting
pattern is formatted using helpers::StringHelper::format method wit
h the user
supplied string array <code>params</code>.
@param level The level of the logging request.
@param key The key to be searched in the ResourceBundle.
@param locationInfo The location info of the logging request.
@param val1 The value for the first placeholder within the pattern.
@param val2 The value for the second placeholder within the pattern
.
@param val3 The value for the third placeholder within the pattern.
@see #setResourceBundle
*/
void l7dlog(const LevelPtr& level, const std::string& key,
const log4cxx::spi::LocationInfo& locationInfo,
const std::string& val1, const std::string& val2, const
std::string& val3) const;
#if LOG4CXX_WCHAR_T_API
/**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resu
lting
pattern is formatted using helpers::StringHelper::format method wit
h the user
supplied string array <code>params</code>.
@param level The level of the logging request.
@param key The key to be searched in the ResourceBundle.
@param locationInfo The location info of the logging request.
@see #setResourceBundle
*/
void l7dlog(const LevelPtr& level, const std::wstring& key,
const log4cxx::spi::LocationInfo& locationInfo) const;
/**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resu
lting
pattern is formatted using helpers::StringHelper::format method wit
h the user
supplied string array <code>params</code>.
@param level The level of the logging request.
@param key The key to be searched in the ResourceBundle.
@param locationInfo The location info of the logging request.
@param val1 The value for the first placeholder within the pattern.
@see #setResourceBundle
*/
void l7dlog(const LevelPtr& level, const std::wstring& key,
const log4cxx::spi::LocationInfo& locationInfo,
const std::wstring& val1) const;
/**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resu
lting
pattern is formatted using helpers::StringHelper::format method wit
h the user
supplied string array <code>params</code>.
@param level The level of the logging request.
@param key The key to be searched in the ResourceBundle.
@param locationInfo The location info of the logging request.
@param val1 The value for the first placeholder within the pattern.
@param val2 The value for the second placeholder within the pattern
.
@see #setResourceBundle
*/
void l7dlog(const LevelPtr& level, const std::wstring& key,
const log4cxx::spi::LocationInfo& locationInfo,
const std::wstring& val1, const std::wstring& val2) con
st;
/**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resu
lting
pattern is formatted using helpers::StringHelper::format method wit
h the user
supplied string array <code>params</code>.
@param level The level of the logging request.
@param key The key to be searched in the ResourceBundle.
@param locationInfo The location info of the logging request.
@param val1 The value for the first placeholder within the pattern.
@param val2 The value for the second placeholder within the pattern
.
@param val3 The value for the third placeholder within the pattern.
@see #setResourceBundle
*/
void l7dlog(const LevelPtr& level, const std::wstring& key,
const log4cxx::spi::LocationInfo& locationInfo,
const std::wstring& val1, const std::wstring& val2, con
st std::wstring& val3) const;
#endif
#if LOG4CXX_UNICHAR_API
/**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resu
lting
pattern is formatted using helpers::StringHelper::format method wit
h the user
supplied string array <code>params</code>.
@param level The level of the logging request.
@param key The key to be searched in the ResourceBundle.
@param locationInfo The location info of the logging request.
@see #setResourceBundle
*/
void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>
& key,
const log4cxx::spi::LocationInfo& locationInfo) const;
/**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resu
lting
pattern is formatted using helpers::StringHelper::format method wit
h the user
supplied string array <code>params</code>.
@param level The level of the logging request.
@param key The key to be searched in the ResourceBundle.
@param locationInfo The location info of the logging request.
@param val1 The value for the first placeholder within the pattern.
@see #setResourceBundle
*/
void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>
& key,
const log4cxx::spi::LocationInfo& locationInfo,
const std::basic_string<UniChar>& val1) const;
/**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resu
lting
pattern is formatted using helpers::StringHelper::format method wit
h the user
supplied string array <code>params</code>.
@param level The level of the logging request.
@param key The key to be searched in the ResourceBundle.
@param locationInfo The location info of the logging request.
@param val1 The value for the first placeholder within the pattern.
@param val2 The value for the second placeholder within the pattern
.
@see #setResourceBundle
*/
void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>
& key,
const log4cxx::spi::LocationInfo& locationInfo,
const std::basic_string<UniChar>& val1, const std::basi
c_string<UniChar>& val2) const;
/**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resu
lting
pattern is formatted using helpers::StringHelper::format method wit
h the user
supplied string array <code>params</code>.
@param level The level of the logging request.
@param key The key to be searched in the ResourceBundle.
@param locationInfo The location info of the logging request.
@param val1 The value for the first placeholder within the pattern.
@param val2 The value for the second placeholder within the pattern
.
@param val3 The value for the third placeholder within the pattern.
@see #setResourceBundle
*/
void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>
& key,
const log4cxx::spi::LocationInfo& locationInfo,
const std::basic_string<UniChar>& val1, const std::basi
c_string<UniChar>& val2,
const std::basic_string<UniChar>& val3) const;
#endif
#if LOG4CXX_CFSTRING_API
/**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resu
lting
pattern is formatted using helpers::StringHelper::format method wit
h the user
supplied string array <code>params</code>.
@param level The level of the logging request.
@param key The key to be searched in the ResourceBundle.
@param locationInfo The location info of the logging request.
@see #setResourceBundle
*/
void l7dlog(const LevelPtr& level, const CFStringRef& key,
const log4cxx::spi::LocationInfo& locationInfo) const;
/**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resu
lting
pattern is formatted using helpers::StringHelper::format method wit
h the user
supplied string array <code>params</code>.
@param level The level of the logging request.
@param key The key to be searched in the ResourceBundle.
@param locationInfo The location info of the logging request.
@param val1 The value for the first placeholder within the pattern.
@see #setResourceBundle
*/
void l7dlog(const LevelPtr& level, const CFStringRef& key,
const log4cxx::spi::LocationInfo& locationInfo,
const CFStringRef& val1) const;
/**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resu
lting
pattern is formatted using helpers::StringHelper::format method wit
h the user
supplied string array <code>params</code>.
@param level The level of the logging request.
@param key The key to be searched in the ResourceBundle.
@param locationInfo The location info of the logging request.
@param val1 The value for the first placeholder within the pattern.
@param val2 The value for the second placeholder within the pattern
.
@see #setResourceBundle
*/
void l7dlog(const LevelPtr& level, const CFStringRef& key,
const log4cxx::spi::LocationInfo& locationInfo,
const CFStringRef& val1, const CFStringRef& val2) const
;
/**
Log a localized and parameterized message.
First, the user supplied
<code>key</code> is searched in the resource bundle. Next, the resu
lting
pattern is formatted using helpers::StringHelper::format method wit
h the user
supplied string array <code>params</code>.
@param level The level of the logging request.
@param key The key to be searched in the ResourceBundle.
@param locationInfo The location info of the logging request.
@param val1 The value for the first placeholder within the pattern.
@param val2 The value for the second placeholder within the pattern
.
@param val3 The value for the third placeholder within the pattern.
@see #setResourceBundle
*/
void l7dlog(const LevelPtr& level, const CFStringRef& key,
const log4cxx::spi::LocationInfo& locationInfo,
const CFStringRef& val1, const CFStringRef& val2,
const CFStringRef& val3) const;
#endif
/** /**
This is the most generic printing method. It is intended to be This is the most generic printing method. It is intended to be
invoked by <b>wrapper</b> classes. invoked by <b>wrapper</b> classes.
@param level The level of the logging request. @param level The level of the logging request.
@param message The message of the logging request. @param message The message of the logging request.
@param file The source file of the logging request, may be null. @param location The source file of the logging request, may be null
@param line The number line of the logging request. */ . */
void log(const LevelPtr& level, const String& message, void log(const LevelPtr& level, const std::string& message,
const char* file=0, int line=-1); const log4cxx::spi::LocationInfo& location) const;
/**
This is the most generic printing method. It is intended to be
invoked by <b>wrapper</b> classes.
/** @param level The level of the logging request.
Remove all previously added appenders from this logger @param message The message of the logging request.
instance. */
<p>This is useful when re-reading configuration information. void log(const LevelPtr& level, const std::string& message) const;
*/ #if LOG4CXX_WCHAR_T_API
void removeAllAppenders(); /**
This is the most generic printing method. It is intended to be
invoked by <b>wrapper</b> classes.
/** @param level The level of the logging request.
Remove the appender passed as parameter form the list of app @param message The message of the logging request.
enders. @param location The source file of the logging request, may be null
*/ . */
void removeAppender(const AppenderPtr& appender); void log(const LevelPtr& level, const std::wstring& message,
const log4cxx::spi::LocationInfo& location) const;
/**
This is the most generic printing method. It is intended to be
invoked by <b>wrapper</b> classes.
/** @param level The level of the logging request.
Remove the appender with the name passed as parameter form t @param message The message of the logging request.
he */
list of appenders. void log(const LevelPtr& level, const std::wstring& message) const;
*/ #endif
void removeAppender(const String& name); #if LOG4CXX_UNICHAR_API
/**
This is the most generic printing method. It is intended to be
invoked by <b>wrapper</b> classes.
@param level The level of the logging request.
@param message The message of the logging request.
@param location The source file of the logging request, may be null
. */
void log(const LevelPtr& level, const std::basic_string<UniChar>& m
essage,
const log4cxx::spi::LocationInfo& location) const;
/**
This is the most generic printing method. It is intended to be
invoked by <b>wrapper</b> classes.
@param level The level of the logging request.
@param message The message of the logging request.
*/
void log(const LevelPtr& level, const std::basic_string<UniChar>& m
essage) const;
#endif
#if LOG4CXX_CFSTRING_API
/**
This is the most generic printing method. It is intended to be
invoked by <b>wrapper</b> classes.
@param level The level of the logging request.
@param message The message of the logging request.
@param location The source file of the logging request, may be null
. */
void log(const LevelPtr& level, const CFStringRef& message,
const log4cxx::spi::LocationInfo& location) const;
/**
This is the most generic printing method. It is intended to be
invoked by <b>wrapper</b> classes.
@param level The level of the logging request.
@param message The message of the logging request.
*/
void log(const LevelPtr& level, const CFStringRef& message) const;
#endif
/**
This is the most generic printing method. It is intended to be
invoked by <b>wrapper</b> classes.
@param level The level of the logging request.
@param message The message of the logging request.
@param location The source file of the logging request, may be null
. */
void logLS(const LevelPtr& level, const LogString& message,
const log4cxx::spi::LocationInfo& location) const;
/**
Remove all previously added appenders from this logger
instance.
<p>This is useful when re-reading configuration information.
*/
void removeAllAppenders();
/**
Remove the appender passed as parameter form the list of appenders.
*/
void removeAppender(const AppenderPtr& appender);
/**
Remove the appender with the name passed as parameter form the
list of appenders.
*/
void removeAppender(const LogString& name);
/** /**
Set the additivity flag for this Logger instance. Set the additivity flag for this Logger instance.
*/ */
void setAdditivity(bool additive); void setAdditivity(bool additive);
protected: protected:
friend class Hierarchy; friend class Hierarchy;
/** /**
Only the Hierarchy class can set the hierarchy of a logger.*/ Only the Hierarchy class can set the hierarchy of a logger.*/
void setHierarchy(spi::LoggerRepository * repository); void setHierarchy(spi::LoggerRepository * repository);
public: public:
/** /**
Set the level of this Logger. If you are passing any of Set the level of this Logger.
<code>Level#DEBUG</code>, <code>Level#INFO</code>,
<code>Level#WARN</code>, <code>Level#ERROR</code>,
<code>Level#FATAL</code> as a parameter, you need to case them as
Level.
<p>As in <pre> &nbsp;&nbsp;&nbsp;logger->setLevel(Level::DEBUG); </ pre> <p>As in <pre> &nbsp;&nbsp;&nbsp;logger->setLevel(Level::getDebug() ); </pre>
<p>Null values are admitted. */ <p>Null values are admitted. */
virtual void setLevel(const LevelPtr& level); virtual void setLevel(const LevelPtr& level);
/** /**
Set the resource bundle to be used with localized logging me Set the resource bundle to be used with localized logging methods.
thod #l7dlog. */
*/ inline void setResourceBundle(const helpers::ResourceBundlePtr& bun
inline void setResourceBundle(const helpers::ResourceBundleP dle)
tr& bundle) { resourceBundle = bundle; }
{ resourceBundle = bundle; }
/** #if LOG4CXX_WCHAR_T_API
Log a message string with the {@link Level#WARN WARN} level. /**
Log a message string with the WARN level.
<p>This method first checks if this logger is <code>WARN</co <p>This method first checks if this logger is <code>WARN</code>
de> enabled by comparing the level of this logger with the
enabled by comparing the level of this logger with the {@lin WARN level. If this logger is
k <code>WARN</code> enabled, it proceeds to call all the
Level#WARN WARN} level. If this logger is registered appenders in this logger and also higher in the
<code>WARN</code> enabled, it proceeds to call all the hierarchy depending on the value of the additivity flag.
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param message the message string to log. @param msg the message string to log.
@param file the file where the log statement was written. @param location location of source of logging request.
@param line the line where the log statement was written. */
*/ void warn(const std::wstring& msg, const log4cxx::spi::LocationInfo
void warn(const String& message, const char* file=NULL, int & location) const;
line=-1); /**
Log a message string with the WARN level.
<p>This method first checks if this logger is <code>WARN</code>
enabled by comparing the level of this logger with the
WARN level. If this logger is
<code>WARN</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void warn(const std::wstring& msg) const;
#endif
#if LOG4CXX_UNICHAR_API
/**
Log a message string with the WARN level.
<p>This method first checks if this logger is <code>WARN</code>
enabled by comparing the level of this logger with the
WARN level. If this logger is
<code>WARN</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void warn(const std::basic_string<UniChar>& msg, const log4cxx::spi
::LocationInfo& location) const;
/**
Log a message string with the WARN level.
<p>This method first checks if this logger is <code>WARN</code>
enabled by comparing the level of this logger with the
WARN level. If this logger is
<code>WARN</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void warn(const std::basic_string<UniChar>& msg) const;
#endif
#if LOG4CXX_CFSTRING_API
/**
Log a message string with the WARN level.
<p>This method first checks if this logger is <code>WARN</code>
enabled by comparing the level of this logger with the
WARN level. If this logger is
<code>WARN</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void warn(const CFStringRef& msg, const log4cxx::spi::LocationInfo&
location) const;
/**
Log a message string with the WARN level.
<p>This method first checks if this logger is <code>WARN</code>
enabled by comparing the level of this logger with the
WARN level. If this logger is
<code>WARN</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void warn(const CFStringRef& msg) const;
#endif
/**
Log a message string with the WARN level.
<p>This method first checks if this logger is <code>WARN</code>
enabled by comparing the level of this logger with the
WARN level. If this logger is
<code>WARN</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void warn(const std::string& msg, const log4cxx::spi::LocationInfo&
location) const;
/**
Log a message string with the WARN level.
<p>This method first checks if this logger is <code>WARN</code>
enabled by comparing the level of this logger with the
WARN level. If this logger is
<code>WARN</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void warn(const std::string& msg) const;
#if LOG4CXX_WCHAR_T_API
/**
Log a message string with the TRACE level.
<p>This method first checks if this logger is <code>TRACE</code>
enabled by comparing the level of this logger with the
TRACE level. If this logger is
<code>TRACE</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void trace(const std::wstring& msg, const log4cxx::spi::LocationInf
o& location) const;
/**
Log a message string with the TRACE level.
<p>This method first checks if this logger is <code>TRACE</code>
enabled by comparing the level of this logger with the
TRACE level. If this logger is
<code>TRACE</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void trace(const std::wstring& msg) const;
#endif
#if LOG4CXX_UNICHAR_API
/**
Log a message string with the TRACE level.
<p>This method first checks if this logger is <code>TRACE</code>
enabled by comparing the level of this logger with the
TRACE level. If this logger is
<code>TRACE</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void trace(const std::basic_string<UniChar>& msg, const log4cxx::sp
i::LocationInfo& location) const;
/**
Log a message string with the TRACE level.
<p>This method first checks if this logger is <code>TRACE</code>
enabled by comparing the level of this logger with the
TRACE level. If this logger is
<code>TRACE</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void trace(const std::basic_string<UniChar>& msg) const;
#endif
#if LOG4CXX_CFSTRING_API
/**
Log a message string with the TRACE level.
<p>This method first checks if this logger is <code>TRACE</code>
enabled by comparing the level of this logger with the
TRACE level. If this logger is
<code>TRACE</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void trace(const CFStringRef& msg, const log4cxx::spi::LocationInfo
& location) const;
/**
Log a message string with the TRACE level.
<p>This method first checks if this logger is <code>TRACE</code>
enabled by comparing the level of this logger with the
TRACE level. If this logger is
<code>TRACE</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void trace(const CFStringRef& msg) const;
#endif
/**
Log a message string with the TRACE level.
<p>This method first checks if this logger is <code>TRACE</code>
enabled by comparing the level of this logger with the
TRACE level. If this logger is
<code>TRACE</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
@param location location of source of logging request.
*/
void trace(const std::string& msg, const log4cxx::spi::LocationInfo
& location) const;
/**
Log a message string with the TRACE level.
<p>This method first checks if this logger is <code>TRACE</code>
enabled by comparing the level of this logger with the
TRACE level. If this logger is
<code>TRACE</code> enabled, it proceeds to call all the
registered appenders in this logger and also higher in the
hierarchy depending on the value of the additivity flag.
@param msg the message string to log.
*/
void trace(const std::string& msg) const;
inline const log4cxx::helpers::Mutex& getMutex() const { return mut
ex; }
private:
//
// prevent copy and assignment
Logger(const Logger&);
Logger& operator=(const Logger&);
log4cxx::helpers::Mutex mutex;
friend class log4cxx::helpers::synchronized;
}; };
LOG4CXX_LIST_DEF(LoggerList, LoggerPtr);
} }
/** @addtogroup LoggingMacros Logging macros /** @addtogroup LoggingMacros Logging macros
@{ @{
*/ */
#if !defined(LOG4CXX_UNLIKELY)
#if __GNUC__ >= 3
/**
Provides optimization hint to the compiler
to optimize for the expression being false.
@param expr boolean expression.
@returns value of expression.
*/
#define LOG4CXX_UNLIKELY(expr) __builtin_expect(expr, 0)
#else
/**
Provides optimization hint to the compiler
to optimize for the expression being false.
@param expr boolean expression.
@returns value of expression.
**/
#define LOG4CXX_UNLIKELY(expr) expr
#endif
#endif
/** /**
Logs a message to a specified logger with a specified level. Logs a message to a specified logger with a specified level.
@param logger the logger to be used. @param logger the logger to be used.
@param level the level to log. @param level the level to log.
@param message the message string to log. @param message the message string to log.
*/ */
#define LOG4CXX_LOG(logger, level, message) { \ #define LOG4CXX_LOG(logger, level, message) { \
if (logger->isEnabledFor(level)) {\ if (logger->isEnabledFor(level)) {\
::log4cxx::StringBuffer oss; \ ::log4cxx::helpers::MessageBuffer oss_; \
oss << message; \ logger->forcedLog(level, oss_.str(oss_ << message), LOG4CXX_LOCA
logger->forcedLog(level, oss.str(), __FILE__, __LINE__); }} TION); } }
/**
Logs a message to a specified logger with a specified level.
@param logger the logger to be used.
@param level the level to log.
@param message the message string to log in the internal encoding.
*/
#define LOG4CXX_LOGLS(logger, level, message) { \
if (logger->isEnabledFor(level)) {\
::log4cxx::helpers::LogCharMessageBuffer oss_; \
logger->forcedLog(level, oss_.str(oss_ << message), LOG4CXX_LOCA
TION); } }
/** /**
Logs a message to a specified logger with the DEBUG level. Logs a message to a specified logger with the DEBUG level.
@param logger the logger to be used. @param logger the logger to be used.
@param message the message string to log. @param message the message string to log.
*/ */
#define LOG4CXX_DEBUG(logger, message) { \ #define LOG4CXX_DEBUG(logger, message) { \
if (logger->isDebugEnabled()) {\ if (LOG4CXX_UNLIKELY(logger->isDebugEnabled())) {\
::log4cxx::StringBuffer oss; \ ::log4cxx::helpers::MessageBuffer oss_; \
oss << message; \ logger->forcedLog(::log4cxx::Level::getDebug(), oss_.str(oss_ <<
logger->forcedLog(::log4cxx::Level::DEBUG, oss.str(), __FILE__, __LI message), LOG4CXX_LOCATION); }}
NE__); }}
/**
Logs a message to a specified logger with the TRACE level.
@param logger the logger to be used.
@param message the message string to log.
*/
#define LOG4CXX_TRACE(logger, message) { \
if (LOG4CXX_UNLIKELY(logger->isTraceEnabled())) {\
::log4cxx::helpers::MessageBuffer oss_; \
logger->forcedLog(::log4cxx::Level::getTrace(), oss_.str(oss_ <<
message), LOG4CXX_LOCATION); }}
/** /**
Logs a message to a specified logger with the INFO level. Logs a message to a specified logger with the INFO level.
@param logger the logger to be used. @param logger the logger to be used.
@param message the message string to log. @param message the message string to log.
*/ */
#define LOG4CXX_INFO(logger, message) { \ #define LOG4CXX_INFO(logger, message) { \
if (logger->isInfoEnabled()) {\ if (logger->isInfoEnabled()) {\
::log4cxx::StringBuffer oss; \ ::log4cxx::helpers::MessageBuffer oss_; \
oss << message; \ logger->forcedLog(::log4cxx::Level::getInfo(), oss_.str(oss_ <<
logger->forcedLog(::log4cxx::Level::INFO, oss.str(), __FILE__, __LIN message), LOG4CXX_LOCATION); }}
E__); }}
/** /**
Logs a message to a specified logger with the WARN level. Logs a message to a specified logger with the WARN level.
@param logger the logger to be used. @param logger the logger to be used.
@param message the message string to log. @param message the message string to log.
*/ */
#define LOG4CXX_WARN(logger, message) { \ #define LOG4CXX_WARN(logger, message) { \
if (logger->isWarnEnabled()) {\ if (logger->isWarnEnabled()) {\
::log4cxx::StringBuffer oss; \ ::log4cxx::helpers::MessageBuffer oss_; \
oss << message; \ logger->forcedLog(::log4cxx::Level::getWarn(), oss_.str(oss_ <<
logger->forcedLog(::log4cxx::Level::WARN, oss.str(), __FILE__, __LIN message), LOG4CXX_LOCATION); }}
E__); }}
/** /**
Logs a message to a specified logger with the ERROR level. Logs a message to a specified logger with the ERROR level.
@param logger the logger to be used. @param logger the logger to be used.
@param message the message string to log. @param message the message string to log.
*/ */
#define LOG4CXX_ERROR(logger, message) { \ #define LOG4CXX_ERROR(logger, message) { \
if (logger->isErrorEnabled()) {\ if (logger->isErrorEnabled()) {\
::log4cxx::StringBuffer oss; \ ::log4cxx::helpers::MessageBuffer oss_; \
oss << message; \ logger->forcedLog(::log4cxx::Level::getError(), oss_.str(oss_ <<
logger->forcedLog(::log4cxx::Level::ERROR, oss.str(), __FILE__, __LI message), LOG4CXX_LOCATION); }}
NE__); }}
/**
Logs a error if the condition is not true.
@param logger the logger to be used.
@param condition condition
@param message the message string to log.
*/
#define LOG4CXX_ASSERT(logger, condition, message) { \
if (!(condition) && logger->isErrorEnabled()) {\
::log4cxx::helpers::MessageBuffer oss_; \
logger->forcedLog(::log4cxx::Level::getError(), oss_.str(oss_ <<
message), LOG4CXX_LOCATION); }}
/** /**
Logs a message to a specified logger with the FATAL level. Logs a message to a specified logger with the FATAL level.
@param logger the logger to be used. @param logger the logger to be used.
@param message the message string to log. @param message the message string to log.
*/ */
#define LOG4CXX_FATAL(logger, message) { \ #define LOG4CXX_FATAL(logger, message) { \
if (logger->isFatalEnabled()) {\ if (logger->isFatalEnabled()) {\
::log4cxx::StringBuffer oss; \ ::log4cxx::helpers::MessageBuffer oss_; \
oss << message; \ logger->forcedLog(::log4cxx::Level::getFatal(), oss_.str(oss_ <<
logger->forcedLog(::log4cxx::Level::FATAL, oss.str(), __FILE__, __LI message), LOG4CXX_LOCATION); }}
NE__); }}
/** /**
Logs a localized message with no parameter. Logs a localized message with no parameter.
@param logger the logger to be used. @param logger the logger to be used.
@param level the level to log. @param level the level to log.
@param key the key to be searched in the resourceBundle of the logger. @param key the key to be searched in the resourceBundle of the logger.
*/ */
#define LOG4CXX_L7DLOG(logger, level, key) { \ #define LOG4CXX_L7DLOG(logger, level, key) { \
if (logger->isEnabledFor(level)) {\ if (logger->isEnabledFor(level)) {\
logger->l7dlog(level, key, __FILE__, __LINE__); }} logger->l7dlog(level, key, LOG4CXX_LOCATION); }}
/** /**
Logs a localized message with one parameter. Logs a localized message with one parameter.
@param logger the logger to be used. @param logger the logger to be used.
@param level the level to log. @param level the level to log.
@param key the key to be searched in the resourceBundle of the logger. @param key the key to be searched in the resourceBundle of the logger.
@param p1 the unique parameter. Must be of type (TCHAR *). @param p1 the unique parameter.
*/ */
#define LOG4CXX_L7DLOG1(logger, level, key, p1) { \ #define LOG4CXX_L7DLOG1(logger, level, key, p1) { \
if (logger->isEnabledFor(level)) {\ if (logger->isEnabledFor(level)) {\
logger->l7dlog(level, key, __FILE__, __LINE__, p1); }} logger->l7dlog(level, key, LOG4CXX_LOCATION, p1); }}
/** /**
Logs a localized message with two parameters. Logs a localized message with two parameters.
@param logger the logger to be used. @param logger the logger to be used.
@param level the level to log. @param level the level to log.
@param key the key to be searched in the resourceBundle of the logger. @param key the key to be searched in the resourceBundle of the logger.
@param p1 the first parameter. Must be of type (TCHAR *). @param p1 the first parameter.
@param p2 the second parameter. Must be of type (TCHAR *). @param p2 the second parameter.
*/ */
#define LOG4CXX_L7DLOG2(logger, level, key, p1, p2) { \ #define LOG4CXX_L7DLOG2(logger, level, key, p1, p2) { \
if (logger->isEnabledFor(level)) {\ if (logger->isEnabledFor(level)) {\
logger->l7dlog(level, key, __FILE__, __LINE__, p1, p2); }} logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2); }}
/** /**
Logs a localized message with three parameters. Logs a localized message with three parameters.
@param logger the logger to be used. @param logger the logger to be used.
@param level the level to log. @param level the level to log.
@param key the key to be searched in the resourceBundle of the logger. @param key the key to be searched in the resourceBundle of the logger.
@param p1 the first parameter. Must be of type (TCHAR *). @param p1 the first parameter.
@param p2 the second parameter. Must be of type (TCHAR *). @param p2 the second parameter.
@param p3 the third parameter. Must be of type (TCHAR *). @param p3 the third parameter.
*/ */
#define LOG4CXX_L7DLOG3(logger, level, key, p1, p2, p3) { \ #define LOG4CXX_L7DLOG3(logger, level, key, p1, p2, p3) { \
if (logger->isEnabledFor(level)) {\ if (logger->isEnabledFor(level)) {\
logger->l7dlog(level, key, __FILE__, __LINE__, p1, p2, p3); }} logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2, p3); }}
/**@}*/ /**@}*/
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#include <log4cxx/spi/loggerrepository.h>
#endif //_LOG4CXX_LOGGER_H #endif //_LOG4CXX_LOGGER_H
 End of changes. 93 change blocks. 
299 lines changed or deleted 1617 lines changed or added


 loggerfactory.h   loggerfactory.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_LOGGERFACTORY_H #ifndef _LOG4CXX_SPI_LOGGERFACTORY_H
#define _LOG4CXX_SPI_LOGGERFACTORY_H #define _LOG4CXX_SPI_LOGGERFACTORY_H
#include <log4cxx/helpers/object.h> #include <log4cxx/logger.h>
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/tchar.h>
namespace log4cxx namespace log4cxx
{ {
class Logger;
typedef helpers::ObjectPtrT<Logger> LoggerPtr;
namespace spi namespace spi
{ {
/** /**
Implement this interface to create new instances of Logger o Implement this interface to create new instances of Logger
r or
a sub-class of Logger. a sub-class of Logger.
*/ */
class LOG4CXX_EXPORT LoggerFactory : public virtual helpers: class LOG4CXX_EXPORT LoggerFactory : public virtual helpers
:Object ::Object
{ {
public: public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(LoggerFactory) DECLARE_ABSTRACT_LOG4CXX_OBJECT(LoggerFactory)
virtual ~LoggerFactory() {} virtual ~LoggerFactory() {}
virtual LoggerPtr makeNewLoggerInstance(const String virtual LoggerPtr makeNewLoggerInstance(
& name) = 0; log4cxx::helpers::Pool& pool,
}; const LogString& name) const = 0;
};
typedef helpers::ObjectPtrT<LoggerFactory> LoggerFactoryPtr;
} // namespace spi } // namespace spi
}; // namesapce log4cxx } // namesapce log4cxx
#endif //_LOG4CXX_SPI_LOGGERFACTORY_H #endif //_LOG4CXX_SPI_LOGGERFACTORY_H
 End of changes. 5 change blocks. 
30 lines changed or deleted 26 lines changed or added


 loggerrepository.h   loggerrepository.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_LOG_REPOSITORY_H #ifndef _LOG4CXX_SPI_LOG_REPOSITORY_H
#define _LOG4CXX_SPI_LOG_REPOSITORY_H #define _LOG4CXX_SPI_LOG_REPOSITORY_H
#include <log4cxx/helpers/objectptr.h> #if defined(_MSC_VER)
#include <log4cxx/helpers/object.h> #pragma warning ( push )
#include <log4cxx/helpers/tchar.h> #pragma warning ( disable: 4231 4251 4275 4786 )
#include <vector> #endif
#include <log4cxx/appender.h>
#include <log4cxx/spi/loggerfactory.h>
#include <log4cxx/level.h>
#include <log4cxx/spi/hierarchyeventlistener.h>
namespace log4cxx namespace log4cxx
{ {
class Level; namespace spi
typedef helpers::ObjectPtrT<Level> LevelPtr; {
class Logger;
typedef helpers::ObjectPtrT<Logger> LoggerPtr;
typedef std::vector<LoggerPtr> LoggerList;
class Appender; /**
typedef log4cxx::helpers::ObjectPtrT<Appender> AppenderPtr; A <code>LoggerRepository</code> is used to create and retrieve
<code>Loggers</code>. The relation between loggers in a reposit
ory
depends on the repository but typically loggers are arranged in
a
named hierarchy.
namespace spi <p>In addition to the creational methods, a
{ <code>LoggerRepository</code> can be queried for existing logge
class HierarchyEventListener; rs,
typedef log4cxx::helpers::ObjectPtrT<HierarchyEventListener> can act as a point of registry for events related to loggers.
HierarchyEventListenerPtr; */
class LOG4CXX_EXPORT LoggerRepository : public virtual helpers:
:Object
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(LoggerRepository)
virtual ~LoggerRepository() {}
class LoggerFactory; /**
typedef helpers::ObjectPtrT<LoggerFactory> LoggerFactoryPtr; Add a {@link spi::HierarchyEventListener HierarchyEventList
ener}
event to the repository.
*/
virtual void addHierarchyEventListener(const HierarchyEvent
ListenerPtr&
listener) = 0;
/**
Is the repository disabled for a given level? The answer de
pends
on the repository threshold and the <code>level</code>
parameter. See also #setThreshold method. */
virtual bool isDisabled(int level) const = 0;
class LoggerRepository; /**
typedef helpers::ObjectPtrT<LoggerRepository> LoggerReposito Set the repository-wide threshold. All logging requests bel
ryPtr; ow the
threshold are immediately dropped. By default, the threshol
d is
set to <code>Level::getAll()</code> which has the lowest po
ssible rank. */
virtual void setThreshold(const LevelPtr& level) = 0;
/** /**
A <code>LoggerRepository</code> is used to create and retrie Another form of {@link #setThreshold(const LevelPtr&)
ve setThreshold} accepting a string
<code>Loggers</code>. The relation between loggers in a repository parameter instead of a <code>Level</code>. */
depends on the repository but typically loggers are arranged in a virtual void setThreshold(const LogString& val) = 0;
named hierarchy.
<p>In addition to the creational methods, a virtual void emitNoAppenderWarning(const LoggerPtr& logger)
<code>LoggerRepository</code> can be queried for existing loggers, = 0;
can act as a point of registry for events related to loggers.
*/
class LOG4CXX_EXPORT LoggerRepository : public virtual helpers::Obj
ect
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(LoggerRepository)
virtual ~LoggerRepository() {}
/** /**
Add a {@link spi::HierarchyEventListener HierarchyEventListener Get the repository-wide threshold. See {@link
} #setThreshold(const LevelPtr&) setThreshold}
event to the repository. for an explanation. */
*/ virtual const LevelPtr& getThreshold() const = 0;
virtual void addHierarchyEventListener(const HierarchyEventList
enerPtr&
listener) = 0;
/**
Is the repository disabled for a given level? The answer depend
s
on the repository threshold and the <code>level</code>
parameter. See also #setThreshold method. */
virtual bool isDisabled(int level) const = 0;
/** virtual LoggerPtr getLogger(const LogString& name) = 0;
Set the repository-wide threshold. All logging requests below t
he
threshold are immediately dropped. By default, the threshold is
set to <code>Level::ALL</code> which has the lowest possible ra
nk. */
virtual void setThreshold(const LevelPtr& level) = 0;
/** virtual LoggerPtr getLogger(const LogString& name,
Another form of {@link #setThreshold(const LevelPtr&) const spi::LoggerFactoryPtr& factory) = 0;
setThreshold} accepting a string
parameter instead of a <code>Level</code>. */
virtual void setThreshold(const String& val) = 0;
virtual void emitNoAppenderWarning(const LoggerPtr& logger) = 0 ; virtual LoggerPtr getRootLogger() const = 0;
/** virtual LoggerPtr exists(const LogString& name) = 0;
Get the repository-wide threshold. See {@link
#setThreshold(const LevelPtr&) setThreshold}
for an explanation. */
virtual const LevelPtr& getThreshold() const = 0;
virtual LoggerPtr getLogger(const String& name) = 0; virtual void shutdown() = 0;
virtual LoggerPtr getLogger(const String& name, spi::LoggerFact virtual LoggerList getCurrentLoggers() const = 0;
oryPtr
factory) = 0;
virtual LoggerPtr getRootLogger() const = 0; virtual void fireAddAppenderEvent(const LoggerPtr& logger,
const AppenderPtr& appender) = 0;
virtual LoggerPtr exists(const String& name) = 0; virtual void resetConfiguration() = 0;
virtual void shutdown() = 0; virtual bool isConfigured() = 0;
virtual void setConfigured(bool configured) = 0;
virtual LoggerList getCurrentLoggers() const = 0; }; // class LoggerRepository
virtual void fireAddAppenderEvent(const LoggerPtr& logger, } // namespace spi
const AppenderPtr& appender) = 0; } // namespace log4cxx
virtual void resetConfiguration() = 0; #if defined(_MSC_VER)
}; // class LoggerRepository #pragma warning ( pop )
} // namespace spi #endif
}; // namespace log4cxx
#endif //_LOG4CXX_SPI_LOG_REPOSITORY_H #endif //_LOG4CXX_SPI_LOG_REPOSITORY_H
 End of changes. 22 change blocks. 
90 lines changed or deleted 87 lines changed or added


 loggingevent.h   loggingevent.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_LOGGING_EVENT_H #ifndef _LOG4CXX_SPI_LOGGING_EVENT_H
#define _LOG4CXX_SPI_LOGGING_EVENT_H #define _LOG4CXX_SPI_LOGGING_EVENT_H
#if defined(_MSC_VER)
#pragma warning (push)
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/tchar.h> #include <log4cxx/logstring.h>
#include <time.h> #include <time.h>
#include <log4cxx/logger.h> #include <log4cxx/logger.h>
#include <log4cxx/mdc.h> #include <log4cxx/mdc.h>
#include <set> #include <log4cxx/spi/location/locationinfo.h>
#include <vector>
namespace log4cxx namespace log4cxx
{ {
class Logger; namespace helpers
typedef helpers::ObjectPtrT<Logger> LoggerPtr; {
class ObjectOutputStream;
class Level; }
namespace helpers
{
class SocketOutputStream;
typedef helpers::ObjectPtrT<SocketOutputStream> SocketOutput
StreamPtr;
class SocketInputStream;
typedef helpers::ObjectPtrT<SocketInputStream> SocketInputSt
reamPtr;
}
namespace spi
{
class LoggingEvent;
/** smart pointer to a LoggingEvent class */
typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr;
/**
The internal representation of logging events. When an affir
mative
decision is made to log then a <code>LoggingEvent</code> ins
tance
is created. This instance is passed around to the different
log4cxx
components.
<p>This class is of concern to those wishing to extend log4c
xx.
*/
class LOG4CXX_EXPORT LoggingEvent :
public virtual helpers::ObjectImpl
{
public:
DECLARE_LOG4CXX_OBJECT(LoggingEvent)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(LoggingEvent)
END_LOG4CXX_CAST_MAP()
/** For serialization only
*/
LoggingEvent();
/** namespace spi
Instantiate a LoggingEvent from the supplied paramet {
ers.
<p>Except #timeStamp all the other fields of /**
<code>LoggingEvent</code> are filled when actually n The internal representation of logging events. When an affi
eeded. rmative
<p> decision is made to log then a <code>LoggingEvent</code> in
@param fqnOfLoggerClass The fully qualified name of stance
the calling is created. This instance is passed around to the different
logger class. log4cxx
@param logger The logger of this event. components.
@param level The level of this event.
@param message The message of this event.
@param file The file where this log statement was wr
itten.
@param line The line where this log statement was wr
itten.
*/
LoggingEvent(const String& fqnOfLoggerClass,
const LoggerPtr& logger,
const LevelPtr& level, const String& messag
e,
const char* file=0, int line=-1);
~LoggingEvent(); <p>This class is of concern to those wishing to extend log4
cxx.
*/
class LOG4CXX_EXPORT LoggingEvent :
public virtual helpers::ObjectImpl
{
public:
DECLARE_LOG4CXX_OBJECT(LoggingEvent)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(LoggingEvent)
END_LOG4CXX_CAST_MAP()
/** Return the #level of this event. */ /** For serialization only
inline const LevelPtr& getLevel() const */
{ return level; } LoggingEvent();
/** Return the name of the #logger. */ /**
const String& getLoggerName() const; Instantiate a LoggingEvent from the supplied parame
ters.
/** Return the #message for this logging event. */ <p>Except timeStamp all the other fields of
inline const String& getMessage() const <code>LoggingEvent</code> are filled when actually
{ return message; } needed.
<p>
@param logger The logger of this event.
@param level The level of this event.
@param message The message of this event.
@param location location of logging request.
*/
LoggingEvent(const LogString& logger,
const LevelPtr& level, const LogString& m
essage,
const log4cxx::spi::LocationInfo& location)
;
/** Return the #message for this logging event. */ ~LoggingEvent();
inline const String& getRenderedMessage() const
{ return message; }
/**Returns the time when the application started, /** Return the level of this event. */
in seconds elapsed since 01.01.1970. inline const LevelPtr& getLevel() const
*/ { return level; }
static int64_t getStartTime()
{ return startTime; }
/** Return the #threadId of this event. */ /** Return the name of the logger. */
inline unsigned long getThreadId() const inline const LogString& getLoggerName() const {
{ return threadId; } return logger;
}
/** Return the #timeStamp of this event. */ /** Return the message for this logging event. */
inline int64_t getTimeStamp() const inline const LogString& getMessage() const
{ return timeStamp; } { return message; }
/* Return the file where this log statement was writ /** Return the message for this logging event. */
ten. */ inline const LogString& getRenderedMessage() const
inline char * getFile() const { return message; }
{ return file; }
/* Return the line where this log statement was writ /**Returns the time when the application started,
ten. */ in seconds elapsed since 01.01.1970.
inline int getLine() const */
{ return line; } static log4cxx_time_t getStartTime();
/** /** Return the threadName of this event. */
* This method returns the NDC for this event. It wil inline const LogString& getThreadName() const {
l return the return threadName;
* correct content even if the event was generated in }
a different
* thread or even on a different machine. The NDC#get
method
* should <em>never</em> be called directly. */
const String& getNDC() const;
/** Write this event to a helpers::SocketOutputStrea /** Return the timeStamp of this event. */
m. */ inline log4cxx_time_t getTimeStamp() const
void write(helpers::SocketOutputStreamPtr& os) const { return timeStamp; }
;
void writeLevel(helpers::SocketOutputStreamPtr& os) /* Return the file where this log statement was wri
const; tten. */
inline const log4cxx::spi::LocationInfo& getLocatio
nInformation() const
{ return locationInfo; }
/** Read this event from a helpers::SocketOutputStre /**
am. */ * This method appends the NDC for this event to pas
void read(const helpers::SocketInputStreamPtr& is); sed string. It will return the
* correct content even if the event was generated i
n a different
* thread or even on a different machine. The NDC#ge
t method
* should <em>never</em> be called directly.
*
* @param dest destination for NDC, unchanged if NDC
is not set.
* @return true if NDC is set.
*/
bool getNDC(LogString& dest) const;
void readLevel(const helpers::SocketInputStreamPtr& /**
is); * Writes the content of the LoggingEvent
* in a format compatible with log4j's serialized
form.
*/
void write(helpers::ObjectOutputStream& os, helpers
::Pool& p) const;
/** /**
* Returns the the context corresponding to the <code * Appends the the context corresponding to the <cod
>key</code> parameter. e>key</code> parameter.
* If there is a local MDC copy, possibly because we * If there is a local MDC copy, possibly because we
are in a logging are in a logging
* server or running inside AsyncAppender, then we se * server or running inside AsyncAppender, then we s
arch for the key in earch for the key in
* MDC copy, if a value is found it is returned. Othe * MDC copy, if a value is found it is returned. Oth
rwise, if the search erwise, if the search
* in MDC copy returns an empty result, then the curr * in MDC copy returns an empty result, then the cur
ent thread's rent thread's
* <code>MDC</code> is used. * <code>MDC</code> is used.
* *
* <p> * <p>
* Note that <em>both</em> the local MDC copy and the * Note that <em>both</em> the local MDC copy and th
current thread's MDC e current thread's MDC
* are searched. * are searched.
* </p> * </p>
*/ * @param key key.
String getMDC(const String& key) const; * @param dest string to which value, if any, is app
ended.
* @return true if key had a corresponding value.
*/
bool getMDC(const LogString& key, LogString& dest)
const;
/** LOG4CXX_LIST_DEF(KeySet, LogString);
* Returns the set of of the key values in the MDC fo /**
r the event. * Returns the set of of the key values in the MDC f
* The returned set is unmodifiable by the caller. or the event.
* * The returned set is unmodifiable by the caller.
* @return Set an unmodifiable set of the MDC keys. *
* @since 1.3 * @return Set an unmodifiable set of the MDC keys.
*/ *
std::set<String> getMDCKeySet() const; */
KeySet getMDCKeySet() const;
/** /**
Obtain a copy of this thread's MDC prior to serializ Obtain a copy of this thread's MDC prior to seriali
ation zation
or asynchronous logging. or asynchronous logging.
*/ */
void getMDCCopy() const; void getMDCCopy() const;
/** /**
* Return a previously set property. The return value * Return a previously set property.
can be null. * @param key key.
*/ * @param dest string to which value, if any, is app
String getProperty(const String& key) const; ended.
/** * @return true if key had a corresponding value.
* Returns the set of of the key values in the proper */
ties bool getProperty(const LogString& key, LogString& d
* for the event. The returned set is unmodifiable by est) const;
the caller. /**
* * Returns the set of of the key values in the prope
* @return Set an unmodifiable set of the property ke rties
ys. * for the event. The returned set is unmodifiable b
*/ y the caller.
std::set<String> getPropertyKeySet() const; *
* @return Set an unmodifiable set of the property k
eys.
*/
KeySet getPropertyKeySet() const;
/** /**
* Set a string property using a key and a string val * Set a string property using a key and a string va
ue. since 1.3 lue. since 1.3
*/ */
void setProperty(const String& key, const String& va void setProperty(const LogString& key, const LogStr
lue); ing& value);
public: private:
/** /**
* Fully qualified name of the calling category class * The logger of the logging event.
. **/
*/ LogString logger;
String fqnOfCategoryClass;
private: /** level of logging event. */
/** LevelPtr level;
* The logger of the logging event. This field is not
serialized for
* performance reasons.
*
* <p>
* It is set by the LoggingEvent constructor or set b
y a remote
* entity after deserialization.
**/
LoggerPtr logger;
/** level of logging event. */ /** The nested diagnostic context (NDC) of logging
LevelPtr level; event. */
mutable LogString* ndc;
/** The nested diagnostic context (NDC) of logging e /** The mapped diagnostic context (MDC) of logging
vent. */ event. */
String ndc; mutable MDC::Map* mdcCopy;
/** The mapped diagnostic context (MDC) of logging e /**
vent. */ * A map of String keys and String values.
MDC::Map mdcCopy; */
std::map<LogString, LogString> * properties;
/** /** Have we tried to do an NDC lookup? If we did, t
* A map of String keys and String values. here is no need
*/ * to do it again. Note that its value is always f
std::map<String, String> * properties; alse when
* serialized. Thus, a receiving SocketNode will ne
ver use it's own
* (incorrect) NDC. See also writeObject method.
*/
mutable bool ndcLookupRequired;
/** Have we tried to do an NDC lookup? If we did, th /**
ere is no need * Have we tried to do an MDC lookup? If we did, the
* to do it again. Note that its value is always fa re is no need to do it
lse when * again. Note that its value is always false when
* serialized. Thus, a receiving SocketNode will nev serialized. See also
er use it's own * the getMDC and getMDCCopy methods.
* (incorrect) NDC. See also writeObject method. */
*/ mutable bool mdcCopyLookupRequired;
bool ndcLookupRequired;
/** /** The application supplied message of logging eve
* Have we tried to do an MDC lookup? If we did, ther nt. */
e is no need to do it LogString message;
* again. Note that its value is always false when s
erialized. See also
* the getMDC and getMDCCopy methods.
*/
bool mdcCopyLookupRequired;
/** The application supplied message of logging even /** The number of milliseconds elapsed from 1/1/197
t. */ 0 until logging event
String message; was created. */
log4cxx_time_t timeStamp;
/** The name of thread in which this logging event was generate /** The is the location where this log statement wa
d. */ s written. */
//const LOG4CPLUS_THREAD_KEY_TYPE thread; const log4cxx::spi::LocationInfo locationInfo;
/** The number of milliseconds elapsed from 1/1/1970 until logg /** The identifier of thread in which this logging
ing event event
was created. */ was generated.
int64_t timeStamp; */
const LogString threadName;
/** The is the file where this log statement was wri //
tten. */ // prevent copy and assignment
char* file; //
std::string fileFromStream; LoggingEvent(const LoggingEvent&);
LoggingEvent& operator=(const LoggingEvent&);
static const LogString getCurrentThreadName();
/** The is the line where this log statement was wri static void writeProlog(log4cxx::helpers::ObjectOutp
tten. */ utStream& os, log4cxx::helpers::Pool& p);
int line;
/** The identifier of thread in which this logging e };
vent
was generated.
*/
unsigned long threadId;
static int64_t startTime; LOG4CXX_PTR_DEF(LoggingEvent);
}; LOG4CXX_LIST_DEF(LoggingEventList, LoggingEventPtr);
} }
} }
#if defined(_MSC_VER)
#pragma warning (pop)
#endif
#endif //_LOG4CXX_SPI_LOGGING_EVENT_H #endif //_LOG4CXX_SPI_LOGGING_EVENT_H
 End of changes. 43 change blocks. 
255 lines changed or deleted 241 lines changed or added


 loglog.h   loglog.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_LOG_LOG_H #ifndef _LOG4CXX_HELPERS_LOG_LOG_H
#define _LOG4CXX_HELPERS_LOG_LOG_H #define _LOG4CXX_HELPERS_LOG_LOG_H
#include <log4cxx/helpers/tchar.h> #include <log4cxx/logstring.h>
#include <log4cxx/helpers/exception.h> #include <log4cxx/helpers/mutex.h>
#include <exception>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
/** /**
This class used to output log statements from within the log This class used to output log statements from within the lo
4cxx package. g4cxx package.
<p>Log4cxx components cannot make log4cxx logging calls. How
ever, it is
sometimes useful for the user to learn about what log4cxx is
doing. You can enable log4cxx internal logging by calling th
e
<b>#setInternalDebugging</b> method.
<p>All log4cxx internal debug calls go to standard output
where as internal error messages are sent to
standard error output. All internal messages are prepended w
ith
the string "log4cxx: ".
*/
class LOG4CXX_EXPORT LogLog
{
public:
/**
Defining this value makes log4j print log4j-internal
debug
statements to <code>System.out</code>.
<p> The value of this string is <b>log4j.debug</b>. <p>Log4cxx components cannot make log4cxx logging calls. Ho
wever, it is
sometimes useful for the user to learn about what log4cxx i
s
doing. You can enable log4cxx internal logging by calling t
he
<b>#setInternalDebugging</b> method.
<p>Note that the search for all option names is case <p>All log4cxx internal debug calls go to standard output
sensitive. */ where as internal error messages are sent to
static String DEBUG_KEY; standard error output. All internal messages are prepended
with
the string "log4cxx: ".
*/
class LOG4CXX_EXPORT LogLog
{
private:
bool debugEnabled;
protected: /**
static bool debugEnabled; In quietMode not even errors generate any output.
*/
bool quietMode;
Mutex mutex;
LogLog();
LogLog(const LogLog&);
LogLog& operator=(const LogLog&);
static LogLog& getInstance();
/** public:
In quietMode not even errors generate any output. /**
*/ Allows to enable/disable log4cxx internal logging.
static bool quietMode; */
static void setInternalDebugging(bool enabled);
public: /**
/** This method is used to output log4cxx internal debu
Allows to enable/disable log4cxx internal logging. g
*/ statements. Output goes to the standard output.
static void setInternalDebugging(bool enabled); */
static void debug(const LogString& msg);
static void debug(const LogString& msg, const std::
exception& e);
/** /**
This method is used to output log4cxx internal debug This method is used to output log4cxx internal erro
statements. Output goes to the standard output. r
*/ statements. There is no way to disable error statem
static void debug(const String& msg); ents.
static void debug(const String& msg, Exception& e); Output goes to stderr.
*/
static void error(const LogString& msg);
static void error(const LogString& msg, const std::
exception& e);
/** /**
This method is used to output log4cxx internal error In quiet mode LogLog generates strictly no output,
statements. There is no way to disable error stateme not even
nts. for errors.
Output goes to stderr.
*/
static void error(const String& msg);
static void error(const String& msg, Exception& e);
/** @param quietMode <code>true</code> for no output.
In quite mode LogLog generates strictly no output, n */
ot even static void setQuietMode(bool quietMode);
for errors.
@param quietMode <code>true</code> for no output. /**
*/ This method is used to output log4cxx internal warn
static void setQuietMode(bool quietMode); ing
statements. There is no way to disable warning stat
ements.
Output goes to stderr.
*/
static void warn(const LogString& msg);
static void warn(const LogString& msg, const std::
exception& e);
/** private:
This method is used to output log4cxx internal warni static void emit(const LogString& msg);
ng static void emit(const std::exception& ex);
statements. There is no way to disable warning state };
ments. } // namespace helpers
Output goes to stderr. } // namespace log4cxx
*/
static void warn(const String& msg);
static void warn(const String& msg, Exception& e);
};
} // namespace helpers
}; // namespace log4cxx
#define LOGLOG_DEBUG(log) { \ #define LOGLOG_DEBUG(log) { \
StringBuffer oss; \ log4cxx::helpers::LogLog::debug(log) ; }
oss << log; \
log4cxx::helpers::LogLog::debug(oss.str()) ; }
#define LOGLOG_WARN(log) { \ #define LOGLOG_WARN(log) { \
StringBuffer oss; \ log4cxx::helpers::LogLog::warn(log) ; }
oss << log; \
log4cxx::helpers::LogLog::warn(oss.str()) ; }
#define LOGLOG_ERROR(log) { \ #define LOGLOG_ERROR(log) { \
StringBuffer oss; \ log4cxx::helpers::LogLog::warn(log); }
oss << log; \
log4cxx::helpers::LogLog::warn(oss.str()); }
#endif //_LOG4CXX_HELPERS_LOG_LOG_H #endif //_LOG4CXX_HELPERS_LOG_LOG_H
 End of changes. 16 change blocks. 
90 lines changed or deleted 89 lines changed or added


 logmanager.h   logmanager.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_LOG_MANAGER_H #ifndef _LOG4CXX_LOG_MANAGER_H
#define _LOG4CXX_LOG_MANAGER_H #define _LOG4CXX_LOG_MANAGER_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/spi/repositoryselector.h> #include <log4cxx/spi/repositoryselector.h>
namespace log4cxx namespace log4cxx
{ {
class Logger; class Logger;
typedef helpers::ObjectPtrT<Logger> LoggerPtr; typedef helpers::ObjectPtrT<Logger> LoggerPtr;
typedef std::vector<LoggerPtr> LoggerList; typedef std::vector<LoggerPtr> LoggerList;
namespace spi namespace spi {
{ class LoggerFactory;
class LoggerFactory; typedef helpers::ObjectPtrT<LoggerFactory> LoggerFactoryPtr;
typedef helpers::ObjectPtrT<LoggerFactory> LoggerFactoryPtr;
} }
/** /**
* Use the <code>LogManager</code> class to retreive Logger * Use the <code>LogManager</code> class to retreive Logger
* instances or to operate on the current {@link spi::LoggerRepository * instances or to operate on the current
* LoggerRepository}. When the <code>LogManager</code> class is loade * {@link log4cxx::spi::LoggerRepository LoggerRepository}.
d * When the <code>LogManager</code> class is loaded
* into memory the default initialization procedure is inititated. * into memory the default initialization procedure is inititated.
*/ */
class LOG4CXX_EXPORT LogManager class LOG4CXX_EXPORT LogManager
{ {
private: private:
static void * guard; static void * guard;
static spi::RepositorySelectorPtr repositorySelector; static spi::RepositorySelectorPtr& getRepositorySelector();
public: public:
/** /**
Sets <code>LoggerFactory</code> but only if the correct Sets <code>LoggerFactory</code> but only if the correct
<em>guard</em> is passed as parameter. <em>guard</em> is passed as parameter.
<p>Initally the guard is null. If the guard is <p>Initally the guard is null. If the guard is
<code>null</code>, then invoking this method sets the logger <code>null</code>, then invoking this method sets the logger
factory and the guard. Following invocations will throw a {@link factory and the guard. Following invocations will throw a {@link
helpers::IllegalArgumentException IllegalArgumentException}, helpers::IllegalArgumentException IllegalArgumentException},
unless the previously set <code>guard</code> is passed as th unless the previously set <code>guard</code> is passed as t
e second he second
parameter. parameter.
<p>This allows a high-level component to set the {@link <p>This allows a high-level component to set the {@link
spi::RepositorySelector RepositorySelector} used by the spi::RepositorySelector RepositorySelector} used by the
<code>LogManager</code>. <code>LogManager</code>.
*/ */
static void setRepositorySelector(spi::RepositorySelectorPtr select or, static void setRepositorySelector(spi::RepositorySelectorPtr select or,
void * guard); void * guard);
static spi::LoggerRepositoryPtr& getLoggerRepository(); static spi::LoggerRepositoryPtr& getLoggerRepository();
/** /**
Retrieve the appropriate root logger. Retrieve the appropriate root logger.
*/ */
static LoggerPtr getRootLogger(); static LoggerPtr getRootLogger();
/** /**
Retrieve the appropriate Logger instance. Retrieve the appropriate Logger instance.
* @param name logger name in current encoding.
* @return logger.
*/ */
static LoggerPtr getLogger(const String& name); static LoggerPtr getLogger(const std::string& name);
/**
Retrieve the appropriate Logger instance.
* @param name logger name in current encoding.
* @param factory logger factory.
* @return logger.
*/
static LoggerPtr getLogger(const std::string& name,
const spi::LoggerFactoryPtr& factory);
/**
* Determines if logger name exists in the hierarchy.
* @param name logger name.
* @return true if logger exists.
*/
static LoggerPtr exists(const std::string& name);
#if LOG4CXX_WCHAR_T_API
/**
Retrieve the appropriate Logger instance.
* @param name logger name.
* @return logger.
*/
static LoggerPtr getLogger(const std::wstring& name);
/**
Retrieve the appropriate Logger instance.
* @param name logger name.
* @param factory logger factory.
* @return logger.
*/
static LoggerPtr getLogger(const std::wstring& name,
const spi::LoggerFactoryPtr& factory);
/**
* Determines if logger name exists in the hierarchy.
* @param name logger name.
* @return true if logger exists.
*/
static LoggerPtr exists(const std::wstring& name);
#endif
#if LOG4CXX_UNICHAR_API
/**
Retrieve the appropriate Logger instance.
* @param name logger name.
* @return logger.
*/
static LoggerPtr getLogger(const std::basic_string<UniChar>& name);
/**
Retrieve the appropriate Logger instance.
* @param name logger name.
* @param factory logger factory.
* @return logger.
*/
static LoggerPtr getLogger(const std::basic_string<UniChar>& name,
const spi::LoggerFactoryPtr& factory);
/**
* Determines if logger name exists in the hierarchy.
* @param name logger name.
* @return true if logger exists.
*/
static LoggerPtr exists(const std::basic_string<UniChar>& name);
#endif
#if LOG4CXX_CFSTRING_API
/**
Retrieve the appropriate Logger instance.
* @param name logger name.
* @return logger.
*/
static LoggerPtr getLogger(const CFStringRef& name);
/**
Retrieve the appropriate Logger instance.
* @param name logger name.
* @param factory logger factory.
* @return logger.
*/
static LoggerPtr getLogger(const CFStringRef& name,
const spi::LoggerFactoryPtr& factory);
/**
* Determines if logger name exists in the hierarchy.
* @param name logger name.
* @return true if logger exists.
*/
static LoggerPtr exists(const CFStringRef& name);
#endif
/** /**
Retrieve the appropriate Logger instance. Retrieve the appropriate Logger instance.
* @param name logger name.
* @return logger.
*/ */
static LoggerPtr getLogger(const String& name, static LoggerPtr getLoggerLS(const LogString& name);
spi::LoggerFactoryPtr factory); /**
Retrieve the appropriate Logger instance.
* @param name logger name.
* @param factory logger factory.
* @return logger.
*/
static LoggerPtr getLoggerLS(const LogString& name,
const spi::LoggerFactoryPtr& factory);
static LoggerPtr exists(const String& name); /**
* Determines if logger name exists in the hierarchy.
* @param name logger name.
* @return true if logger exists.
*/
static LoggerPtr existsLS(const LogString& name);
static LoggerList getCurrentLoggers(); static LoggerList getCurrentLoggers();
/** /**
Safely close and remove all appenders in all loggers includi Safely close and remove all appenders in all loggers including
ng the root logger.
the root logger. */
*/ static void shutdown();
static void shutdown();
/** /**
Reset all values contained in this current {@link Reset all values contained in this current {@link
spi::LoggerRepository LoggerRepository} to their default. spi::LoggerRepository LoggerRepository} to their default.
*/ */
static void resetConfiguration(); static void resetConfiguration();
}; // class LogManager }; // class LogManager
} // namespace log4cxx } // namespace log4cxx
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#endif //_LOG4CXX_LOG_MANAGER_H #endif //_LOG4CXX_LOG_MANAGER_H
 End of changes. 17 change blocks. 
34 lines changed or deleted 138 lines changed or added


 mdc.h   mdc.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_MDC_H #ifndef _LOG4CXX_MDC_H
#define _LOG4CXX_MDC_H #define _LOG4CXX_MDC_H
#include <log4cxx/helpers/tchar.h> #if defined(_MSC_VER)
#include <log4cxx/helpers/threadspecificdata.h> #pragma warning (push)
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/log4cxx.h>
#include <log4cxx/logstring.h>
#include <map> #include <map>
namespace log4cxx namespace log4cxx
{ {
/** /**
The MDC class is similar to the {@link NDC} class except that it is The MDC class is similar to the {@link log4cxx::NDC NDC} class exce
based on a map instead of a stack. It provides <em>mapped pt that it is
diagnostic contexts</em>. A <em>Mapped Diagnostic Context</em>, or based on a map instead of a stack. It provides <em>mapped
MDC in short, is an instrument for distinguishing interleaved log diagnostic contexts</em>. A <em>Mapped Diagnostic Context</em>, or
output from different sources. Log output is typically interleaved MDC in short, is an instrument for distinguishing interleaved log
when a server handles multiple clients near-simultaneously. output from different sources. Log output is typically interleaved
when a server handles multiple clients near-simultaneously.
<p><b><em>The MDC is managed on a per thread basis</em></b>. A
child thread automatically inherits a <em>copy</em> of the mapped
diagnostic context of its parent.
<p>The MDC class requires JDK 1.2 or above. Under JDK 1.1 the MDC
will always return empty values but otherwise will not affect or
harm your application.
*/
class LOG4CXX_EXPORT MDC
{
public:
/** String to string stl mp
*/
typedef std::map<String, String> Map;
private:
static Map * getCurrentThreadMap();
static void setCurrentThreadMap(Map * map);
static helpers::ThreadSpecificData threadSpecificData; <p><b><em>The MDC is managed on a per thread basis</em></b>. A
const String& key; child thread automatically inherits a <em>copy</em> of the mapped
diagnostic context of its parent.
public: */
MDC(const String& key, const String& value); class LOG4CXX_EXPORT MDC
~MDC(); {
public:
/** String to string stl map.
*/
typedef std::map<LogString, LogString> Map;
/** /**
* Put a context value (the <code>o</code> parameter) as iden * Places a key/value pair in the MDC for the current thre
tified ad
* with the <code>key</code> parameter into the current threa * which will be removed during the corresponding destru
d's ctor. Both
* context map. * construction and destruction are expected to be on th
* e same thread.
* <p>If the current thread does not have a context map it is * @param key key
* created as a side effect. * @param value value.
* */ */
static void put(const String& key, const String& value); MDC(const std::string& key, const std::string& value);
~MDC();
/** /**
* Get the context identified by the <code>key</code> paramet * Put a context value (the <code>o</code> parameter) as ide
er. ntified
* * with the <code>key</code> parameter into the current thre
* <p>This method has no side effects. ad's
* */ * context map.
static String get(const String& key); *
* <p>If the current thread does not have a context map it i
s
* created as a side effect.
* @param key key
* @param value value.
*/
static void put(const std::string& key, const std::string&
value);
/**
* Put a context value (the <code>o</code> parameter) as ide
ntified
* with the <code>key</code> parameter into the current thre
ad's
* context map.
*
* <p>If the current thread does not have a context map it i
s
* created as a side effect.
* */
static void putLS(const LogString& key, const LogString& va
lue);
/** /**
* Remove the the context identified by the <code>key</code> * Get the context identified by the <code>key</code> parame
* parameter. */ ter.
static String remove(const String& key); *
* <p>This method has no side effects.
* @param key key.
* @return value for key, empty if not set.
* */
static std::string get(const std::string& key);
/**
* Gets the context identified by the <code>key</code> par
ameter.
* @param key context key.
* @param dest destination to which value is appended.
* @return true if key has associated value.
*/
static bool get(const LogString& key, LogString& dest);
/** /**
* Clear all entries in the MDC. * Remove the the context identified by the <code>key</code>
*/ * parameter.
static void clear(); * @param key key.
* @return value if key had been set, empty if not.
*/
static std::string remove(const std::string& key);
#if LOG4CXX_WCHAR_T_API
/**
* Places a key/value pair in the MDC for the current thre
ad
* which will be removed during the corresponding destru
ctor. Both
* construction and destruction are expected to be on th
e same thread.
* @param key key
* @param value value.
*/
MDC(const std::wstring& key, const std::wstring& value);
/**
* Put a context value (the <code>o</code> parameter) as ide
ntified
* with the <code>key</code> parameter into the current thre
ad's
* context map.
*
* <p>If the current thread does not have a context map it i
s
* created as a side effect.
* @param key key
* @param value value.
*/
static void put(const std::wstring& key, const std::wstring
& value);
/**
* Get the context identified by the <code>key</code> parame
ter.
*
* <p>This method has no side effects.
* @param key key.
* @return value for key, empty if not set.
* */
static std::wstring get(const std::wstring& key);
/**
* Remove the the context identified by the <code>key</code>
* parameter.
* @param key key.
* @return value if key had been set, empty if not.
*/
static std::wstring remove(const std::wstring& key);
#endif
#if LOG4CXX_UNICHAR_API
/**
* Places a key/value pair in the MDC for the current thre
ad
* which will be removed during the corresponding destru
ctor. Both
* construction and destruction are expected to be on th
e same thread.
* @param key key
* @param value value.
*/
MDC(const std::basic_string<UniChar>& key, const std::basic
_string<UniChar>& value);
/**
* Put a context value (the <code>o</code> parameter) as ide
ntified
* with the <code>key</code> parameter into the current thre
ad's
* context map.
*
* <p>If the current thread does not have a context map it i
s
* created as a side effect.
* @param key key
* @param value value.
*/
static void put(const std::basic_string<UniChar>& key, cons
t std::basic_string<UniChar>& value);
/**
* Get the context identified by the <code>key</code> parame
ter.
*
* <p>This method has no side effects.
* @param key key.
* @return value for key, empty if not set.
* */
static std::basic_string<UniChar> get(const std::basic_stri
ng<UniChar>& key);
/**
* Remove the the context identified by the <code>key</code>
* parameter.
* @param key key.
* @return value if key had been set, empty if not.
*/
static std::basic_string<UniChar> remove(const std::basic_s
tring<UniChar>& key);
#endif
#if LOG4CXX_CFSTRING_API
/**
* Places a key/value pair in the MDC for the current thre
ad
* which will be removed during the corresponding destru
ctor. Both
* construction and destruction are expected to be on th
e same thread.
* @param key key
* @param value value.
*/
MDC(const CFStringRef& key, const CFStringRef& value);
/**
* Put a context value (the <code>o</code> parameter) as ide
ntified
* with the <code>key</code> parameter into the current thre
ad's
* context map.
*
* <p>If the current thread does not have a context map it i
s
* created as a side effect.
* @param key key
* @param value value.
*/
static void put(const CFStringRef& key, const CFStringRef&
value);
/**
* Get the context identified by the <code>key</code> parame
ter.
*
* <p>This method has no side effects.
* @param key key.
* @return value for key, empty if not set.
* */
static CFStringRef get(const CFStringRef& key);
/**
* Remove the the context identified by the <code>key</code>
* parameter.
* @param key key.
* @return value if key had been set, empty if not.
*/
static CFStringRef remove(const CFStringRef& key);
#endif
/**
* Remove the the context identified by the <code>key</code>
* parameter.
* @param key key.
* @param prevValue buffer to which previous value is append
ed.
* @return true if key existed in MDC.
*/
static bool remove(const LogString& key, LogString& prevVal
ue);
/** /**
* Get the current thread's MDC as a Map. This method is * Clear all entries in the MDC.
* intended to be used internally. */
* */ static void clear();
static const Map getContext();
static void setContext(Map& map); private:
}; // class MDC; MDC(const MDC&);
MDC& operator=(const MDC&);
LogString key;
}; // class MDC;
} // namespace log4cxx } // namespace log4cxx
#if defined(_MSC_VER)
#pragma warning (pop)
#endif
#endif // _LOG4CXX_MDC_H #endif // _LOG4CXX_MDC_H
 End of changes. 12 change blocks. 
71 lines changed or deleted 253 lines changed or added


 mutex.h   mutex.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_MUTEX_H #ifndef _LOG4CXX_HELPERS_MUTEX_H
#define _LOG4CXX_HELPERS_MUTEX_H #define _LOG4CXX_HELPERS_MUTEX_H
#include <log4cxx/config.h> #include <log4cxx/log4cxx.h>
#include <log4cxx/helpers/exception.h>
#ifdef HAVE_PTHREAD extern "C" {
#include <pthread.h> struct apr_thread_mutex_t;
#endif struct apr_pool_t;
}
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class LOG4CXX_EXPORT MutexException : public Exception class Pool;
{
};
class Condition;
class LOG4CXX_EXPORT Mutex class LOG4CXX_EXPORT Mutex
{ {
friend class Condition; public:
public: Mutex(log4cxx::helpers::Pool& p);
Mutex(); Mutex(apr_pool_t* p);
~Mutex(); ~Mutex();
void lock(); apr_thread_mutex_t* getAPRMutex() const;
void unlock();
protected: private:
#ifdef HAVE_PTHREAD Mutex(const Mutex&);
pthread_mutex_t mutex; Mutex& operator=(const Mutex&);
#elif defined(HAVE_MS_THREAD) apr_thread_mutex_t* mutex;
void * mutex; };
#endif } // namespace helpers
}; } // namespace log4cxx
} // namespace helpers
};// namespace log4cxx
#endif //_LOG4CXX_HELPERS_MUTEX_H #endif //_LOG4CXX_HELPERS_MUTEX_H
 End of changes. 6 change blocks. 
34 lines changed or deleted 28 lines changed or added


 ndc.h   ndc.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_NDC_H #ifndef _LOG4CXX_NDC_H
#define _LOG4CXX_NDC_H #define _LOG4CXX_NDC_H
#include <log4cxx/helpers/tchar.h> #if defined(_MSC_VER)
#include <log4cxx/helpers/threadspecificdata.h> #pragma warning ( push )
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/log4cxx.h>
#include <log4cxx/logstring.h>
#include <stack> #include <stack>
namespace log4cxx namespace log4cxx
{ {
class DiagnosticContext; /**
typedef std::stack<DiagnosticContext> Stack; the ndc class implements <i>nested diagnostic contexts</i> as
defined by neil harrison in the article "patterns for logging
diagnostic messages" part of the book "<i>pattern languages of
program design 3</i>" edited by martin et al.
/** <p>a nested diagnostic context, or ndc in short, is an instrument
the ndc class implements <i>nested diagnostic contexts</i> as to distinguish interleaved log output from different sources. log
defined by neil harrison in the article "patterns for logging output is typically interleaved when a server handles multiple
diagnostic messages" part of the book "<i>pattern languages of clients near-simultaneously.
program design 3</i>" edited by martin et al.
<p>a nested diagnostic context, or ndc in short, is an instrument <p>interleaved log output can still be meaningful if each log entry
to distinguish interleaved log output from different sources. log from different contexts had a distinctive stamp. this is where ndcs
output is typically interleaved when a server handles multiple come into play.
clients near-simultaneously.
<p>interleaved log output can still be meaningful if each log entry <p><em><b>note that ndcs are managed on a per thread
from different contexts had a distinctive stamp. this is where ndcs basis</b></em>. ndc operations such as #push,
come into play. #pop, #clear and #getDepth
affect the ndc of the <em>current</em> thread only. ndcs of other
threads remain unaffected.
<p><em><b>note that ndcs are managed on a per thread <p>for example, a servlet can build a per client request ndc
basis</b></em>. ndc operations such as #push, consisting the clients host name and other information contained in
#pop, #clear and #getDepth the the request. <em>cookies</em> are another source of distinctive
affect the ndc of the <em>current</em> thread only. ndcs of other information. to build an ndc one uses the #push
threads remain unaffected. operation. simply put,
<p>for example, a servlet can build a per client request ndc <p><ul>
consisting the clients host name and other information contained in <li>contexts can be nested.
the the request. <em>cookies</em> are another source of distinctive
information. to build an ndc one uses the #push
operation. simply put,
<p><ul> <p><li>when entering a context, call <code>ndc.push</code>. as a
<li>contexts can be nested. side effect, if there is no nested diagnostic context for the
current thread, this method will create it.
<p><li>when entering a context, call <code>ndc.push</code>. as a <p><li>when leaving a context, call <code>ndc.pop</code>.
side effect, if there is no nested diagnostic context for the
current thread, this method will create it.
<p><li>when leaving a context, call <code>ndc.pop</code>. <p><li><b>when exiting a thread make sure to call #remove
</b>.
</ul>
<p><li><b>when exiting a thread make sure to call #remove <p>there is no penalty for forgetting to match each
</b>. <code>push</code> operation with a corresponding <code>pop</code>,
</ul> except the obvious mismatch between the real application context
and the context set in the ndc.
<p>there is no penalty for forgetting to match each <p>if configured to do so, PatternLayout and
<code>push</code> operation with a corresponding <code>pop</code>, TTCCLayout instances automatically retrieve the nested diagnostic
except the obvious mismatch between the real application context context for the current thread without any user intervention.
and the context set in the ndc. hence, even if a servlet is serving multiple clients
simultaneously, the logs emanating from the same code (belonging to
the same logger) can still be distinguished because each client
request will have a different ndc tag.
<p>if configured to do so, PatternLayout and <p>heavy duty systems should call the #remove method when
TTCCLayout instances automatically retrieve the nested diagnostic leaving the run method of a thread. this ensures that the memory
context for the current thread without any user intervention. used by the thread can be freed by the java garbage
hence, even if a servlet is serving multiple clients collector. there is a mechanism to lazily remove references to dead
simultaneously, the logs emanating from the same code (belonging to threads. in practice, this means that you can be a little sloppy
the same category) can still be distinguished because each client and sometimes forget to call #remove before exiting a
request will have a different ndc tag. thread.
<p>heavy duty systems should call the #remove method when */
leaving the run method of a thread. this ensures that the memory class LOG4CXX_EXPORT NDC
used by the thread can be freed by the java garbage {
collector. there is a mechanism to lazily remove references to dead public:
threads. in practice, this means that you can be a little sloppy /**
and sometimes forget to call #remove before exiting a * Pair of Message and FullMessage.
thread. */
typedef std::pair<LogString, LogString> DiagnosticContext;
typedef std::stack<DiagnosticContext> Stack;
<p>a thread may inherit the nested diagnostic context of another /**
(possibly parent) thread using the #inherit Creates a nested diagnostic context.
method. a thread may obtain a copy of its ndc with the Since java performs no automatic cleanup of objects when a
#clonestack method and pass the reference to any other scope is left, in log4j push() and pop() must be used
thread, in particular to a child. to manage the NDC. For convenience, log4cxx provides
*/ an NDC constructor and destructor which simply call the pu
class LOG4CXX_EXPORT NDC sh() and
{ pop() methods, allowing for automatic cleanup when the cur
private: rent
class DiagnosticContext scope ends.
{
public:
String fullMessage;
String message;
DiagnosticContext(const String& message, @param message The new diagnostic context information.
const DiagnosticContext * parent); @see The #push method.
}; */
NDC(const std::string& message);
typedef std::stack<DiagnosticContext> Stack; /**
Removes the topmost element from the NDC stack.
static Stack * getCurrentThreadStack(); @see The #pop method.
static void setCurrentThreadStack(Stack * stack); */
~NDC();
static helpers::ThreadSpecificData threadSpecificData; /**
Clear any nested diagnostic information if any. This method
is
useful in cases where the same thread can be potentially us
ed
over and over in different unrelated contexts.
*/
static void clear();
public: /**
NDC(const String& message); Clone the diagnostic context for the current thread.
~NDC(); <p>Internally a diagnostic context is represented as a
stack. A
given thread can supply the stack (i.e. diagnostic cont
ext) to a
child thread so that the child can inherit the parent t
hread's
diagnostic context.
<p>The child thread uses the #inherit method to
inherit the parent's diagnostic context.
<p>If not passed to #inherit, returned stack should be
deleted by caller.
@return Stack A clone of the current thread's diagnosti
c context, will not be null.
*/
static Stack * cloneStack();
/** /**
Clear any nested diagnostic information if any. This method Inherit the diagnostic context of another thread.
is <p>The parent thread can obtain a reference to its diagnost
useful in cases where the same thread can be potentially use ic
d context using the #cloneStack method. It should
over and over in different unrelated contexts. communicate this information to its child so that it may in
<p>This method is equivalent to calling the #setMaxDepth herit
method with a zero <code>maxDepth</code> argument. the parent's diagnostic context.
*/ <p>The parent's diagnostic context is cloned before being
static void clear(); inherited. In other words, once inherited, the two diagnost
ic
contexts can be managed independently.
@param stack The diagnostic context of the parent thread,
will be deleted during call. If NULL, NDC will not be
modified.
*/
static void inherit(Stack * stack);
/** /**
Clone the diagnostic context for the current thread. * Get the current value of the NDC of the
<p>Internally a diagnostic context is represented as a stack * currrent thread.
. A * @param dest destination to which to append content of NDC
given thread can supply the stack (i.e. diagnostic context) .
to a * @return true if NDC is set.
child thread so that the child can inherit the parent thread */
's static bool get(LogString& dest);
diagnostic context.
<p>The child thread uses the #inherit method to
inherit the parent's diagnostic context.
@return Stack A clone of the current thread's diagnostic co
ntext.
*/
static Stack * cloneStack();
/** /**
Inherit the diagnostic context of another thread. Get the current nesting depth of this diagnostic context.
<p>The parent thread can obtain a reference to its diagnosti */
c static int getDepth();
context using the #cloneStack method. It should
communicate this information to its child so that it may inh
erit
the parent's diagnostic context.
<p>The parent's diagnostic context is cloned before being
inherited. In other words, once inherited, the two diagnosti
c
contexts can be managed independently.
<p>In java, a child thread cannot obtain a reference to its
parent, unless it is directly handed the reference. Conseque
ntly,
there is no client-transparent way of inheriting diagnostic
contexts. Do you know any solution to this problem?
@param stack The diagnostic context of the parent thread.
*/
static void inherit(Stack * stack);
/** /**
<b>Never use this method directly, use the * Tests if the NDC is empty.
{@link spi::LoggingEvent#getNDC LoggingEvent::getNDC} */
method instead.</b> static bool empty();
*/
static String get();
/** /**
Get the current nesting depth of this diagnostic context. Pop top value off stack.
*/ @return top value.
static int getDepth(); */
static LogString pop();
/**
Pop top value off stack.
@param buf to which top value is appended.
@return true if NDC contained at least one value.
*/
static bool pop(std::string& buf);
/** /**
Clients should call this method before leaving a diagnostic Looks at the last diagnostic context at the top of this NDC
context. without removing it.
<p>The returned value is the value that was pushed last. If <p>The returned value is the value that was pushed last. If
no no
context is available, then the empty string "" is returned. context is available, then the empty string "" is returned.
@return String The innermost diagnostic context. @return String The innermost diagnostic context.
*/ */
static String pop(); static LogString peek();
/**
Get top value without removing value.
@param buf to which top value is appended.
@return true if NDC contained at least one value.
*/
static bool peek(std::string& buf);
/** /**
Looks at the last diagnostic context at the top of this NDC Push new diagnostic context information for the current thr
without removing it. ead.
<p>The returned value is the value that was pushed last. If <p>The contents of the <code>message</code> parameter is
no determined solely by the client.
context is available, then the empty string "" is returned. @param message The new diagnostic context information.
@return String The innermost diagnostic context. */
*/ static void push(const std::string& message);
static String peek(); /**
Push new diagnostic context information for the current thr
ead.
<p>The contents of the <code>message</code> parameter is
determined solely by the client.
@param message The new diagnostic context information.
*/
static void pushLS(const LogString& message);
/** /**
Push new diagnostic context information for the current thre Remove the diagnostic context for this thread.
ad. <p>Each thread that created a diagnostic context by calling
<p>The contents of the <code>message</code> parameter is #push should call this method before exiting. Otherwise,
determined solely by the client. the memory used by the <b>thread</b> cannot be reclaimed by
@param message The new diagnostic context information. the
*/ VM.
static void push(const String& message); <p>As this is such an important problem in heavy duty syste
ms and
because it is difficult to always guarantee that the remove
method is called before exiting a thread, this method has b
een
augmented to lazily remove references to dead threads. In
practice, this means that you can be a little sloppy and
occasionally forget to call #remove before exiting a
thread. However, you must call <code>remove</code> sometime
. If
you never call it, then your application is sure to run out
of
memory.
*/
static void remove();
/** #if LOG4CXX_WCHAR_T_API
Remove the diagnostic context for this thread. /**
<p>Each thread that created a diagnostic context by calling Creates a nested diagnostic context.
#push should call this method before exiting. Otherwise, Since java performs no automatic cleanup of objects when a
the memory used by the <b>thread</b> cannot be reclaimed by scope is left, in log4j push() and pop() must be used
the to manage the NDC. For convenience, log4cxx provides
VM. an NDC constructor and destructor which simply call the pu
<p>As this is such an important problem in heavy duty system sh() and
s and pop() methods, allowing for automatic cleanup when the cur
because it is difficult to always guarantee that the remove rent
method is called before exiting a thread, this method has be scope ends.
en
augmented to lazily remove references to dead threads. In @param message The new diagnostic context information.
practice, this means that you can be a little sloppy and @see The #push method.
occasionally forget to call #remove before exiting a */
thread. However, you must call <code>remove</code> sometime. NDC(const std::wstring& message);
If /**
you never call it, then your application is sure to run out Push new diagnostic context information for the current thr
of ead.
memory. <p>The contents of the <code>message</code> parameter is
*/ determined solely by the client.
static void remove(); @param message The new diagnostic context information.
}; // class NDC; */
static void push(const std::wstring& message);
/**
* Appends the current NDC content to the provided string
.
* @param dst destination.
* @return true if NDC value set.
*/
static bool peek(std::wstring& dst);
/**
* Appends the current NDC content to the provided string
and removes the value from the NDC.
* @param dst destination.
* @return true if NDC value set.
*/
static bool pop(std::wstring& dst);
#endif
#if LOG4CXX_UNICHAR_API
/**
Creates a nested diagnostic context.
Since java performs no automatic cleanup of objects when a
scope is left, in log4j push() and pop() must be used
to manage the NDC. For convenience, log4cxx provides
an NDC constructor and destructor which simply call the pu
sh() and
pop() methods, allowing for automatic cleanup when the cur
rent
scope ends.
@param message The new diagnostic context information.
@see The #push method.
*/
NDC(const std::basic_string<UniChar>& message);
/**
Push new diagnostic context information for the current thr
ead.
<p>The contents of the <code>message</code> parameter is
determined solely by the client.
@param message The new diagnostic context information.
*/
static void push(const std::basic_string<UniChar>& message)
;
/**
* Appends the current NDC content to the provided string
.
* @param dst destination.
* @return true if NDC value set.
*/
static bool peek(std::basic_string<UniChar>& dst);
/**
* Appends the current NDC content to the provided string
and removes the value from the NDC.
* @param dst destination.
* @return true if NDC value set.
*/
static bool pop(std::basic_string<UniChar>& dst);
#endif
#if LOG4CXX_CFSTRING_API
/**
Creates a nested diagnostic context.
Since java performs no automatic cleanup of objects when a
scope is left, in log4j push() and pop() must be used
to manage the NDC. For convenience, log4cxx provides
an NDC constructor and destructor which simply call the pu
sh() and
pop() methods, allowing for automatic cleanup when the cur
rent
scope ends.
@param message The new diagnostic context information.
@see The #push method.
*/
NDC(const CFStringRef& message);
/**
Push new diagnostic context information for the current thr
ead.
<p>The contents of the <code>message</code> parameter is
determined solely by the client.
@param message The new diagnostic context information.
*/
static void push(const CFStringRef& message);
/**
* Gets the current NDC value.
* @param dst destination.
* @return true if NDC value set.
*/
static bool peek(CFStringRef& dst);
/**
* Gets and removes the current NDC value.
* @param dst destination.
* @return true if NDC value set.
*/
static bool pop(CFStringRef& dst);
#endif
private:
NDC(const NDC&);
NDC& operator=(const NDC&);
static LogString& getMessage(DiagnosticContext& ctx);
static LogString& getFullMessage(DiagnosticContext& ctx);
}; // class NDC;
} // namespace log4cxx } // namespace log4cxx
#if defined(_MSC_VER)
#pragma warning (pop)
#endif
#endif // _LOG4CXX_NDC_H #endif // _LOG4CXX_NDC_H
 End of changes. 31 change blocks. 
186 lines changed or deleted 339 lines changed or added


 nteventlogappender.h   nteventlogappender.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_NT_EVENT_LOG_APPENDER_HEADER_ #ifndef _LOG4CXX_NT_EVENT_LOG_APPENDER_HEADER_
#define _LOG4CXX_NT_EVENT_LOG_APPENDER_HEADER_ #define _LOG4CXX_NT_EVENT_LOG_APPENDER_HEADER_
#include <log4cxx/appenderskeleton.h> #include <log4cxx/appenderskeleton.h>
typedef void * HANDLE;
struct HKEY__;
struct _SID;
typedef struct HKEY__ *HKEY;
typedef struct _SID SID;
namespace log4cxx namespace log4cxx
{ {
namespace nt namespace nt
{ {
/** /**
* Appends log events to NT EventLog. * Appends log events to NT EventLog.
*/ */
class LOG4CXX_EXPORT NTEventLogAppender : public AppenderSke class LOG4CXX_EXPORT NTEventLogAppender : public AppenderSk
leton eleton
{ {
public: public:
DECLARE_LOG4CXX_OBJECT(NTEventLogAppender) DECLARE_LOG4CXX_OBJECT(NTEventLogAppender)
BEGIN_LOG4CXX_CAST_MAP() BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(NTEventLogAppender) LOG4CXX_CAST_ENTRY(NTEventLogAppender)
LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton) LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
END_LOG4CXX_CAST_MAP() END_LOG4CXX_CAST_MAP()
NTEventLogAppender(); NTEventLogAppender();
NTEventLogAppender(const String& server, const Strin NTEventLogAppender(const LogString& server, const L
g& log, ogString& log,
const String& source, const LayoutPtr& layou const LogString& source, const LayoutPtr& l
t); ayout);
virtual ~NTEventLogAppender(); virtual ~NTEventLogAppender();
virtual void activateOptions(); virtual void activateOptions(log4cxx::helpers::Pool
virtual void close(); & p);
virtual void setOption(const String& option, const S virtual void close();
tring& value); virtual void setOption(const LogString& option, con
st LogString& value);
/** /**
* The SocketAppender does not use a layout. Hence, this meth * The SocketAppender does not use a layout. Hence,
od this method
* returns <code>false</code>. * returns <code>false</code>.
* */ *
bool requiresLayout() const */
{ return true; } bool requiresLayout() const
{ return true; }
void setSource(const String& source) void setSource(const LogString& source)
{ this->source = source; } { this->source.assign(source); }
const String& getSource() const const LogString& getSource() const
{ return source; } { return source; }
void setLog(const String& log) void setLog(const LogString& log)
{ this->log = log; } { this->log.assign(log); }
const String& getLog() const const LogString& getLog() const
{ return log; } { return log; }
void setServer(const String& server) void setServer(const LogString& server)
{ this->server = server; } { this->server.assign(server); }
const String& getServer() const const LogString& getServer() const
{ return server; } { return server; }
protected: protected:
virtual void append(const spi::LoggingEventPtr& even //
t); // these typedef are proxies for the real Win32 d
HKEY regGetKey(const String& subkey, unsigned long * efinitions
disposition); // and need to be cast to the global definition
void regSetString(HKEY hkey, const String& name, con s before
st String& value); // use with a Win32 API call
void regSetDword(HKEY hkey, const String& name, unsi typedef void SID;
gned long value); typedef void* HANDLE;
unsigned short getEventType(const spi::LoggingEventP
tr& event); virtual void append(const spi::LoggingEventPtr& eve
unsigned short getEventCategory(const spi::LoggingEv nt, log4cxx::helpers::Pool& p);
entPtr& event); static unsigned short getEventType(const spi::Loggi
/* ngEventPtr& event);
* Add this source with appropriate configuration ke static unsigned short getEventCategory(const spi::L
ys to the registry. oggingEventPtr& event);
*/ /*
void addRegistryInfo(); * Add this source with appropriate configuration k
eys to the registry.
*/
void addRegistryInfo();
// Data
LogString server;
LogString log;
LogString source;
HANDLE hEventLog;
SID * pCurrentUserSID;
static LogString getErrorString(const LogString& fu
nction);
private:
NTEventLogAppender(const NTEventLogAppender&);
NTEventLogAppender& operator=(const NTEventLogAppen
der&);
}; // class NTEventLogAppender
LOG4CXX_PTR_DEF(NTEventLogAppender);
// Data
String server;
String log;
String source;
HANDLE hEventLog;
SID * pCurrentUserSID;
}; // class NTEventLogAppender
} // namespace nt } // namespace nt
}; // namespace log4cxx } // namespace log4cxx
#endif //_LOG4CXX_NT_EVENT_LOG_APPENDER_HEADER_ #endif //_LOG4CXX_NT_EVENT_LOG_APPENDER_HEADER_
 End of changes. 16 change blocks. 
80 lines changed or deleted 90 lines changed or added


 object.h   object.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_OBJECT_H #ifndef _LOG4CXX_HELPERS_OBJECT_H
#define _LOG4CXX_HELPERS_OBJECT_H #define _LOG4CXX_HELPERS_OBJECT_H
#include <log4cxx/helpers/tchar.h> #include <log4cxx/logstring.h>
#include <log4cxx/helpers/class.h> #include <log4cxx/helpers/class.h>
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/classregistration.h>
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)\ #define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)\
public:\ public:\
class Class##object : public helpers::Class\ class Clazz##object : public helpers::Class\
{\ {\
public:\ public:\
Class##object() : helpers::Class(_T(#object)) {}\ Clazz##object() : helpers::Class() {}\
virtual ~Clazz##object() {}\
virtual log4cxx::LogString getName() const { return LOG4CXX_STR(#ob
ject); } \
};\ };\
virtual const helpers::Class& getClass() const;\ virtual const helpers::Class& getClass() const;\
static const helpers::Class& getStaticClass();\ static const helpers::Class& getStaticClass(); \
static Class##object theClass##object; static const log4cxx::helpers::ClassRegistration& registerClass();
#define DECLARE_LOG4CXX_OBJECT(object)\ #define DECLARE_LOG4CXX_OBJECT(object)\
public:\ public:\
class Class##object : public helpers::Class\ class Clazz##object : public helpers::Class\
{\ {\
public:\ public:\
Class##object() : helpers::Class(_T(#object)) {}\ Clazz##object() : helpers::Class() {}\
virtual helpers::ObjectPtr newInstance() const\ virtual ~Clazz##object() {}\
{\ virtual log4cxx::LogString getName() const { return LOG4CXX_STR(#ob
return new object();\ ject); } \
}\ virtual helpers::ObjectPtr newInstance() const\
{\
return new object();\
}\
};\ };\
virtual const helpers::Class& getClass() const;\ virtual const helpers::Class& getClass() const;\
static const helpers::Class& getStaticClass();\ static const helpers::Class& getStaticClass(); \
static Class##object theClass##object; static const log4cxx::helpers::ClassRegistration& registerClass();
#define DECLARE_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(object, class)\ #define DECLARE_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(object, class)\
public:\ public:\
virtual const helpers::Class& getClass() const;\ virtual const helpers::Class& getClass() const;\
static const helpers::Class& getStaticClass();\ static const helpers::Class& getStaticClass();\
static class theClass##object; static const log4cxx::helpers::ClassRegistration& registerClass();
#define IMPLEMENT_LOG4CXX_OBJECT(object)\ #define IMPLEMENT_LOG4CXX_OBJECT(object)\
object::Class##object object::theClass##object;\ const log4cxx::helpers::Class& object::getClass() const { return getStaticC
const log4cxx::helpers::Class& object::getClass() const { return theClass## lass(); }\
object; }\ const log4cxx::helpers::Class& object::getStaticClass() { \
const log4cxx::helpers::Class& object::getStaticClass() { return theClass## static Clazz##object theClass; \
object; } return theClass; \
} \
const log4cxx::helpers::ClassRegistration& object::registerClass() { \
static log4cxx::helpers::ClassRegistration classReg(object::getStaticCl
ass); \
return classReg; \
}\
namespace log4cxx { namespace classes { \
const log4cxx::helpers::ClassRegistration& object##Registration = object::r
egisterClass(); \
} }
#define IMPLEMENT_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(object, class)\ #define IMPLEMENT_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(object, class)\
object::class object::theClass##object;\ const log4cxx::helpers::Class& object::getClass() const { return getStaticC
const log4cxx::helpers::Class& object::getClass() const { return theClass## lass(); }\
object; }\ const log4cxx::helpers::Class& object::getStaticClass() { \
const log4cxx::helpers::Class& object::getStaticClass() { return theClass## static class theClass; \
object; } return theClass; \
} \
const log4cxx::helpers::ClassRegistration& object::registerClass() { \
static log4cxx::helpers::ClassRegistration classReg(object::getStaticCl
ass); \
return classReg; \
}\
namespace log4cxx { namespace classes { \
const log4cxx::helpers::ClassRegistration& object##Registration = object::r
egisterClass(); \
} }
namespace log4cxx namespace log4cxx
{ {
namespace helpers class AppenderSkeleton;
{ class Logger;
class LOG4CXX_EXPORT IllegalMonitorStateException : public E
xception
{
public:
IllegalMonitorStateException(const String& message)
: Exception(message)
{
}
};
class Object;
typedef ObjectPtrT<Object> ObjectPtr;
/** base class for java-like objects.*/
class LOG4CXX_EXPORT Object
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Object)
virtual ~Object() {}
virtual void addRef() const = 0;
virtual void releaseRef() const = 0;
virtual void lock() const = 0;
virtual void unlock() const = 0;
virtual void wait() const = 0;
virtual void notify() const = 0;
virtual void notifyAll() const = 0;
virtual bool instanceof(const Class& clazz) const =
0;
virtual const void * cast(const Class& clazz) const
= 0;
};
/** utility class for objects multi-thread synchronization.*
/
class synchronized
{
public:
synchronized(const Object * object) : object(object)
{ object->lock(); }
~synchronized() namespace helpers
{ object->unlock(); } {
class Pool;
protected: /** base class for java-like objects.*/
const Object * object; class LOG4CXX_EXPORT Object
}; {
} public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Object)
virtual ~Object() {}
virtual void addRef() const = 0;
virtual void releaseRef() const = 0;
virtual bool instanceof(const Class& clazz) const =
0;
virtual const void * cast(const Class& clazz) const
= 0;
};
LOG4CXX_PTR_DEF(Object);
}
} }
#define BEGIN_LOG4CXX_CAST_MAP()\ #define BEGIN_LOG4CXX_CAST_MAP()\
const void * cast(const helpers::Class& clazz) const\ const void * cast(const helpers::Class& clazz) const\
{\ {\
const void * object = 0;\ const void * object = 0;\
if (&clazz == &helpers::Object::getStaticClass()) return (helpers::O if (&clazz == &helpers::Object::getStaticClass()) return (const hel
bject *)this; pers::Object *)this;
#define END_LOG4CXX_CAST_MAP()\ #define END_LOG4CXX_CAST_MAP()\
return object;\ return object;\
}\ }\
bool instanceof(const helpers::Class& clazz) const\ bool instanceof(const helpers::Class& clazz) const\
{ return cast(clazz) != 0; } { return cast(clazz) != 0; }
#define LOG4CXX_CAST_ENTRY(Interface)\ #define LOG4CXX_CAST_ENTRY(Interface)\
if (&clazz == &Interface::getStaticClass()) return (Interface *)this; if (&clazz == &Interface::getStaticClass()) return (const Interface *)this;
#define LOG4CXX_CAST_ENTRY2(Interface, interface2)\ #define LOG4CXX_CAST_ENTRY2(Interface, interface2)\
if (&clazz == &Interface::getStaticClass()) return (Interface *)(interface2 *)this; if (&clazz == &Interface::getStaticClass()) return (Interface *)(interface2 *)this;
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)\ #define LOG4CXX_CAST_ENTRY_CHAIN(Interface)\
object = Interface::cast(clazz);\ object = Interface::cast(clazz);\
if (object != 0) return object; if (object != 0) return object;
#endif //_LOG4CXX_HELPERS_OBJECT_H #endif //_LOG4CXX_HELPERS_OBJECT_H
 End of changes. 18 change blocks. 
81 lines changed or deleted 82 lines changed or added


 objectimpl.h   objectimpl.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_OBJECT_IMPL_H #ifndef _LOG4CXX_HELPERS_OBJECT_IMPL_H
#define _LOG4CXX_HELPERS_OBJECT_IMPL_H #define _LOG4CXX_HELPERS_OBJECT_IMPL_H
#include <log4cxx/config.h>
#include <log4cxx/helpers/object.h> #include <log4cxx/helpers/object.h>
#include <log4cxx/helpers/criticalsection.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
/** Implementation class for Object.*/ /** Implementation class for Object.*/
class LOG4CXX_EXPORT ObjectImpl : public virtual Object class LOG4CXX_EXPORT ObjectImpl : public virtual Object
{ {
public: public:
ObjectImpl(); ObjectImpl();
virtual ~ObjectImpl(); virtual ~ObjectImpl();
void addRef() const; void addRef() const;
void releaseRef() const; void releaseRef() const;
virtual void lock() const;
virtual void unlock() const;
virtual void wait() const;
virtual void notify() const;
virtual void notifyAll() const;
protected: protected:
mutable long volatile ref; mutable unsigned int volatile ref;
mutable CriticalSection cs;
mutable void * eventList; private:
}; //
} // prevent object copy and assignment
//
ObjectImpl(const ObjectImpl&);
ObjectImpl& operator=(const ObjectImpl&);
};
}
} }
#endif //_LOG4CXX_HELPERS_OBJECT_IMPL_H #endif //_LOG4CXX_HELPERS_OBJECT_IMPL_H
 End of changes. 5 change blocks. 
28 lines changed or deleted 27 lines changed or added


 objectptr.h   objectptr.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_OBJECT_PTR_H #ifndef _LOG4CXX_HELPERS_OBJECT_PTR_H
#define _LOG4CXX_HELPERS_OBJECT_PTR_H #define _LOG4CXX_HELPERS_OBJECT_PTR_H
#include <log4cxx/helpers/exception.h> #include <log4cxx/log4cxx.h>
//
// Helgrind (race detection tool for Valgrind) will complain if pointer
// is not initialized in an atomic operation. Static analysis tools
// (gcc's -Weffc++, for example) will complain if pointer is not initiali
zed
// in member initialization list. The use of a macro allows quick
// switching between the initialization styles.
//
#if LOG4CXX_HELGRIND
#define _LOG4CXX_OBJECTPTR_INIT(x) { exchange(x);
#else
#define _LOG4CXX_OBJECTPTR_INIT(x) : p(x) {
#endif
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
/** smart pointer to a Object descendant */ class Class;
template<typename T> class ObjectPtrT
{
public:
template<typename InterfacePtr> ObjectPtrT(const Int
erfacePtr& p)
: p(0)
{
cast(p);
}
// Disable conversion using ObjectPtrT* specializati
on of
// template<typename InterfacePtr> ObjectPtrT(const
InterfacePtr& p)
/* template<> explicit ObjectPtrT(ObjectPtrT* const & p
) throw(IllegalArgumentException)
{
if (p == 0)
{
throw IllegalArgumentException(Strin
g());
}
else
{
this->p = p->p;
this->p->addRef();
}
}*/
ObjectPtrT(const int& null) //throw(IllegalArgumentE class LOG4CXX_EXPORT ObjectPtrBase {
xception) public:
: p(0) ObjectPtrBase();
{ virtual ~ObjectPtrBase();
if (null != 0) static void checkNull(const int& null);
{ static void* exchange(void** destination, void* newValue);
virtual void* cast(const Class& cls) const = 0;
};
throw IllegalArgumentException(Strin /** smart pointer to a Object descendant */
g()); template<typename T> class ObjectPtrT : public ObjectPtrBase
} {
} public:
ObjectPtrT(const int& null)
_LOG4CXX_OBJECTPTR_INIT(0)
ObjectPtrBase::checkNull(null);
}
ObjectPtrT() : p(0) ObjectPtrT()
{ _LOG4CXX_OBJECTPTR_INIT(0)
} }
ObjectPtrT(T * p) : p(p) ObjectPtrT(T * p1)
{ _LOG4CXX_OBJECTPTR_INIT(p1)
if (this->p != 0) if (this->p != 0)
{ {
this->p->addRef(); this->p->addRef();
} }
} }
ObjectPtrT(const ObjectPtrT& p) : p(p.p) ObjectPtrT(const ObjectPtrT& p1)
{ _LOG4CXX_OBJECTPTR_INIT(p1.p)
if (this->p != 0) if (this->p != 0)
{ {
this->p->addRef(); this->p->addRef();
} }
} }
~ObjectPtrT() ObjectPtrT(const ObjectPtrBase& p1)
{ _LOG4CXX_OBJECTPTR_INIT(reinterpret_cast<T*>(p1.cast(T::getStatic
if (this->p != 0) Class())))
{ if (this->p != 0) {
this->p->releaseRef(); this->p->addRef();
} }
} }
// Operators ObjectPtrT(ObjectPtrBase& p1)
template<typename InterfacePtr> ObjectPtrT& operator _LOG4CXX_OBJECTPTR_INIT(reinterpret_cast<T*>(p1.cast(T::getStatic
=(const InterfacePtr& p) Class())))
{ if (this->p != 0) {
cast(p); this->p->addRef();
return *this; }
} }
ObjectPtrT& operator=(const ObjectPtrT& p) ~ObjectPtrT()
{ {
if (this->p != p.p) if (p != 0) {
{ p->releaseRef();
if (this->p != 0) }
{
this->p->releaseRef();
}
this->p = p.p;
if (this->p != 0)
{
this->p->addRef();
}
}
return *this;
} }
ObjectPtrT& operator=(const int& null) //throw(Illeg ObjectPtrT& operator=(const ObjectPtrT& p1) {
alArgumentException) T* newPtr = p1.p;
{ if (newPtr != 0) {
if (null != 0) newPtr->addRef();
{ }
throw IllegalArgumentException(Strin T* oldPtr = exchange(newPtr);
g()); if (oldPtr != 0) {
} oldPtr->releaseRef();
}
return *this;
}
if (this->p != 0) ObjectPtrT& operator=(const int& null) //throw(IllegalArgumentExce
{ ption)
this->p->releaseRef(); {
this->p = 0; //
// throws IllegalArgumentException if null != 0
//
ObjectPtrBase::checkNull(null);
T* oldPtr = exchange(0);
if (oldPtr != 0) {
oldPtr->releaseRef();
} }
return *this;
}
return *this; ObjectPtrT& operator=(T* p1) {
} if (p1 != 0) {
p1->addRef();
ObjectPtrT& operator=(T* p) }
{ T* oldPtr = exchange(p1);
if (this->p != p) if (oldPtr != 0) {
{ oldPtr->releaseRef();
if (this->p != 0) }
{ return *this;
this->p->releaseRef(); }
}
this->p = p;
if (this->p != 0) ObjectPtrT& operator=(ObjectPtrBase& p1) {
{ T* newPtr = reinterpret_cast<T*>(p1.cast(T::getStaticClass()));
this->p->addRef(); return operator=(newPtr);
} }
}
return *this; ObjectPtrT& operator=(const ObjectPtrBase& p1) {
} T* newPtr = reinterpret_cast<T*>(p1.cast(T::getStaticClass()));
return operator=(newPtr);
}
bool operator==(const ObjectPtrT& p) const { return (this->p == bool operator==(const ObjectPtrT& p1) const { return (this->p =
p.p); } = p1.p); }
bool operator!=(const ObjectPtrT& p) const { return (this->p != bool operator!=(const ObjectPtrT& p1) const { return (this->p !
p.p); } = p1.p); }
bool operator==(const T* p) const { return (this->p == p); } bool operator<(const ObjectPtrT& p1) const { return (this->p < p1.
bool operator!=(const T* p) const { return (this->p != p); } p); }
T* operator->() {return p; } bool operator==(const T* p1) const { return (this->p == p1); }
const T* operator->() const {return p; } bool operator!=(const T* p1) const { return (this->p != p1); }
bool operator<(const T* p1) const { return (this->p < p1); }
T* operator->() const {return p; }
T& operator*() const {return *p; } T& operator*() const {return *p; }
operator T*() const {return p; } operator T*() const {return p; }
template<typename InterfacePtr> void cast(const Inte private:
rfacePtr& p)
{
if (this->p != 0)
{
this->p->releaseRef();
this->p = 0;
}
if (p != 0)
{
this->p = (T*)p->cast(T::getStaticCl
ass());
if (this->p != 0)
{
this->p->addRef();
}
}
}
public:
T * p; T * p;
virtual void* cast(const Class& cls) const {
if (p != 0) {
return const_cast<void*>(p->cast(cls));
}
return 0;
}
T* exchange(const T* newValue) {
return static_cast<T*>(ObjectPtrBase::exchange(
reinterpret_cast<void**>(&p),
const_cast<T*>(newValue)));
}
}; };
} }
} }
#endif //_LOG4CXX_HELPERS_OBJECT_PTR_H #endif //_LOG4CXX_HELPERS_OBJECT_PTR_H
 End of changes. 22 change blocks. 
144 lines changed or deleted 128 lines changed or added


 odbcappender.h   odbcappender.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_DB_ODBC_APPENDER_H #ifndef _LOG4CXX_DB_ODBC_APPENDER_H
#define _LOG4CXX_DB_ODBC_APPENDER_H #define _LOG4CXX_DB_ODBC_APPENDER_H
#include <log4cxx/config.h> #if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#ifdef HAVE_ODBC #include <log4cxx/log4cxx.h>
#include <log4cxx/helpers/exception.h> #include <log4cxx/helpers/exception.h>
#include <log4cxx/appenderskeleton.h> #include <log4cxx/appenderskeleton.h>
#include <log4cxx/spi/loggingevent.h> #include <log4cxx/spi/loggingevent.h>
#include <list> #include <list>
#ifdef HAVE_MS_ODBC
#include <windows.h>
#endif
#include <sqlext.h>
namespace log4cxx namespace log4cxx
{ {
namespace db namespace db
{ {
class LOG4CXX_EXPORT SQLException : public helpers::Exceptio class LOG4CXX_EXPORT SQLException : public log4cxx::helpers::Ex
n ception {
{ public:
public: SQLException(short fHandleType,
SQLException(int code) : code(code) {} void* hInput, const char* prolog,
virtual String getMessage() { return String(); } log4cxx::helpers::Pool& p);
SQLException(const char* msg);
SQLException(const SQLException& src);
private:
const char* formatMessage(short fHandleType,
void* hInput, const char* prolog,
log4cxx::helpers::Pool& p);
};
int code; /**
}; <p><b>WARNING: This version of ODBCAppender
is very likely to be completely replaced in the future. Mor
eoever,
it does not log exceptions.</b> </p>
class ODBCAppender; The ODBCAppender provides for sending log events to a datab
typedef helpers::ObjectPtrT<ODBCAppender> ODBCAppenderPtr; ase.
/** <p>Each append call adds to an <code>ArrayList</code> buffe
<p><b>WARNING: This version of ODBCAppender r. When
is very likely to be completely replaced in the future. More the buffer is filled each log event is placed in a sql stat
oever, ement
it does not log exceptions.</b> </p> (configurable) and executed.
The ODBCAppender provides for sending log events to a databa <b>BufferSize</b>, <b>db URL</b>, <b>User</b>, & <b>Passwor
se. d</b> are
configurable options in the standard log4j ways.
<p>Each append call adds to an <code>ArrayList</code> buffer <p>The <code>setSql(String sql)</code> sets the SQL stateme
. When nt to be
the buffer is filled each log event is placed in a sql state used for logging -- this statement is sent to a
ment <code>PatternLayout</code> (either created automaticly by t
(configurable) and executed. he
appender or added by the user). Therefore by default all t
he
conversion patterns in <code>PatternLayout</code> can be us
ed
inside of the statement. (see the test cases for examples)
<b>BufferSize</b>, <b>db URL</b>, <b>User</b>, & <b>Password <p>Overriding the {@link #getLogStatement} method allows mo
</b> are re
configurable options in the standard log4j ways. explicit control of the statement used for logging.
<p>The <code>setSql(String sql)</code> sets the SQL statemen <p>For use as a base class:
t to be
used for logging -- this statement is sent to a
<code>PatternLayout</code> (either created automaticly by th
e
appender or added by the user). Therefore by default all th
e
conversion patterns in <code>PatternLayout</code> can be use
d
inside of the statement. (see the test cases for examples)
<p>Overriding the {@link #getLogStatement} method allows mor <ul>
e
explicit control of the statement used for logging.
<p>For use as a base class: <li>Override getConnection() to pass any connection
you want. Typically this is used to enable application wid
e
connection pooling.
<ul> <li>Override closeConnection -- if
you override getConnection make sure to implement
<code>closeConnection</code> to handle the connection you
generated. Typically this would return the connection to t
he
pool it came from.
<li>Override getConnection() to pass any connection <li>Override getLogStatement to
you want. Typically this is used to enable application wide produce specialized or dynamic statements. The default uses
connection pooling. the
sql option value.
<li>Override closeConnection -- if </ul>
you override getConnection make sure to implement */
<code>closeConnection</code> to handle the connection you
generated. Typically this would return the connection to th
e
pool it came from.
<li>Override getLogStatement to class LOG4CXX_EXPORT ODBCAppender : public AppenderSkeleton
produce specialized or dynamic statements. The default uses {
the protected:
sql option value. /**
* URL of the DB for default connection handling
*/
LogString databaseURL;
</ul> /**
*/ * User to connect as for default connection handlin
g
*/
LogString databaseUser;
class LOG4CXX_EXPORT ODBCAppender : public AppenderSkeleton /**
{ * User to use for default connection handling
protected: */
/** LogString databasePassword;
* URL of the DB for default connection handling
*/
String databaseURL;
/** typedef void* SQLHDBC;
* User to connect as for default connection handling typedef void* SQLHENV;
*/ typedef void* SQLHANDLE;
String databaseUser; typedef short SQLSMALLINT;
/** /**
* User to use for default connection handling * Connection used by default. The connection is op
*/ ened the first time it
String databasePassword; * is needed and then held open until the appender i
s closed (usually at
* garbage collection). This behavior is best modif
ied by creating a
* sub-class and overriding the <code>getConnection<
/code> and
* <code>closeConnection</code> methods.
*/
SQLHDBC connection;
SQLHENV env;
/** /**
* Connection used by default. The connection is ope * Stores the string given to the pattern layout for
ned the first time it conversion into a SQL
* is needed and then held open until the appender is * statement, eg: insert into LogTable (Thread, File
closed (usually at , Message) values
* garbage collection). This behavior is best modifi * ("%t", "%F", "%m")
ed by creating a *
* sub-class and overriding the <code>getConnection</ * Be careful of quotes in your messages!
code> and *
* <code>closeConnection</code> methods. * Also see PatternLayout.
*/ */
SQLHDBC connection; LogString sqlStatement;
SQLHENV env;
/** /**
* Stores the string given to the pattern layout for * size of LoggingEvent buffer before writing to the
conversion into a SQL database.
* statement, eg: insert into LogTable (Thread, File, * Default is 1.
Message) values */
* ("%t", "%F", "%m") size_t bufferSize;
*
* Be careful of quotes in your messages!
*
* Also see PatternLayout.
*/
String sqlStatement;
/** /**
* size of LoggingEvent buffer before writting to the * ArrayList holding the buffer of Logging Events.
database. */
* Default is 1. std::list<spi::LoggingEventPtr> buffer;
*/
size_t bufferSize;
/** public:
* ArrayList holding the buffer of Logging Events. DECLARE_LOG4CXX_OBJECT(ODBCAppender)
*/ BEGIN_LOG4CXX_CAST_MAP()
std::list<spi::LoggingEventPtr> buffer; LOG4CXX_CAST_ENTRY(ODBCAppender)
LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
END_LOG4CXX_CAST_MAP()
public: ODBCAppender();
DECLARE_LOG4CXX_OBJECT(ODBCAppender) virtual ~ODBCAppender();
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(ODBCAppender)
LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
END_LOG4CXX_CAST_MAP()
ODBCAppender(); /**
virtual ~ODBCAppender(); Set options
*/
virtual void setOption(const LogString& option, con
st LogString& value);
/** /**
Set options Activate the specified options.
*/ */
virtual void setOption(const String& option, const S virtual void activateOptions(log4cxx::helpers::Pool
tring& value); & p);
/** /**
* Adds the event to the buffer. When full the buffe * Adds the event to the buffer. When full the buff
r is flushed. er is flushed.
*/ */
void append(const spi::LoggingEventPtr& event); void append(const spi::LoggingEventPtr& event, log4cxx::h
elpers::Pool&);
/** /**
* By default getLogStatement sends the event to the * By default getLogStatement sends the event to the
required Layout object. required Layout object.
* The layout will format the given pattern into a wo * The layout will format the given pattern into a w
rkable SQL string. orkable SQL string.
* *
* Overriding this provides direct access to the Logg * Overriding this provides direct access to the Log
ingEvent gingEvent
* when constructing the logging statement. * when constructing the logging statement.
* *
*/ */
protected: protected:
String getLogStatement(const spi::LoggingEventPtr& e LogString getLogStatement(const spi::LoggingEventPt
vent) const; r& event,
helpers::Pool& p) const;
/** /**
* *
* Override this to provide an alertnate method of ge * Override this to provide an alertnate method of g
tting etting
* connections (such as caching). One method to fix * connections (such as caching). One method to fix
this is to open this is to open
* connections at the start of flushBuffer() and clos * connections at the start of flushBuffer() and clo
e them at the se them at the
* end. I use a connection pool outside of ODBCAppen * end. I use a connection pool outside of ODBCAppe
der which is nder which is
* accessed in an override of this method. * accessed in an override of this method.
* */ * */
void execute(const String& sql) /*throw(SQLException virtual void execute(const LogString& sql,
)*/; log4cxx::helpers::Pool& p) /*throw(SQLException
)*/;
/** /**
* Override this to return the connection to a pool, * Override this to return the connection to a pool,
or to clean up the or to clean up the
* resource. * resource.
* *
* The default behavior holds a single connection ope * The default behavior holds a single connection op
n until the appender en until the appender
* is closed (typically when garbage collected). * is closed (typically when garbage collected).
*/ */
virtual void closeConnection(SQLHDBC con); virtual void closeConnection(SQLHDBC con);
/** /**
* Override this to link with your connection pooling * Override this to link with your connection poolin
system. g system.
* *
* By default this creates a single connection which * By default this creates a single connection which
is held open is held open
* until the object is garbage collected. * until the object is garbage collected.
*/ */
virtual SQLHDBC getConnection() /*throw(SQLException virtual SQLHDBC getConnection(log4cxx::helpers::Poo
)*/; l& p) /*throw(SQLException)*/;
/** /**
* Closes the appender, flushing the buffer first the * Closes the appender, flushing the buffer first th
n closing the default en closing the default
* connection if it is open. * connection if it is open.
*/ */
public: public:
virtual void close(); virtual void close();
/** /**
* loops through the buffer of LoggingEvents, gets a * loops through the buffer of LoggingEvents, gets a
* sql string from getLogStatement() and sends it to * sql string from getLogStatement() and sends it to
execute(). execute().
* Errors are sent to the errorHandler. * Errors are sent to the errorHandler.
* *
* If a statement fails the LoggingEvent stays in the * If a statement fails the LoggingEvent stays in th
buffer! e buffer!
*/ */
void flushBuffer(); virtual void flushBuffer(log4cxx::helpers::Pool& p)
;
/** /**
* ODBCAppender requires a layout. * ODBCAppender requires a layout.
* */ * */
virtual bool requiresLayout() const virtual bool requiresLayout() const
{ return true; } { return true; }
/** /**
* Set pre-formated statement eg: insert into LogTabl * Set pre-formated statement eg: insert into LogTab
e (msg) values ("%m") le (msg) values ("%m")
*/ */
void setSql(const String& s); void setSql(const LogString& s);
/** /**
* Returns pre-formated statement eg: insert into Log * Returns pre-formated statement eg: insert into Lo
Table (msg) values ("%m") gTable (msg) values ("%m")
*/ */
inline const String& getSql() const inline const LogString& getSql() const
{ return sqlStatement; } { return sqlStatement; }
inline void setUser(const String& user) inline void setUser(const LogString& user)
{ databaseUser = user; } { databaseUser = user; }
inline void setURL(const String& url) inline void setURL(const LogString& url)
{ databaseURL = url; } { databaseURL = url; }
inline void setPassword(const String& password) inline void setPassword(const LogString& password)
{ databasePassword = password; } { databasePassword = password; }
inline void setBufferSize(size_t newBufferSize) inline void setBufferSize(size_t newBufferSize)
{ bufferSize = newBufferSize; } { bufferSize = newBufferSize; }
inline const String& getUser() const inline const LogString& getUser() const
{ return databaseUser; } { return databaseUser; }
inline const String& getURL() const inline const LogString& getURL() const
{ return databaseURL; } { return databaseURL; }
inline const String& getPassword() const inline const LogString& getPassword() const
{ return databasePassword; } { return databasePassword; }
inline size_t getBufferSize() const
{ return bufferSize; }
private:
ODBCAppender(const ODBCAppender&);
ODBCAppender& operator=(const ODBCAppender&);
}; // class ODBCAppender
LOG4CXX_PTR_DEF(ODBCAppender);
inline size_t getBufferSize() const
{ return bufferSize; }
}; // class ODBCAppender
} // namespace db } // namespace db
}; // namespace log4cxx } // namespace log4cxx
#endif // HAVE_ODBC #if defined(_MSC_VER)
#endif // _LOG4CXX_NET_SOCKET_APPENDER_H #pragma warning ( pop )
#endif
#endif // _LOG4CXX_DB_ODBC_APPENDER_H
 End of changes. 49 change blocks. 
237 lines changed or deleted 258 lines changed or added


 onlyonceerrorhandler.h   onlyonceerrorhandler.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_ONLY_ONCE_ERROR_HANDLER_H #ifndef _LOG4CXX_HELPERS_ONLY_ONCE_ERROR_HANDLER_H
#define _LOG4CXX_HELPERS_ONLY_ONCE_ERROR_HANDLER_H #define _LOG4CXX_HELPERS_ONLY_ONCE_ERROR_HANDLER_H
#include <log4cxx/spi/errorhandler.h> #include <log4cxx/spi/errorhandler.h>
#include <log4cxx/helpers/objectimpl.h> #include <log4cxx/helpers/objectimpl.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
/** /**
The <code>OnlyOnceErrorHandler</code> implements log4cxx's d The <code>OnlyOnceErrorHandler</code> implements log4cxx's
efault default
error handling policy which consists of emitting a message f error handling policy which consists of emitting a message
or the for the
first error in an appender and ignoring all following errors first error in an appender and ignoring all following error
. s.
<p>The error message is printed on <code>System.err</code>. <p>The error message is printed on <code>System.err</code>.
<p>This policy aims at protecting an otherwise working appli <p>This policy aims at protecting an otherwise working appl
cation ication
from being flooded with error messages when logging fails from being flooded with error messages when logging fails
*/ */
class LOG4CXX_EXPORT OnlyOnceErrorHandler : class LOG4CXX_EXPORT OnlyOnceErrorHandler :
public virtual spi::ErrorHandler, public virtual spi::ErrorHandler,
public virtual ObjectImpl public virtual ObjectImpl
{ {
private: private:
String WARN_PREFIX; LogString WARN_PREFIX;
String ERROR_PREFIX; LogString ERROR_PREFIX;
mutable bool firstTime; mutable bool firstTime;
public: public:
DECLARE_LOG4CXX_OBJECT(OnlyOnceErrorHandler) DECLARE_LOG4CXX_OBJECT(OnlyOnceErrorHandler)
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()
OnlyOnceErrorHandler(); OnlyOnceErrorHandler();
void addRef() const;
void releaseRef() const;
/** /**
Does not do anything. Does not do anything.
*/ */
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 LogString& value)
;
/** /**
Prints the message and the stack trace of the exception on Prints the message and the stack trace of the exception on
<code>System.err</code>. */ <code>System.err</code>. */
void error(const String& message, Exception& e, void error(const LogString& message, const std::exception& e,
int errorCode) const; int errorCode) const;
/** /**
Prints the message and the stack trace of the exception on Prints the message and the stack trace of the exception on
<code>System.err</code>. <code>System.err</code>.
*/ */
void error(const String& message, Exception& e, void error(const LogString& message, const std::exception& 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;
/** /**
Does not do anything. Does not do anything.
*/ */
void setAppender(const AppenderPtr& appender); void setAppender(const AppenderPtr& appender);
/** /**
Does not do anything. Does not do anything.
*/ */
void setBackupAppender(const AppenderPtr& appender); void setBackupAppender(const AppenderPtr& appender);
}; };
} // namespace helpers } // namespace helpers
}; // namespace log4cxx } // namespace log4cxx
#endif //_LOG4CXX_HELPERS_ONLY_ONCE_ERROR_HANDLER_H #endif //_LOG4CXX_HELPERS_ONLY_ONCE_ERROR_HANDLER_H
 End of changes. 12 change blocks. 
49 lines changed or deleted 53 lines changed or added


 optionconverter.h   optionconverter.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_OPTION_CONVERTER_H #ifndef _LOG4CXX_HELPER_OPTION_CONVERTER_H
#define _LOG4CXX_HELPER_OPTION_CONVERTER_H #define _LOG4CXX_HELPER_OPTION_CONVERTER_H
#include <log4cxx/helpers/tchar.h> #include <log4cxx/logstring.h>
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
namespace log4cxx namespace log4cxx
{ {
class Level; class Level;
typedef helpers::ObjectPtrT<Level> LevelPtr; class File;
typedef helpers::ObjectPtrT<Level> LevelPtr;
namespace spi
{
class LoggerRepository;
typedef helpers::ObjectPtrT<LoggerRepository> LoggerReposito
ryPtr;
}
namespace helpers namespace spi
{ {
class Properties; class LoggerRepository;
typedef helpers::ObjectPtrT<LoggerRepository> LoggerReposit
oryPtr;
}
class Object; namespace helpers
typedef ObjectPtrT<Object> ObjectPtr; {
class Properties;
class Class; class Object;
typedef ObjectPtrT<Object> ObjectPtr;
/** A convenience class to convert property values to specif class Class;
ic types.*/
class LOG4CXX_EXPORT OptionConverter
{
static String DELIM_START;
static TCHAR DELIM_STOP;
static int DELIM_START_LEN;
static int DELIM_STOP_LEN;
/** OptionConverter is a static class. */ /** A convenience class to convert property values to speci
private: fic types.*/
OptionConverter() {} class LOG4CXX_EXPORT OptionConverter
{
/** OptionConverter is a static class. */
private:
OptionConverter() {}
public: public:
static String convertSpecialChars(const String& s); static LogString convertSpecialChars(const LogStrin
g& s);
/** /**
If <code>value</code> is "true", then <code>true</co If <code>value</code> is "true", then <code>true</c
de> is ode> is
returned. If <code>value</code> is "false", then returned. If <code>value</code> is "false", then
<code>true</code> is returned. Otherwise, <code>defa <code>true</code> is returned. Otherwise, <code>def
ult</code> is ault</code> is
returned. returned.
<p>Case of value is unimportant. <p>Case of value is unimportant.
*/ */
static bool toBoolean(const String& value, bool dEfa static bool toBoolean(const LogString& value, bool
ult); dEfault);
static int toInt(const String& value, int dEfault); static int toInt(const LogString& value, int dEfaul
static long toFileSize(const String& value, long dEf t);
ault); static long toFileSize(const LogString& value, long
static const LevelPtr& toLevel(const String& value, dEfault);
const LevelPtr& defaultValue); static LevelPtr toLevel(const LogString& value,
const LevelPtr& defaultValue);
/** /**
Find the value corresponding to <code>key</code> in Find the value corresponding to <code>key</code> in
<code>props</code>. Then perform variable substitution on th <code>props</code>. Then perform variable substitution on t
e he
found value. found value.
*/ */
static String findAndSubst(const String& key, Proper static LogString findAndSubst(const LogString& key,
ties& props); Properties& props);
/** /**
Perform variable substitution in string <code>val</code> from the Perform variable substitution in string <code>val</code> from the
values of keys found in the system propeties. values of keys found in the system propeties.
<p>The variable substitution delimeters are <b>${</b> and <b>}</b>. <p>The variable substitution delimeters are <b>${</b> and <b>}</b>.
<p>For example, if the System properties contains "key=value", then <p>For example, if the System properties contains "key=value", then
the call the call
<pre> <pre>
skipping to change at line 113 skipping to change at line 110
will set <code>s</code> to "Value of inexistentKey is []" will set <code>s</code> to "Value of inexistentKey is []"
<p>An IllegalArgumentException is thrown if <p>An IllegalArgumentException is thrown if
<code>val</code> contains a start delimeter "${" which is not <code>val</code> contains a start delimeter "${" which is not
balanced by a stop delimeter "}". </p> balanced by a stop delimeter "}". </p>
@param val The string on which variable substitution is performed. @param val The string on which variable substitution is performed.
@param props The properties from which variable substitution is performed. @param props The properties from which variable substitution is performed.
@throws IllegalArgumentException if <code>val</code> is malformed. @throws IllegalArgumentException if <code>val</code> is malformed.
*/ */
static String substVars(const String& val, Propertie s& props); static LogString substVars(const LogString& val, Pr operties& props);
/** /**
@param key The key to search for. * Gets the specified system property.
@param def The default value to return. @param key The key to search for.
@return the string value of the system property, or @param def The default value to return.
the default @return the string value of the system property, or
value if there is no property with that key. the default
*/ value if there is no property with that key.
static String getSystemProperty(const String& key, c */
onst String& def); static LogString getSystemProperty(const LogString&
key, const LogString& def);
/** /**
Instantiate an object given a class name. Check that Instantiate an object given a class name. Check tha
the t the
<code>className</code> is a subclass of <code>className</code> is a subclass of
<code>superClass</code>. If that test fails or the o <code>superClass</code>. If that test fails or the
bject could object could
not be instantiated, then <code>defaultValue</code> not be instantiated, then <code>defaultValue</code>
is returned. is returned.
@param className The fully qualified class name of t @param className The fully qualified class name of
he object to instantiate. the object to instantiate.
@param superClass The class to which the new object @param superClass The class to which the new object
should belong. should belong.
@param defaultValue The object to return in case of @param defaultValue The object to return in case of
non-fulfillment non-fulfillment
*/ */
static ObjectPtr instantiateByClassName(const String static ObjectPtr instantiateByClassName(const LogSt
& className, ring& className,
const Class& superClass, const ObjectPtr& de const Class& superClass, const ObjectPtr& d
faultValue); efaultValue);
static ObjectPtr instantiateByKey(Properties& props, static ObjectPtr instantiateByKey(Properties& props
const String& key, const Class& superClass, ,
const ObjectPtr& defaultValue); const LogString& key, const Class& superCla
ss,
const ObjectPtr& defaultValue);
/** /**
Configure log4cxx given a configFileName. Configure log4cxx given a configFileName.
<p>The configFileName must point to a file which wil <p>The configFileName must point to a file which wi
l be ll be
interpreted by a new instance of a log4cxx configura interpreted by a new instance of a log4cxx configur
tor. ator.
<p>All configurations steps are taken on the <p>All configurations steps are taken on the
<code>hierarchy</code> passed as a parameter. <code>hierarchy</code> passed as a parameter.
<p> <p>
@param configFileName The location of the configurat @param configFileName The location of the configura
ion file. tion file.
@param clazz The classname, of the log4cxx configura @param clazz The classname, of the log4cxx configur
tor which ator which
will parse the file <code>configFileName</code>. Thi will parse the file <code>configFileName</code>. Th
s must be is must be
a subclass of Configurator, or null. If this value i a subclass of Configurator, or null. If this value
s null then is null then
a default configurator of PropertyConfigurator is us a default configurator of PropertyConfigurator is u
ed, unless the sed, unless the
filename pointed to by <code>configFileName</code> e filename pointed to by <code>configFileName</code>
nds in '.xml', ends in '.xml',
in which case DOMConfigurator is used. in which case DOMConfigurator is used.
@param hierarchy The Hierarchy to act on. @param hierarchy The Hierarchy to act on.
*/ */
static void selectAndConfigure(const String& configF static void selectAndConfigure(const File& configFi
ileName, leName,
const String& clazz, spi::LoggerRepositoryPt const LogString& clazz, spi::LoggerReposito
r& hierarchy); ryPtr& hierarchy);
}; };
} // namespace helpers } // namespace helpers
}; // namespace log4cxx } // namespace log4cxx
#endif //_LOG4CXX_HELPER_OPTION_CONVERTER_H #endif //_LOG4CXX_HELPER_OPTION_CONVERTER_H
 End of changes. 21 change blocks. 
121 lines changed or deleted 123 lines changed or added


 optionhandler.h   optionhandler.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_OPTION_HANDLER_H #ifndef _LOG4CXX_SPI_OPTION_HANDLER_H
#define _LOG4CXX_SPI_OPTION_HANDLER_H #define _LOG4CXX_SPI_OPTION_HANDLER_H
#include <log4cxx/helpers/tchar.h> #include <log4cxx/logstring.h>
#include <log4cxx/helpers/object.h> #include <log4cxx/helpers/object.h>
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
namespace log4cxx namespace log4cxx
{ {
namespace spi namespace spi
{ {
class OptionHandler; class OptionHandler;
typedef helpers::ObjectPtrT<OptionHandler> OptionHandlerPtr; typedef helpers::ObjectPtrT<OptionHandler> OptionHandlerPtr
;
/** /**
A string based interface to configure package components. A string based interface to configure package components.
*/ */
class LOG4CXX_EXPORT OptionHandler : public virtual helpers: class LOG4CXX_EXPORT OptionHandler : public virtual helpers
:Object ::Object
{ {
public: public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(OptionHandler) DECLARE_ABSTRACT_LOG4CXX_OBJECT(OptionHandler)
virtual ~OptionHandler() {} virtual ~OptionHandler() {}
/** /**
Activate the options that were previously set with c Activate the options that were previously set with
alls to option calls to option
setters. setters.
<p>This allows to defer activiation of the options u <p>This allows to defer activiation of the options
ntil all until all
options have been set. This is required for componen options have been set. This is required for compone
ts which have nts which have
related options that remain ambigous until all are s related options that remain ambigous until all are
et. set.
<p>For example, the FileAppender has the {@link <p>For example, the FileAppender has the {@link
FileAppender#setFile File} and {@link FileAppender#setFile File} and {@link
FileAppender#setAppend Append} options both of FileAppender#setAppend Append} options both of
which are ambigous until the other is also set. */ which are ambigous until the other is also set. */
virtual void activateOptions() = 0; virtual void activateOptions(log4cxx::helpers::Pool
& p) = 0;
/** /**
Set <code>option</code> to <code>value</code>. Set <code>option</code> to <code>value</code>.
<p>The handling of each option depends on the Option <p>The handling of each option depends on the Optio
Handler nHandler
instance. Some options may become active immediately instance. Some options may become active immediatel
whereas y whereas
other may be activated only when #activateOptions is other may be activated only when #activateOptions i
called. s
*/ called.
virtual void setOption(const String& option, const S */
tring& value) = 0; virtual void setOption(const LogString& option,
const LogString& value) = 0;
}; // class OptionConverter }; // class OptionConverter
} // namespace spi } // namespace spi
}; // namespace log4cxx } // namespace log4cxx
#endif //_LOG4CXX_SPI_OPTION_HANDLER_H #endif //_LOG4CXX_SPI_OPTION_HANDLER_H
 End of changes. 10 change blocks. 
48 lines changed or deleted 52 lines changed or added


 patternconverter.h   patternconverter.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_PATTERN_CONVERTER_H #ifndef _LOG4CXX_PATTERN_PATTERN_CONVERTER_H
#define _LOG4CXX_HELPER_PATTERN_CONVERTER_H #define _LOG4CXX_PATTERN_PATTERN_CONVERTER_H
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/objectimpl.h> #include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/logstring.h>
#include <vector>
namespace log4cxx #ifdef _MSC_VER
{ // disable identifier too wide for debugging warning
namespace spi #pragma warning ( disable: 4231 4251 4275 4786 )
{ #endif
class LoggingEvent;
typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr;
}
namespace helpers #define DECLARE_LOG4CXX_PATTERN(cls) DECLARE_ABSTRACT_LOG4CXX_OBJECT(cls)
{
class FormattingInfo;
class PatternConverter; namespace log4cxx {
typedef ObjectPtrT<PatternConverter> PatternConverterPtr; namespace pattern {
/** typedef std::vector<LogString> OptionsList;
<p>PatternConverter is an abtract class that provides the
formatting functionality that derived classes need.
<p>Conversion specifiers in a conversion patterns are parsed /**
to
individual PatternConverters. Each of which is responsible f
or
converting a logging event in a converter specific manner.
*/
class LOG4CXX_EXPORT PatternConverter : public ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(PatternConverter)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(PatternConverter)
END_LOG4CXX_CAST_MAP()
PatternConverterPtr next; <p>PatternConverter is an abstract class that provides the
int minChar; formatting functionality that derived classes need.
int maxChar;
bool leftAlign;
mutable StringBuffer os;
protected: <p>Conversion specifiers in a conversion patterns are parsed to
PatternConverter(); individual PatternConverters. Each of which is responsible for
PatternConverter(const FormattingInfo& fi); converting an object in a converter specific manner.
/** */
Derived pattern converters must override this method class LOG4CXX_EXPORT PatternConverter : public virtual log4cxx::helpers::Ob
in order to jectImpl {
convert conversion specifiers in the correct way.
*/
virtual void convert(ostream& sbuf,
const spi::LoggingEventPtr& event) const = 0
;
public: /**
/** * Converter name.
A template method for formatting in a converter spec */
ific way. const LogString name;
*/
virtual void format(ostream& sbuf, const spi::Loggin
gEventPtr& e) const;
}; // class PatternConverter /**
} // namespace helpers * Converter style name.
}; // namespace log4cxx */
const LogString style;
#endif // _LOG4CXX_HELPER_PATTERN_CONVERTER_H protected:
/**
* Create a new pattern converter.
* @param name name for pattern converter.
* @param style CSS style for formatted output.
*/
PatternConverter(const LogString& name,
const LogString& style);
virtual ~PatternConverter();
public:
DECLARE_LOG4CXX_PATTERN(PatternConverter)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(PatternConverter)
END_LOG4CXX_CAST_MAP()
/**
* Formats an object into a string buffer.
* @param obj event to format, may not be null.
* @param toAppendTo string buffer to which the formatted event will be a
ppended. May not be null.
* @param p pool for any allocations necessary during formatting.
*/
virtual void format(const log4cxx::helpers::ObjectPtr& obj,
LogString& toAppendTo,
log4cxx::helpers::Pool& p) const = 0;
/**
* This method returns the name of the conversion pattern.
*
* The name can be useful to certain Layouts such as HTMLLayout.
*
* @return the name of the conversion pattern
*/
LogString getName() const;
/**
* This method returns the CSS style class that should be applied to
* the LoggingEvent passed as parameter, which can be null.
*
* This information is currently used only by HTMLLayout.
*
* @param e null values are accepted
* @return the name of the conversion pattern
*/
virtual LogString getStyleClass(const log4cxx::helpers::ObjectPtr& e) con
st;
protected:
/**
* Appends content in the locale code page to a LogString.
* @param toAppendTo string to which content is appended.
* @param src content.
*/
static void append(LogString& toAppendTo, const std::string& src);
};
LOG4CXX_PTR_DEF(PatternConverter);
}
}
#endif
 End of changes. 15 change blocks. 
63 lines changed or deleted 35 lines changed or added


 patternlayout.h   patternlayout.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_PATTERN_LAYOUT_H #ifndef _LOG4CXX_PATTERN_LAYOUT_H
#define _LOG4CXX_PATTERN_LAYOUT_H #define _LOG4CXX_PATTERN_LAYOUT_H
#if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/layout.h> #include <log4cxx/layout.h>
#include <log4cxx/helpers/patternconverter.h> #include <log4cxx/pattern/loggingeventpatternconverter.h>
#include <log4cxx/pattern/formattinginfo.h>
#include <log4cxx/pattern/patternparser.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers
{
class PatternConverter;
typedef ObjectPtrT<PatternConverter> PatternConverterPtr;
}
class PatternLayout;
typedef helpers::ObjectPtrT<PatternLayout> PatternLayoutPtr;
/**
A flexible layout configurable with pattern string.
<p>The goal of this class is to #format a {@link
spi::LoggingEvent LoggingEvent} and return the results as a string.
The results depend on the <em>conversion pattern</em>.
<p>The conversion pattern is closely related to the conversion
pattern of the printf function in C. A conversion pattern is
composed of literal text and format control expressions called
<em>conversion specifiers</em>.
<p><i>You are free to insert any literal text within the conversion
pattern.</i>
<p>Each conversion specifier starts with a percent sign (\%) and is
followed by optional <em>format modifiers</em> and a <em>conversion
character</em>. The conversion character specifies the type of
data, e.g. logger, priority, date, thread name. The format
modifiers control such things as field width, padding, left and
right justification. The following is a simple example.
<p>Let the conversion pattern be <b>"\%-5p [\%t]: \%m\%n"</b> and as
sume
that the log4cxx environment was set to use a PatternLayout. Then th
e
statements
<pre>
LoggerPtr root = Logger::getRoot();
root->debug("Message 1");
root->warn("Message 2");
</pre>
would yield the output
<pre>
DEBUG [main]: Message 1
WARN [main]: Message 2
</pre>
<p>Note that there is no explicit separator between text and
conversion specifiers. The pattern parser knows when it has reached
the end of a conversion specifier when it reads a conversion
character. In the example above the conversion specifier
<b>\%-5p</b> means the priority of the logging event should be left
justified to a width of five characters.
The recognized conversion characters are
<p>
<table border="1" CELLPADDING="8">
<tr>
<td align=center><b>Conversion Character</b></td>
<td align=center><b>Effect</b></td>
</tr>
<tr>
<td align=center><b>c</b></td>
<td>Used to output the logger of the logging event. The /**
logger conversion specifier can be optionally followed by
<em>precision specifier</em>, that is a decimal constant in
brackets.
<p>If a precision specifier is given, then only the corresponding A flexible layout configurable with pattern string.
number of right most components of the logger name will be
printed. By default the logger name is printed in full.
<p>For example, for the logger name "a.b.c" the pattern <p>The goal of this class is to #format a {@link
<b>\%c{2}</b> will output "b.c". spi::LoggingEvent LoggingEvent} and return the results as a string.
The results depend on the <em>conversion pattern</em>.
</td> <p>The conversion pattern is closely related to the conversion
</tr> pattern of the printf function in C. A conversion pattern is
composed of literal text and format control expressions called
<em>conversion specifiers</em>.
<tr> <td align=center><b>d</b></td> <td>Used to output the date of <p><i>You are free to insert any literal text within the conversion
the logging event. The date conversion specifier may be pattern.</i>
followed by a <em>date format specifier</em> enclosed between
braces. For example, <b>\%d{\%H:\%M:\%S}</b> or
<b>\%d{\%d&nbsp;\%b&nbsp;\%Y&nbsp;\%H:\%M:\%S}</b>. If no
date format specifier is given then {@link helpers::ISO8601DateForma
t
ISO8601 format} is assumed.
<p>The Following format options are possible: <p>Each conversion specifier starts with a percent sign (\%) and is
- %a -- Abbreviated weekday name followed by optional <em>format modifiers</em> and a <em>conversion
- %A -- Full weekday name character</em>. The conversion character specifies the type of
- %b -- Abbreviated month name data, e.g. logger, level, date, thread name. The format
- %B -- Full month name modifiers control such things as field width, padding, left and
- %c -- Standard date and time string right justification. The following is a simple example.
- %d -- Day of month as a decimal(1-31)
- %H -- Hour(0-23)
- %I -- Hour(1-12)
- %j -- Day of year as a decimal(1-366)
- %m -- Month as decimal(1-12)
- %M -- Minute as decimal(00-59)
- %p -- Locale's equivalent of AM or PM
- %Q -- Millisecond as decimal (000-999)
- %S -- Second as decimal(00-59)
- %U -- Week of year, Sunday being first day(0-53)
- %w -- Weekday as a decimal(0-6, Sunday being 0)
- %W -- Week of year, Monday being first day(0-53)
- %x -- Standard date string
- %X -- Standard time string
- %y -- Year in decimal without century(0-99)
- %Y -- Year including century as decimal
- %Z -- Time zone name
- %% -- The percent sign
<p>Lookup the documentation for the <code>strftime()</code> function <p>Let the conversion pattern be <b>"\%-5p [\%t]: \%m\%n"</b> and a
found in the <code>&lt;ctime&gt;</code> header for more information. ssume
that the log4cxx environment was set to use a PatternLayout. Then t
he
statements
<pre>
LoggerPtr root = Logger::getRoot();
root->debug("Message 1");
root->warn("Message 2");
</pre>
would yield the output
<pre>
DEBUG [main]: Message 1
WARN [main]: Message 2
</pre>
<p>You can alos use the log4cxx predefined date <p>Note that there is no explicit separator between text and
formatters. These can be specified using one of the strings conversion specifiers. The pattern parser knows when it has reached
"ABSOLUTE", "DATE" and "ISO8601" for specifying {@link the end of a conversion specifier when it reads a conversion
helpers::AbsoluteTimeDateFormat character. In the example above the conversion specifier
AbsoluteTimeDateFormat}, {@link <b>\%-5p</b> means the level of the logging event should be left
helpers::DateTimeDateFormat DateTimeDateFormat} justified to a width of five characters.
and respectively {@link
helpers::ISO8601DateFormat
ISO8601DateFormat}. For example, <b>\%d{ISO8601}</b> or
<b>\%d{ABSOLUTE}</b>.
</td> The recognized conversion characters are
</tr>
<tr> <p>
<td align=center><b>F</b></td> <table border="1" CELLPADDING="8">
<tr>
<td align=center><b>Conversion Character</b></td>
<td align=center><b>Effect</b></td>
</tr>
<td>Used to output the file name where the logging request was <tr>
issued. <td align=center><b>c</b></td>
<p><b>WARNING</b> Generating caller location information is <td>Used to output the logger of the logging event. The
extremely slow. It's use should be avoided unless execution speed logger conversion specifier can be optionally followed by
is not an issue. <em>precision specifier</em>, that is a decimal constant in
brackets.
</tr> <p>If a precision specifier is given, then only the corresponding
number of right most components of the logger name will be
printed. By default the logger name is printed in full.
<tr> <p>For example, for the logger name "a.b.c" the pattern
<td align=center><b>l</b></td> <b>\%c{2}</b> will output "b.c".
<td>Used to output location information of the caller which generate </td>
d </tr>
the logging event.
<p>The location information can be very useful. However, it's <tr> <td align=center><b>d</b></td> <td>Used to output the date of
generation is <em>extremely</em> slow. It's use should be avoided the logging event. The date conversion specifier may be
unless execution speed is not an issue. followed by a set of braces containing a
date and time pattern string compatible with java.text.SimpleDateF
ormat,
<em>ABSOLUTE</em>, <em>DATE</em> or <em>ISO8601</em>.
For example, <b>%d{HH:mm:ss,SSS}</b>,
<b>%d{dd&nbsp;MMM&nbsp;yyyy&nbsp;HH:mm:ss,SSS}</b> or
<b>%d{DATE}</b>. If no date format specifier is given then
ISO8601 format is assumed.
</td>
</tr>
</td> <tr>
</tr> <td align=center><b>F</b></td>
<tr> <td>Used to output the file name where the logging request was
<td align=center><b>L</b></td> issued.
<td>Used to output the line number from where the logging request </tr>
was issued.
<p><b>WARNING</b> Generating caller location information is <tr>
extremely slow. It's use should be avoided unless execution speed <td align=center><b>l</b></td>
is not an issue.
</tr> <td>Used to output location information of the caller which generat
ed
the logging event.
<tr> </td>
<td align=center><b>m</b></td> </tr>
<td>Used to output the application supplied message associated with
the logging event.</td>
</tr>
<tr> <tr>
<td align=center><b>n</b></td> <td align=center><b>L</b></td>
<td>Outputs the platform dependent line separator character or <td>Used to output the line number from where the logging request
characters. was issued.
</tr>
<p>This conversion character offers practically the same <tr>
performance as using non-portable line separator strings such as <td align=center><b>m</b></td>
"\n", or "\r\n". Thus, it is the preferred way of specifying a <td>Used to output the application supplied message associated with
line separator. the logging event.</td>
</tr>
</tr> <tr>
<td align=center><b>n</b></td>
<tr> <td>Outputs the platform dependent line separator character or
<td align=center><b>p</b></td> characters.
<td>Used to output the level(priority) of the logging event.</td>
</tr>
<tr> <p>This conversion character offers practically the same
performance as using non-portable line separator strings such as
"\n", or "\r\n". Thus, it is the preferred way of specifying a
line separator.
<td align=center><b>r</b></td> </tr>
<td>Used to output the number of milliseconds elapsed since the star <tr>
t <td align=center><b>p</b></td>
of the application until the creation of the logging event.</td> <td>Used to output the level of the logging event.</td>
</tr> </tr>
<tr> <tr>
<td align=center><b>t</b></td>
<td>Used to output the name of the thread that generated the <td align=center><b>r</b></td>
logging event.</td>
</tr> <td>Used to output the number of milliseconds elapsed since the sta
rt
of the application until the creation of the logging event.</td>
</tr>
<tr> <tr>
<td align=center><b>t</b></td>
<td align=center><b>x</b></td> <td>Used to output the name of the thread that generated the
logging event.</td>
<td>Used to output the NDC (nested diagnostic context) associated </tr>
with the thread that generated the logging event.
</td>
</tr>
<tr> <tr>
<td align=center><b>X</b></td>
<td> <td align=center><b>x</b></td>
<p>Used to output the MDC (mapped diagnostic context) associated <td>Used to output the NDC (nested diagnostic context) associated
with the thread that generated the logging event. The <b>X</b> with the thread that generated the logging event.
conversion character <em>must</em> be followed by the key for the </td>
map placed between braces, as in <b>\%X{clientNumber}</b> where </tr>
<code>clientNumber</code> is the key. The value in the MDC
corresponding to the key will be output.</p>
<p>See MDC class for more details. <tr>
</p> <td align=center><b>X</b></td>
</td> <td>
</tr>
<tr> <p>Used to output the MDC (mapped diagnostic context) associated
with the thread that generated the logging event. The <b>X</b>
conversion character <em>must</em> be followed by the key for the
map placed between braces, as in <b>\%X{clientNumber}</b> where
<code>clientNumber</code> is the key. The value in the MDC
corresponding to the key will be output.</p>
<td align=center><b>\%</b></td> <p>See MDC class for more details.
</p>
<td>The sequence \%\% outputs a single percent sign. </td>
</td> </tr>
</tr>
</table> <tr>
<p>By default the relevant information is output as is. However, <td align=center><b>\%</b></td>
with the aid of format modifiers it is possible to change the
minimum field width, the maximum field width and justification.
<p>The optional format modifier is placed between the percent sign <td>The sequence \%\% outputs a single percent sign.
and the conversion character. </td>
</tr>
<p>The first optional format modifier is the <em>left justification </table>
flag</em> which is just the minus (-) character. Then comes the
optional <em>minimum field width</em> modifier. This is a decimal
constant that represents the minimum number of characters to
output. If the data item requires fewer characters, it is padded on
either the left or the right until the minimum width is
reached. The default is to pad on the left (right justify) but you
can specify right padding with the left justification flag. The
padding character is space. If the data item is larger than the
minimum field width, the field is expanded to accommodate the
data. The value is never truncated.
<p>This behavior can be changed using the <em>maximum field <p>By default the relevant information is output as is. However,
width</em> modifier which is designated by a period followed by a with the aid of format modifiers it is possible to change the
decimal constant. If the data item is longer than the maximum minimum field width, the maximum field width and justification.
field, then the extra characters are removed from the
<em>beginning</em> of the data item and not from the end. For
example, it the maximum field width is eight and the data item is
ten characters long, then the first two characters of the data item
are dropped. This behavior deviates from the printf function in C
where truncation is done from the end.
<p>Below are various format modifier examples for the logger <p>The optional format modifier is placed between the percent sign
conversion specifier. and the conversion character.
<p> <p>The first optional format modifier is the <em>left justification
<TABLE BORDER=1 CELLPADDING=8> flag</em> which is just the minus (-) character. Then comes the
<tr> optional <em>minimum field width</em> modifier. This is a decimal
<td align=center><b>Format modifier</b></td> constant that represents the minimum number of characters to
<td align=center><b>left justify</b></td> output. If the data item requires fewer characters, it is padded on
<td align=center><b>minimum width</b></td> either the left or the right until the minimum width is
<td align=center><b>maximum width</b></td> reached. The default is to pad on the left (right justify) but you
<td align=center><b>comment</b></td> can specify right padding with the left justification flag. The
</tr> padding character is space. If the data item is larger than the
minimum field width, the field is expanded to accommodate the
data. The value is never truncated.
<tr> <p>This behavior can be changed using the <em>maximum field
<td align=center>\%20c</td> width</em> modifier which is designated by a period followed by a
<td align=center>false</td> decimal constant. If the data item is longer than the maximum
<td align=center>20</td> field, then the extra characters are removed from the
<td align=center>none</td> <em>beginning</em> of the data item and not from the end. For
example, it the maximum field width is eight and the data item is
ten characters long, then the first two characters of the data item
are dropped. This behavior deviates from the printf function in C
where truncation is done from the end.
<td>Left pad with spaces if the logger name is less than 20 <p>Below are various format modifier examples for the logger
characters long. conversion specifier.
<tr> <td align=center>\%-20c</td> <td align=center>true</td> <td <p>
align=center>20</td> <td align=center>none</td> <td>Right pad with <TABLE BORDER=1 CELLPADDING=8>
spaces if the logger name is less than 20 characters long. <tr>
<td align=center><b>Format modifier</b></td>
<td align=center><b>left justify</b></td>
<td align=center><b>minimum width</b></td>
<td align=center><b>maximum width</b></td>
<td align=center><b>comment</b></td>
</tr>
<tr> <tr>
<td align=center>\%.30c</td> <td align=center>\%20c</td>
<td align=center>NA</td> <td align=center>false</td>
<td align=center>none</td> <td align=center>20</td>
<td align=center>30</td> <td align=center>none</td>
<td>Truncate from the beginning if the logger name is longer than 30 <td>Left pad with spaces if the logger name is less than 20
characters. characters long.
<tr> <tr> <td align=center>\%-20c</td> <td align=center>true</td> <td
<td align=center>\%20.30c</td> align=center>20</td> <td align=center>none</td> <td>Right pad with
<td align=center>false</td> spaces if the logger name is less than 20 characters long.
<td align=center>20</td>
<td align=center>30</td>
<td>Left pad with spaces if the logger name is shorter than 20 <tr>
characters. However, if logger name is longer than 30 characters, <td align=center>\%.30c</td>
then truncate from the beginning. <td align=center>NA</td>
<td align=center>none</td>
<td align=center>30</td>
<tr> <td>Truncate from the beginning if the logger name is longer than 3
<td align=center>\%-20.30c</td> 0
<td align=center>true</td> characters.
<td align=center>20</td>
<td align=center>30</td>
<td>Right pad with spaces if the logger name is shorter than 20 <tr>
characters. However, if logger name is longer than 30 characters, <td align=center>\%20.30c</td>
then truncate from the beginning. <td align=center>false</td>
<td align=center>20</td>
<td align=center>30</td>
</table> <td>Left pad with spaces if the logger name is shorter than 20
characters. However, if logger name is longer than 30 characters,
then truncate from the beginning.
<p>Below are some examples of conversion patterns. <tr>
<td align=center>\%-20.30c</td>
<td align=center>true</td>
<td align=center>20</td>
<td align=center>30</td>
<p><b>\%r [\%t] \%-5p \%c \%x - \%m\n</b> <td>Right pad with spaces if the logger name is shorter than 20
<p>This is essentially the TTCC layout. characters. However, if logger name is longer than 30 characters,
then truncate from the beginning.
<p><b>\%-6r [\%15.15t] \%-5p \%30.30c \%x - \%m\n</b> </table>
<p>Similar to the TTCC layout except that the relative time is <p>Below are some examples of conversion patterns.
right padded if less than 6 digits, thread name is right padded if
less than 15 characters and truncated if longer and the logger
name is left padded if shorter than 30 characters and truncated if
longer.
<p>The above text is largely inspired from Peter A. Darnell and <p><b>\%r [\%t] \%-5p \%c \%x - \%m\n</b>
Philip E. Margolis' highly recommended book "C -- a Software <p>This is essentially the TTCC layout.
Engineering Approach", ISBN 0-387-97389-3.
*/
class LOG4CXX_EXPORT PatternLayout : public Layout
{
public:
/** Default pattern string for log output. Currently set to
the
string <b>"\%m\%n"</b> which just prints the application sup
plied
message. */
static String DEFAULT_CONVERSION_PATTERN;
/** A conversion pattern equivalent to the TTCCCLayout. <p><b>\%-6r [\%15.15t] \%-5p \%30.30c \%x - \%m\n</b>
Current value is <b>\%r [\%t] \%p \%c \%x - \%m\%n</b>. */
static String TTCC_CONVERSION_PATTERN;
protected: <p>Similar to the TTCC layout except that the relative time is
static int BUF_SIZE; right padded if less than 6 digits, thread name is right padded if
static int MAX_CAPACITY; less than 15 characters and truncated if longer and the logger
name is left padded if shorter than 30 characters and truncated if
longer.
private: <p>The above text is largely inspired from Peter A. Darnell and
// output buffer appended to when format() is invoked Philip E. Margolis' highly recommended book "C -- a Software
StringBuffer sbuf; Engineering Approach", ISBN 0-387-97389-3.
String pattern; */
helpers::PatternConverterPtr head; class LOG4CXX_EXPORT PatternLayout : public Layout
String timeZone; {
/**
* Conversion pattern.
*/
LogString conversionPattern;
public: /**
DECLARE_LOG4CXX_OBJECT(PatternLayout) * Pattern converters.
BEGIN_LOG4CXX_CAST_MAP() */
LOG4CXX_CAST_ENTRY(PatternLayout) LOG4CXX_LIST_DEF(LoggingEventPatternConverterList, log4cxx:
LOG4CXX_CAST_ENTRY_CHAIN(Layout) :pattern::LoggingEventPatternConverterPtr);
END_LOG4CXX_CAST_MAP() LoggingEventPatternConverterList patternConverters;
/** /**
Does nothing * Field widths and alignment corresponding to pattern conve
*/ rters.
PatternLayout(); */
LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::Form
attingInfoPtr);
FormattingInfoList patternFields;
/** public:
Constructs a PatternLayout using the supplied conversion pat DECLARE_LOG4CXX_OBJECT(PatternLayout)
tern. BEGIN_LOG4CXX_CAST_MAP()
*/ LOG4CXX_CAST_ENTRY(PatternLayout)
PatternLayout(const String& pattern); LOG4CXX_CAST_ENTRY_CHAIN(Layout)
END_LOG4CXX_CAST_MAP()
/** /**
Set the <b>ConversionPattern</b> option. This is the string Does nothing
which */
controls formatting and consists of a mix of literal content PatternLayout();
and
conversion specifiers.
*/
void setConversionPattern(const String& conversionPattern);
/** /**
Returns the value of the <b>ConversionPattern</b> option. Constructs a PatternLayout using the supplied conversion pa
*/ ttern.
inline String getConversionPattern() const */
{ return pattern; } PatternLayout(const LogString& pattern);
/** /**
Call createPatternParser Set the <b>ConversionPattern</b> option. This is the string
*/ which
virtual void activateOptions(); controls formatting and consists of a mix of literal conten
t and
conversion specifiers.
*/
void setConversionPattern(const LogString& conversionPatter
n);
virtual void setOption(const String& option, const String& v /**
alue); Returns the value of the <b>ConversionPattern</b> option.
*/
inline LogString getConversionPattern() const
{ return conversionPattern; }
/** /**
The PatternLayout does not handle the throwable contained wi Call createPatternParser
thin */
{@link spi::LoggingEvent LoggingEvents}. Thus, it returns virtual void activateOptions(log4cxx::helpers::Pool& p);
<code>true</code>.
*/
virtual bool ignoresThrowable() const
{ return true; }
/** virtual void setOption(const LogString& option, const LogSt
Produces a formatted string as specified by the conversion p ring& value);
attern.
*/
virtual void format(ostream& output, const spi::LoggingEvent
Ptr& event) const;
/** /**
The <b>TimeZoneID</b> option is a time zone ID string in the The PatternLayout does not handle the throwable contained w
format ithin
expected by the <code>locale</code> C++ standard class. {@link spi::LoggingEvent LoggingEvents}. Thus, it returns
*/ <code>true</code>.
inline void setTimeZone(const String& timeZone) */
{ this->timeZone = timeZone; } virtual bool ignoresThrowable() const
{ return true; }
/** /**
Returns value of the <b>TimeZone</b> option. Produces a formatted string as specified by the conversion
*/ pattern.
inline const String& getTimeZone() const */
{ return timeZone; } virtual void format(LogString& output,
const spi::LoggingEventPtr& event, log4cxx::helpers::P
ool& pool) const;
protected: protected:
/** virtual log4cxx::pattern::PatternMap getFormatSpecifiers();
Returns head of PatternParser used to parse the conversion s };
tring. LOG4CXX_PTR_DEF(PatternLayout);
Subclasses may override this to return a subclass of Pattern
Parser
which recognize custom conversion characters.
*/
virtual helpers::PatternConverterPtr createPatternParser(con
st String& pattern);
};
} // namespace log4cxx } // namespace log4cxx
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#endif //_LOG4CXX_PATTERN_LAYOUT_H #endif //_LOG4CXX_PATTERN_LAYOUT_H
 End of changes. 86 change blocks. 
383 lines changed or deleted 316 lines changed or added


 patternparser.h   patternparser.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_PATTERN_PARSER_H #ifndef _LOG4CXX_HELPER_PATTERN_CONVERTER_H
#define _LOG4CXX_HELPER_PATTERN_PARSER_H #define _LOG4CXX_HELPER_PATTERN_CONVERTER_H
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/formattinginfo.h>
#include <log4cxx/helpers/patternconverter.h>
namespace log4cxx
{
namespace spi
{
class LoggingEvent;
typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr;
}
namespace helpers
{
class DateFormat;
/**
Most of the work of the PatternLayout class
is delegated to the PatternParser class.
<p>It is this class that parses conversion patterns and creates
a chained list of {@link helpers::OptionConverter OptionConverters}.
*/
class LOG4CXX_EXPORT PatternParser
{
protected:
int state;
StringBuffer currentLiteral;
int patternLength;
int i;
PatternConverterPtr head;
PatternConverterPtr tail;
FormattingInfo formattingInfo;
String pattern;
String timeZone;
public:
PatternParser(const String& pattern, const String& t
imeZone);
private:
void addToList(PatternConverterPtr& pc);
protected: #if defined(_MSC_VER)
String extractOption(); #pragma warning (push)
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
/** #include <map>
The option is expected to be in decimal and positive #include <vector>
. In case of #include <log4cxx/helpers/class.h>
error, zero is returned. */ #include <log4cxx/pattern/patternconverter.h>
int extractPrecisionOption(); #include <log4cxx/pattern/formattinginfo.h>
public: namespace log4cxx {
PatternConverterPtr parse(); namespace pattern {
protected: typedef PatternConverterPtr (*PatternConstructor)(const std::vector<LogStri
void finalizeConverter(TCHAR c); ng>& options);
typedef std::map<LogString, PatternConstructor> PatternMap;
void addConverter(PatternConverterPtr& pc); // Contributors: Nelson Minar <(nelson@monkey.org>
// Igor E. Poteryaev <jah@mail.ru>
// Reinhard Deschler <reinhard.deschler@web.de>
// --------------------------------------------------------- /**
------------ * Most of the work of the {@link log4cxx::PatternLayout PatternLayout} cla
// PatternConverters ss
// --------------------------------------------------------- * is delegated to the PatternParser class.
------------ * <p>It is this class that parses conversion patterns and creates
private: * a chained list of {@link PatternConverter PatternConverters}.
class LOG4CXX_EXPORT BasicPatternConverter : public *
PatternConverter *
{ */
private: class LOG4CXX_EXPORT PatternParser {
int type; /**
public: * Escape character for format specifier.
BasicPatternConverter(const FormattingInfo& */
formattingInfo, int type); static const logchar ESCAPE_CHAR;
virtual void convert(ostream& sbuf,
const spi::LoggingEventPtr& event) c
onst;
};
class LOG4CXX_EXPORT LiteralPatternConverter : publi enum {
c PatternConverter LITERAL_STATE = 0,
{ CONVERTER_STATE = 1,
private: DOT_STATE = 3,
String literal; MIN_STATE = 4,
MAX_STATE = 5
};
public: /**
LiteralPatternConverter(const String& value) * Private constructor.
; */
virtual void format(StringBuffer& sbuf, PatternParser();
const spi::LoggingEventPtr& e) const
;
virtual void convert(ostream& sbuf,
const spi::LoggingEventPtr& event) c
onst;
};
class LOG4CXX_EXPORT DatePatternConverter : public P private:
atternConverter /** Extract the converter identifier found at position i.
{ *
private: * After this function returns, the variable i will point to the
DateFormat * df; * first char after the end of the converter identifier.
*
* If i points to a char which is not a character acceptable at the
* start of a unicode identifier, the value null is returned.
*
* @param lastChar last processed character.
* @param pattern format string.
* @param i current index into pattern format.
* @param convBuf buffer to receive conversion specifier.
* @param currentLiteral literal to be output in case format specifier in
unrecognized.
* @return position in pattern after converter.
*/
static int extractConverter(
logchar lastChar, const LogString& pattern,
LogString::size_type i, LogString& convBuf,
LogString& currentLiteral);
public: /**
DatePatternConverter(const FormattingInfo& f * Extract options.
ormattingInfo, * @param pattern conversion pattern.
DateFormat * df); * @param i start of options.
~DatePatternConverter(); * @param options array to receive extracted options
* @return position in pattern after options.
*/
static int extractOptions(const LogString& pattern, LogString::size_type
i,
std::vector<LogString>& options);
public: public:
virtual void convert(ostream& sbuf, /**
const spi::LoggingEventPtr& event) c * Parse a format specifier.
onst; * @param pattern pattern to parse.
}; * @param patternConverters list to receive pattern converters.
* @param formattingInfos list to receive field specifiers corresponding
to pattern converters.
* @param rules map of stock pattern converters keyed by format specifier
.
*/
static void parse(
const LogString& pattern,
std::vector<PatternConverterPtr>& patternConverters,
std::vector<FormattingInfoPtr>& formattingInfos,
const PatternMap& rules);
class LOG4CXX_EXPORT MDCPatternConverter : public Pa private:
tternConverter /**
{ * Creates a new PatternConverter.
private: *
String key; *
* @param converterId converterId.
* @param currentLiteral literal to be used if converter is unrecognized
or following converter
* if converterId contains extra characters.
* @param rules map of stock pattern converters keyed by format specifier
.
* @param options converter options.
* @return converter or null.
*/
static PatternConverterPtr createConverter(
const LogString& converterId,
LogString& currentLiteral,
const PatternMap& rules,
std::vector<LogString>& options);
public: /**
MDCPatternConverter(const FormattingInfo& fo * Processes a format specifier sequence.
rmattingInfo, *
const String& key); * @param c initial character of format specifier.
virtual void convert(ostream& sbuf, * @param pattern conversion pattern
const spi::LoggingEventPtr& event) c * @param i current position in conversion pattern.
onst; * @param currentLiteral current literal.
}; * @param formattingInfo current field specifier.
* @param rules map of stock pattern converters keyed by format specifier
.
* @param patternConverters list to receive parsed pattern converter.
* @param formattingInfos list to receive corresponding field specifier.
* @return position after format specifier sequence.
*/
static int finalizeConverter(
logchar c, const LogString& pattern, int i,
LogString& currentLiteral, const FormattingInfoPtr& formattingInfo,
const PatternMap& rules,
std::vector<PatternConverterPtr>& patternConverters,
std::vector<FormattingInfoPtr>& formattingInfos);
class LOG4CXX_EXPORT LocationPatternConverter : publ static bool isUnicodeIdentifierStart(logchar c);
ic PatternConverter static bool isUnicodeIdentifierPart(logchar c);
{
private:
int type;
public: };
LocationPatternConverter(const FormattingInf
o& formattingInfo, int type);
virtual void convert(ostream& sbuf,
const spi::LoggingEventPtr& event) c
onst;
};
class LOG4CXX_EXPORT CategoryPatternConverter : publ }
ic PatternConverter }
{
private:
int precision;
public: #if defined(_MSC_VER)
CategoryPatternConverter(const FormattingInf #pragma warning (pop)
o& formattingInfo, #endif
int precision);
virtual void convert(ostream& sbuf,
const spi::LoggingEventPtr& event) c
onst;
};
}; // class PatternParser
} // namespace helpers
}; // namespace log4cxx
#endif //_LOG4CXX_HELPER_PATTERN_PARSER_H #endif
 End of changes. 20 change blocks. 
154 lines changed or deleted 143 lines changed or added


 properties.h   properties.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_PROPERTIES_H #ifndef _LOG4CXX_HELPER_PROPERTIES_H
#define _LOG4CXX_HELPER_PROPERTIES_H #define _LOG4CXX_HELPER_PROPERTIES_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 <log4cxx/helpers/objectimpl.h> #include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/inputstream.h>
#include <map> #include <map>
#include <vector> #include <vector>
#include <istream>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class LOG4CXX_EXPORT Properties class LOG4CXX_EXPORT Properties
{ {
private: private:
std::map<String, String> properties; typedef std::map<LogString, LogString> PropertyMap;
PropertyMap* properties;
Properties(const Properties&);
Properties& operator=(const Properties&);
public: public:
/** /**
Reads a property list (key and element pairs) from t * Create new instance.
he input stream. */
The stream is assumed to be using the ISO 8859-1 cha Properties();
racter encoding. /**
* Destructor.
*/
~Properties();
/**
Reads a property list (key and element pairs) from
the input stream.
The stream is assumed to be using the ISO 8859-1 ch
aracter encoding.
<p>Every property occupies one line of the input str <p>Every property occupies one line of the input st
eam. ream.
Each line is terminated by a line terminator (<code> Each line is terminated by a line terminator (<code
\\n</code> or >\\n</code> or
<code>\r</code> or <code>\r\\n</code>). <code>\\r</code> or <code>\\r\\n</code>).
Lines from the input stream are processed until end Lines from the input stream are processed until end
of file is reached of file is reached
on the input stream. on the input stream.
<p>A line that contains only whitespace or whose fir <p>A line that contains only whitespace or whose fi
st non-whitespace rst non-whitespace
character is an ASCII <code>#</code> or <code>!</cod character is an ASCII <code>#</code> or <code>!</co
e> is ignored de> is ignored
(thus, <code>#</code> or <code>!</code> indicate com (thus, <code>#</code> or <code>!</code> indicate co
ment lines). mment lines).
<p>Every line other than a blank line or a comment l <p>Every line other than a blank line or a comment
ine describes one line describes one
property to be added to the table (except that if a property to be added to the table (except that if a
line ends with \, line ends with \,
then the following line, if it exists, is treated as then the following line, if it exists, is treated a
a continuation s a continuation
line, as described below). The key consists of all t line, as described below). The key consists of all
he characters in the characters in
the line starting with the first non-whitespace char the line starting with the first non-whitespace cha
acter and up to, racter and up to,
but not including, the first ASCII <code>=</code but not including, the first ASCII <code>=</code>
>, <code>:</code>, , <code>:</code>,
or whitespace character. All of the or whitespace character. All of the
key termination characters may be included in the ke key termination characters may be included in the k
y by preceding them ey by preceding them
with a <code>\\</code>. Any whitespace after the key with a <code>\\</code>. Any whitespace after the ke
is skipped; y is skipped;
if the first if the first
non-whitespace character after the key is <code>=</c non-whitespace character after the key is <code>=</
ode> or code> or
<code>:</code>, then it is ignored <code>:</code>, then it is ignored
and any whitespace characters after it are also skip and any whitespace characters after it are also ski
ped. All remaining pped. All remaining
characters on the line become part of the associated characters on the line become part of the associate
element string. d element string.
Within the element string, the ASCII escape sequence Within the element string, the ASCII escape sequenc
s <code>\t</code>, es <code>\\t</code>,
<code>\\n</code>, <code>\r</code>, <code>\\</code>, <code>\\n</code>, <code>\\r</code>, <code>\\</code>
<code>\"</code>, , <code>\\"</code>,
<code>\'</code>, <code>\\</code> (a backslash and a <code>\\'</code>, <code>\\</code> (a backslash and
space), and a space), and
<code>\uxxxx</code> are recognized <code>\\uxxxx</code> are recognized
and converted to single characters. Moreover, if the and converted to single characters. Moreover, if th
last character on e last character on
the line is <code>\\</code>, then the next line is t the line is <code>\\</code>, then the next line is
reated as a treated as a
continuation of the continuation of the
current line; the <code>\\</code> and line terminato current line; the <code>\\</code> and line terminat
r are simply or are simply
discarded, and any discarded, and any
leading whitespace characters on the continuation li leading whitespace characters on the continuation l
ne are also ine are also
discarded and are not part of the element string. discarded and are not part of the element string.
<p>As an example, each of the following four lines s <p>As an example, each of the following four lines
pecifies the key specifies the key
"Truth" and the associated element value "Beauty": "Truth" and the associated element value "Beauty":
<pre> <pre>
Truth = Beauty Truth = Beauty
Truth:Beauty Truth:Beauty
Truth :Beauty Truth :Beauty
</pre> </pre>
As another example, the following three lines specify a sing As another example, the following three lines specify a sin
le gle
property: property:
<pre> <pre>
fruits apple, banana, pear, \ fruits apple, banana, pear, \
cantaloupe, watermelon, \ cantaloupe, watermelon, \
kiwi, mango kiwi, mango
</pre> </pre>
The key is "<code>fruits</code>" and the associated The key is "<code>fruits</code>" and the associated
element is: element is:
<pre> <pre>
"apple, banana, pear, cantaloupe, watermelon, kiwi, mango" "apple, banana, pear, cantaloupe, watermelon, kiwi, mango"
</pre> </pre>
Note that a space appears before each \ so that a sp Note that a space appears before each \ so that a s
ace will appear pace will appear
after each comma in the final result; the \, line te after each comma in the final result; the \, line t
rminator, and erminator, and
leading whitespace on the continuation line are mere leading whitespace on the continuation line are mer
ly discarded and are ely discarded and are
not replaced by one or more other characters. not replaced by one or more other characters.
<p>As a third example, the line: <p>As a third example, the line:
<pre> <pre>
cheeses cheeses
</pre> </pre>
specifies that the key is "<code>cheeses</code>" and specifies that the key is "<code>cheeses</code>" an
the associated d the associated
element is the empty string. element is the empty string.
@param inStream the input stream. @param inStream the input stream.
@throw IOException if an error occurred when reading @throw IOException if an error occurred when readin
from the input g from the input
stream. stream.
*/ */
void load(istream& inStream); void load(InputStreamPtr inStream);
/** /**
Calls the Hashtable method put. Provided for paralle * Calls Properties::put.
lism with the * @param key the key to be placed into this prop
getProperty method. Enforces use of strings for prop erty list.
erty keys and * @param value the value corresponding to key.
values. The value returned is the result of the Hash * @return the previous value of the specified ke
table call to y in this
put. * property list, or an empty string if it did no
@param key the key to be placed into this property l t have one.
ist. */
@param value the value corresponding to key. LogString setProperty(const LogString& key, const L
@return the previous value of the specified key in this ogString& value);
property list, or an empty string if it did not have /**
one. * Puts a property value into the collection.
*/ * @param key the key to be placed into this prop
String setProperty(const String& key, const String& erty list.
value); * @param value the value corresponding to key.
* @return the previous value of the specified ke
y in this
* property list, or an empty string if it did no
t have one.
*/
LogString put(const LogString& key, const LogString
& value);
/** /**
Searches for the property with the specified key in * Calls Properties::get.
this property * @param key the property key.
list. If the key is not found in this property list, * @return the value in this property list with the
the default specified
property list, and its defaults, recursively, are th * key value or empty string.
en checked. */
The method returns an empty string if the property i LogString getProperty(const LogString& key) const;
s not found. /**
@param key the property key. * Gets a property value.
@return the value in this property list with the specified * @param key the property key.
key value. * @return the value in this property list with the
*/ specified
String getProperty(const String& key) const; * key value or empty string.
*/
LogString get(const LogString& key) const;
/** /**
Returns an enumeration of all the keys in this prope Returns an enumeration of all the keys in this prop
rty list, erty list,
including distinct keys in the default property list including distinct keys in the default property lis
if a key t if a key
of the same name has not already been found from the of the same name has not already been found from th
main e main
properties list. properties list.
@return an array of all the keys in this @return an array of all the keys in this
property list, including the keys in the default pro property list, including the keys in the default pr
perty list. operty list.
*/ */
std::vector<String> propertyNames() const; std::vector<LogString> propertyNames() const;
}; // class Properties }; // class Properties
} // namespace helpers } // namespace helpers
}; // namespace log4cxx } // namespace log4cxx
#if defined(_MSC_VER)
#pragma warning (pop)
#endif
#endif //_LOG4CXX_HELPER_PROPERTIES_H #endif //_LOG4CXX_HELPER_PROPERTIES_H
 End of changes. 22 change blocks. 
158 lines changed or deleted 190 lines changed or added


 propertyconfigurator.h   propertyconfigurator.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_PROPERTY_CONFIGURATOR_H #ifndef _LOG4CXX_PROPERTY_CONFIGURATOR_H
#define _LOG4CXX_PROPERTY_CONFIGURATOR_H #define _LOG4CXX_PROPERTY_CONFIGURATOR_H
#if defined(_MSC_VER)
#pragma warning (push)
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#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/logstring.h>
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/spi/configurator.h> #include <log4cxx/spi/configurator.h>
#include <map> #include <map>
#include <log4cxx/file.h>
namespace log4cxx namespace log4cxx
{ {
class Logger; class Logger;
typedef helpers::ObjectPtrT<Logger> LoggerPtr; typedef helpers::ObjectPtrT<Logger> LoggerPtr;
class Appender;
typedef helpers::ObjectPtrT<Appender> AppenderPtr;
namespace spi class Appender;
{ typedef helpers::ObjectPtrT<Appender> AppenderPtr;
class LoggerFactory;
typedef helpers::ObjectPtrT<LoggerFactory> LoggerFactoryPtr;
class LoggerRepository; namespace helpers
typedef helpers::ObjectPtrT<LoggerRepository> LoggerReposito {
ryPtr; class Properties;
} }
namespace helpers namespace spi {
{ class LoggerFactory;
class Properties; }
}
/** /**
Allows the configuration of log4cxx from an external file. See Allows the configuration of log4cxx from an external file. See
<b>{@link #doConfigure(const String&, spi::LoggerRepositoryPtr&)}</b> <b>{@link #doConfigure(const File&, log4cxx::spi::LoggerRepositoryPtr&)}</b >
for the expected format. for the expected format.
<p>It is sometimes useful to see how log4cxx is reading configuration <p>It is sometimes useful to see how log4cxx is reading configuration
files. You can enable log4cxx internal logging by defining the files. You can enable log4cxx internal logging by defining the
<b>log4j.debug</b> variable. <b>log4j.debug</b> variable.
<P>At class initialization time class, <P>At class initialization time class,
the file <b>log4j.properties</b> will be searched in the current directory. the file <b>log4j.properties</b> will be searched in the current directory.
If the file can be found, then it will If the file can be found, then it will
be fed to the be fed to the
{@link PropertyConfigurator#configure(const String& configFilename)} {@link PropertyConfigurator#configure(const File& configFilename)}
method. method.
<p>The <code>PropertyConfigurator</code> does not handle the <p>The <code>PropertyConfigurator</code> does not handle the
advanced configuration features supported by the {@link advanced configuration features supported by the {@link
xml::DOMConfigurator DOMConfigurator} such as xml::DOMConfigurator DOMConfigurator} such as
support for {@link spi::Filter Filters}, custom support for {@link spi::Filter Filters}, custom
{@link spi::ErrorHandler ErrorHandlers}, nested {@link spi::ErrorHandler ErrorHandlers}, nested
appenders such as the {@link AsyncAppender appenders such as the {@link AsyncAppender
AsyncAppender}, etc. AsyncAppender}, etc.
skipping to change at line 87 skipping to change at line 89
the substituted variable can be defined as a system property or in the substituted variable can be defined as a system property or in
the configuration file itself. The value of the key is first the configuration file itself. The value of the key is first
searched in the system properties, and if not found there, it is searched in the system properties, and if not found there, it is
then searched in the configuration file being parsed. The then searched in the configuration file being parsed. The
corresponding value replaces the ${variableName} sequence. For corresponding value replaces the ${variableName} sequence. For
example, if <code>java.home</code> system property is set to example, if <code>java.home</code> system property is set to
<code>/home/xyz</code>, then every occurrence of the sequence <code>/home/xyz</code>, then every occurrence of the sequence
<code>${java.home}</code> will be interpreted as <code>${java.home}</code> will be interpreted as
<code>/home/xyz</code>. <code>/home/xyz</code>.
*/ */
class LOG4CXX_EXPORT PropertyConfigurator : class LOG4CXX_EXPORT PropertyConfigurator :
virtual public spi::Configurator, virtual public spi::Configurator,
virtual public helpers::ObjectImpl virtual public helpers::ObjectImpl
{ {
protected: protected:
static String CATEGORY_PREFIX;
static String LOGGER_PREFIX;
static String FACTORY_PREFIX;
static String ADDITIVITY_PREFIX;
static String ROOT_CATEGORY_PREFIX;
static String ROOT_LOGGER_PREFIX;
static String APPENDER_PREFIX;
static String RENDERER_PREFIX;
static String THRESHOLD_PREFIX;
/* Key for specifying the {@link spi::LoggerFactory /**
LoggerFactory}. Currently set to "<code>log4j.logge Used internally to keep track of configured appenders.
rFactory</code>". */ */
static String LOGGER_FACTORY_KEY; std::map<LogString, AppenderPtr>* registry;
static String INTERNAL_ROOT_NAME;
/** /**
Used internally to keep track of configured appenders. Used to create new instances of logger
*/ */
std::map<String, AppenderPtr> registry; helpers::ObjectPtrT<spi::LoggerFactory> loggerFactory;
spi::LoggerFactoryPtr loggerFactory;
public: public:
DECLARE_LOG4CXX_OBJECT(PropertyConfigurator) DECLARE_LOG4CXX_OBJECT(PropertyConfigurator)
BEGIN_LOG4CXX_CAST_MAP() BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(spi::Configurator) LOG4CXX_CAST_ENTRY(spi::Configurator)
END_LOG4CXX_CAST_MAP() END_LOG4CXX_CAST_MAP()
PropertyConfigurator(); PropertyConfigurator();
virtual ~PropertyConfigurator();
void addRef() const;
void releaseRef() const;
/** /**
Read configuration from a file. <b>The existing configuration is Read configuration from a file. <b>The existing configuration is
not cleared nor reset.</b> If you require a different behavior, not cleared nor reset.</b> If you require a different behavior,
then call {@link LogManager#resetConfiguration then call {@link LogManager#resetConfiguration
resetConfiguration} method before calling resetConfiguration} method before calling
<code>doConfigure</code>. <code>doConfigure</code>.
<p>The configuration file consists of statements in the format <p>The configuration file consists of statements in the format
<code>key=value</code>. The syntax of different configuration <code>key=value</code>. The syntax of different configuration
skipping to change at line 219 skipping to change at line 214
<p>By default categories inherit their level from the <p>By default categories inherit their level from the
hierarchy. However, if you set the level of a logger and later hierarchy. However, if you set the level of a logger and later
decide that that logger should inherit its level, then you should decide that that logger should inherit its level, then you should
specify INHERITED as the value for the level value. NULL is a specify INHERITED as the value for the level value. NULL is a
synonym for INHERITED. synonym for INHERITED.
<p>Similar to the root logger syntax, each <i>appenderName</i> <p>Similar to the root logger syntax, each <i>appenderName</i>
(separated by commas) will be attached to the named logger. (separated by commas) will be attached to the named logger.
<p>See the <a href="../../../../manual.html#additivity">appender <p>See the <a href="Introduction.html#additivity">appender
additivity rule</a> in the user manual for the meaning of the additivity rule</a> in the user manual for the meaning of the
<code>additivity</code> flag. <code>additivity</code> flag.
<h3>Logger Factories</h3> <h3>Logger Factories</h3>
The usage of custom logger factories is discouraged and no longer The usage of custom logger factories is discouraged and no longer
documented. documented.
<h3>Example</h3> <h3>Example</h3>
skipping to change at line 295 skipping to change at line 290
Layout for class specific options. Layout for class specific options.
<p>Use the <code>#</code> or <code>!</code> characters at the <p>Use the <code>#</code> or <code>!</code> characters at the
beginning of a line for comments. beginning of a line for comments.
<p> <p>
@param configFileName The name of the configuration file where the @param configFileName The name of the configuration file where the
configuration information is stored. configuration information is stored.
@param hierarchy The hierarchy to operation upon. @param hierarchy The hierarchy to operation upon.
*/ */
void doConfigure(const String& configFileName, void doConfigure(const File& configFileName,
spi::LoggerRepositoryPtr& hierarchy); spi::LoggerRepositoryPtr& hierarchy);
/** /**
Read configuration options from file <code>configFilename</c Read configuration options from file <code>configFilename</code>.
ode>. */
*/ static void configure(const File& configFilename);
static void configure(const String& configFilename);
/** /**
Like {@link #configureAndWatch(const String& configFilename, Like {@link #configureAndWatch(const File& configFilename, long delay
long delay)} )}
except that the except that the
default delay as defined by helpers::FileWatchdog#DEFAULT_DE default delay as defined by helpers::FileWatchdog#DEFAULT_DELAY
LAY is used.
is used. @param configFilename A file in key=value format.
@param configFilename A file in key=value format. */
*/ static void configureAndWatch(const File& configFilename);
static void configureAndWatch(const String& configFilename);
/** /**
Read the configuration file <code>configFilename</code> if i Read the configuration file <code>configFilename</code> if it
t exists. Moreover, a thread will be created that will periodically
exists. Moreover, a thread will be created that will periodi check if <code>configFilename</code> has been created or
cally modified. The period is determined by the <code>delay</code>
check if <code>configFilename</code> has been created or argument. If a change or file creation is detected, then
modified. The period is determined by the <code>delay</code> <code>configFilename</code> is read to configure log4j.
argument. If a change or file creation is detected, then
<code>configFilename</code> is read to configure log4j.
@param configFilename A file in key=value format. @param configFilename A file in key=value format.
@param delay The delay in milliseconds to wait between each @param delay The delay in milliseconds to wait between each check.
check. */
*/ static void configureAndWatch(const File& configFilename,
static void configureAndWatch(const String& configFilename, long delay);
long delay);
/** /**
Read configuration options from <code>properties</code>. Read configuration options from <code>properties</code>.
See #doConfigure(const string&, spi::LoggerRepositoryPtr&) See #doConfigure(const File&, log4cxx::spi::LoggerRepositoryPtr&)
for the expected format. for the expected format.
*/ */
static void configure(helpers::Properties& properties); static void configure(helpers::Properties& properties);
/** /**
Read configuration options from <code>properties</code>. Read configuration options from <code>properties</code>.
See #doConfigure(const String&, spi::LoggerRepositoryPtr&) See #doConfigure(const File&, log4cxx::spi::LoggerRepositoryPtr&)
for the expected format. for the expected format.
*/ */
void doConfigure(helpers::Properties& properties, void doConfigure(helpers::Properties& properties,
spi::LoggerRepositoryPtr& hierarchy); spi::LoggerRepositoryPtr& hierarchy);
// ------------------------------------------------------------------------ -- // ------------------------------------------------------------------------ --
// Internal stuff // Internal stuff
// ------------------------------------------------------------------------ -- // ------------------------------------------------------------------------ --
protected: protected:
/** /**
Check the provided <code>Properties</code> object for a Check the provided <code>Properties</code> object for a
#LoggerFactory #loggerFactory
entry specified by #LOGGER_FACTORY_KEY. If such an entry entry specified by LOGGER_FACTORY_KEY. If such an entry
exists, an attempt is made to create an instance using the d exists, an attempt is made to create an instance using the default
efault constructor. This instance is used for subsequent Logger creations
constructor. This instance is used for subsequent Logger cr within this configurator.
eations @see #parseCatsAndRenderers
within this configurator. */
@see #parseCatsAndRenderers void configureLoggerFactory(helpers::Properties& props);
*/
void configureLoggerFactory(helpers::Properties& props);
void configureRootCategory(helpers::Properties& props, void configureRootLogger(helpers::Properties& props,
spi::LoggerRepositoryPtr& hierarchy); spi::LoggerRepositoryPtr& hierarchy);
/** /**
Parse non-root elements, such non-root categories and render Parse non-root elements, such non-root categories and renderers.
ers. */
*/ void parseCatsAndRenderers(helpers::Properties& props,
void parseCatsAndRenderers(helpers::Properties& props, spi::LoggerRepositoryPtr& hierarchy);
spi::LoggerRepositoryPtr& hierarchy);
/** /**
Parse the additivity option for a non-root logger. Parse the additivity option for a non-root logger.
*/ */
void parseAdditivityForLogger(helpers::Properties& props, void parseAdditivityForLogger(helpers::Properties& props,
LoggerPtr& cat, const String& loggerName); LoggerPtr& cat, const LogString& loggerName);
/** /**
This method must work for the root logger as well. This method must work for the root logger as well.
*/ */
void parseCategory( void parseLogger(
helpers::Properties& props, LoggerPtr& logger, helpers::Properties& props, LoggerPtr& logger,
const String& optionKey, const String& loggerName, const LogString& optionKey, const LogString& loggerName,
const String& value); const LogString& value);
AppenderPtr parseAppender( AppenderPtr parseAppender(
helpers::Properties& props, const String& appenderNa helpers::Properties& props, const LogString& appenderName);
me);
void registryPut(const AppenderPtr& appender); void registryPut(const AppenderPtr& appender);
AppenderPtr registryGet(const String& name); AppenderPtr registryGet(const LogString& name);
}; // class PropertyConfigurator
private:
PropertyConfigurator(const PropertyConfigurator&);
PropertyConfigurator& operator=(const PropertyConfigurator&);
}; // class PropertyConfigurator
} // namespace log4cxx } // namespace log4cxx
#if defined(_MSC_VER)
#pragma warning (pop)
#endif
#endif //_LOG4CXX_PROPERTY_CONFIGURATOR_H #endif //_LOG4CXX_PROPERTY_CONFIGURATOR_H
 End of changes. 31 change blocks. 
140 lines changed or deleted 132 lines changed or added


 propertyresourcebundle.h   propertyresourcebundle.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_PROPERTY_RESOURCE_BUNDLE_H #ifndef _LOG4CXX_HELPERS_PROPERTY_RESOURCE_BUNDLE_H
#define _LOG4CXX_HELPERS_PROPERTY_RESOURCE_BUNDLE_H #define _LOG4CXX_HELPERS_PROPERTY_RESOURCE_BUNDLE_H
#include <log4cxx/helpers/resourcebundle.h> #include <log4cxx/helpers/resourcebundle.h>
#include <log4cxx/helpers/properties.h> #include <log4cxx/helpers/properties.h>
#include <log4cxx/helpers/inputstream.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class PropertyResourceBundle;
typedef ObjectPtrT<PropertyResourceBundle> PropertyResourceB
undlePtr;
/** /**
PropertyResourceBundle is a concrete subclass of ResourceBun PropertyResourceBundle is a concrete subclass of ResourceBu
dle that ndle that
manages resources for a locale using a set of static strings manages resources for a locale using a set of static string
from a s from a
property file. property file.
*/ */
class LOG4CXX_EXPORT PropertyResourceBundle : public Resourc class LOG4CXX_EXPORT PropertyResourceBundle : public Resour
eBundle ceBundle
{ {
public: public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(PropertyResourceBund DECLARE_ABSTRACT_LOG4CXX_OBJECT(PropertyResourceBun
le) dle)
BEGIN_LOG4CXX_CAST_MAP() BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(PropertyResourceBundle) LOG4CXX_CAST_ENTRY(PropertyResourceBundle)
LOG4CXX_CAST_ENTRY_CHAIN(ResourceBundle) LOG4CXX_CAST_ENTRY_CHAIN(ResourceBundle)
END_LOG4CXX_CAST_MAP() END_LOG4CXX_CAST_MAP()
/** /**
Creates a property resource bundle. Creates a property resource bundle.
@param inStream property file to read from. @param inStream property file to read from.
@throw IOException if an error occurred when reading @throw IOException if an error occurred when readin
from the g from the
input stream. input stream.
*/ */
PropertyResourceBundle(istream& inStream); PropertyResourceBundle(InputStreamPtr inStream);
virtual String getString(const String& key) const; virtual LogString getString(const LogString& key) c onst;
protected: protected:
Properties properties; Properties properties;
}; // class PropertyResourceBundle }; // class PropertyResourceBundle
} // namespace helpers LOG4CXX_PTR_DEF(PropertyResourceBundle);
}; // namespace log4cxx } // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_PROPERTY_RESOURCE_BUNDLE_H #endif // _LOG4CXX_HELPERS_PROPERTY_RESOURCE_BUNDLE_H
 End of changes. 7 change blocks. 
41 lines changed or deleted 41 lines changed or added


 propertysetter.h   propertysetter.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_CONFIG_PROPERTYSETTER_H #ifndef _LOG4CXX_CONFIG_PROPERTYSETTER_H
#define _LOG4CXX_CONFIG_PROPERTYSETTER_H #define _LOG4CXX_CONFIG_PROPERTYSETTER_H
#include <log4cxx/helpers/tchar.h> #include <log4cxx/logstring.h>
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class Object; class Object;
typedef ObjectPtrT<Object> ObjectPtr; typedef ObjectPtrT<Object> ObjectPtr;
class Properties; class Properties;
} class Pool;
}
namespace config namespace config
{ {
/** /**
General purpose Object property setter. Clients repeatedly invokes General purpose Object property setter. Clients repeatedly
{@link #setProperty setProperty(name,value)} in order to invoke setters invokes
on the Object specified in the constructor. {@link #setProperty setProperty(name,value)} in order to in
voke setters
on the Object specified in the constructor.
<p>Usage: <p>Usage:
<pre> <pre>
PropertySetter ps(anObject); PropertySetter ps(anObject);
ps.set("name", "Joe"); ps.set("name", "Joe");
ps.set("age", "32"); ps.set("age", "32");
ps.set("isMale", "true"); ps.set("isMale", "true");
</pre> </pre>
will cause the invocations anObject->setOption("name", "Joe"), will cause the invocations anObject->setOption("name", "Joe
anObject->setOption("age", "32") and anObject->setOption("isMale", "true") "),
if the spi::OptionHandler interface is supported by anObject. anObject->setOption("age", "32") and anObject->setOption("i
*/ sMale", "true")
class LOG4CXX_EXPORT PropertySetter if the spi::OptionHandler interface is supported by anObjec
{ t.
protected: */
helpers::ObjectPtr obj; class LOG4CXX_EXPORT PropertySetter
{
protected:
helpers::ObjectPtr obj;
public: public:
/** /**
Create a new PropertySetter for the specified Object. This is done Create a new PropertySetter for the specified Objec
in prepartion for invoking #setProperty one or more times. t. This is done
in prepartion for invoking #setProperty one or more
times.
@param obj the object for which to set properties @param obj the object for which to set properties
*/ */
PropertySetter(helpers::ObjectPtr obj); PropertySetter(const helpers::ObjectPtr& obj);
/** /**
Set the properties of an object passed as a parameter in one Set the properties of an object passed as a paramet
go. The <code>properties</code> are parsed relative to a er in one
<code>prefix</code>. go. The <code>properties</code> are parsed relative
to a
<code>prefix</code>.
@param obj The object to configure. @param obj The object to configure.
@param properties A java.util.Properties containing keys and values. @param properties A java.util.Properties containing
@param prefix Only keys having the specified prefix will be set. keys and values.
*/ @param prefix Only keys having the specified prefix
static void setProperties(helpers::ObjectPtr obj, will be set.
helpers::Properties& properties, const Strin @param p pool to use for any allocations required d
g& prefix); uring call.
*/
static void setProperties(const helpers::ObjectPtr&
obj,
helpers::Properties& properties,
const LogString& prefix,
log4cxx::helpers::Pool& p);
/** /**
Set the properites for the object that match the Set the properites for the object that match the
<code>prefix</code> passed as parameter. <code>prefix</code> passed as parameter.
*/ */
void setProperties(helpers::Properties& properties, void setProperties(helpers::Properties& properties,
const String& prefix); const LogString& prefix,
log4cxx::helpers::Pool& p);
/** /**
Set a property on this PropertySetter's Object. If the underlying Set a property on this PropertySetter's Object. If
Object supports the spi::OptionHandler interface, the the underlying
{@link spi::OptionHandler#setOption setOption} method is called. Object supports the spi::OptionHandler interface, t
he
{@link spi::OptionHandler#setOption setOption} meth
od is called.
@param name name of the property @param option name of the property
@param value String value of the property @param value String value of the property
*/ @param p pool to use for any allocations required d
void setProperty(const String& name, const String& v uring call.
alue); */
void setProperty(const LogString& option,
const LogString& value,
log4cxx::helpers::Pool& p);
void activate(); void activate(log4cxx::helpers::Pool& p);
}; // class PropertySetter }; // class PropertySetter
} // namespace config; } // namespace config;
}; // namespace log4cxx } // namespace log4cxx
#endif //_LOG4CXX_CONFIG_PROPERTYSETTER_H #endif //_LOG4CXX_CONFIG_PROPERTYSETTER_H
 End of changes. 14 change blocks. 
70 lines changed or deleted 94 lines changed or added


 provisionnode.h   provisionnode.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 29 skipping to change at line 30
#include <vector> #include <vector>
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
#include <log4cxx/logger.h> #include <log4cxx/logger.h>
namespace log4cxx namespace log4cxx
{ {
class Logger; class Logger;
typedef helpers::ObjectPtrT<Logger> LoggerPtr; typedef helpers::ObjectPtrT<Logger> LoggerPtr;
class ProvisionNode : public std::vector<LoggerPtr> typedef std::vector<LoggerPtr> ProvisionNode;
{
public:
ProvisionNode(const LoggerPtr& logger)
{
push_back(logger);
}
}; // class LogManager
} // namespace log4cxx } // namespace log4cxx
#endif //_LOG4CXX_PROVISION_NODE_H #endif //_LOG4CXX_PROVISION_NODE_H
 End of changes. 2 change blocks. 
13 lines changed or deleted 8 lines changed or added


 relativetimedateformat.h   relativetimedateformat.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_RELATIVE_TIME_DATE_FORMAT_H #ifndef _LOG4CXX_HELPERS_RELATIVE_TIME_DATE_FORMAT_H
#define _LOG4CXX_HELPERS_RELATIVE_TIME_DATE_FORMAT_H #define _LOG4CXX_HELPERS_RELATIVE_TIME_DATE_FORMAT_H
#include <log4cxx/helpers/dateformat.h> #include <log4cxx/helpers/dateformat.h>
#include <log4cxx/helpers/system.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
/** /**
Formats a date by printing the number of seconds Formats a date by printing the number of seconds
elapsed since the start of the application. This is the fast elapsed since the start of the application. This is the fas
est test
printing DateFormat in the package. printing DateFormat in the package.
*/ */
class LOG4CXX_EXPORT RelativeTimeDateFormat : public DateFor class LOG4CXX_EXPORT RelativeTimeDateFormat : public DateFo
mat rmat
{ {
protected: public:
int64_t startTime; RelativeTimeDateFormat();
virtual void format(LogString &s,
log4cxx_time_t tm,
log4cxx::helpers::Pool& p) const;
public: private:
RelativeTimeDateFormat() log4cxx_time_t startTime;
: DateFormat(_T(""), 0), startTime(System::currentT
imeMillis())
{
}
virtual void format(ostream& os, int64_t time) const };
{ } // namespace helpers
os << (time - startTime); } // namespace log4cxx
}
};
} // namespace helpers
}; // namespace log4cxx
#endif // _LOG4CXX_HELPERS_RELATIVE_TIME_DATE_FORMAT_H #endif // _LOG4CXX_HELPERS_RELATIVE_TIME_DATE_FORMAT_H
 End of changes. 5 change blocks. 
32 lines changed or deleted 27 lines changed or added


 repositoryselector.h   repositoryselector.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_REPOSITORY_SELECTOR_H #ifndef _LOG4CXX_SPI_REPOSITORY_SELECTOR_H
#define _LOG4CXX_SPI_REPOSITORY_SELECTOR_H #define _LOG4CXX_SPI_REPOSITORY_SELECTOR_H
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/object.h> #include <log4cxx/helpers/object.h>
namespace log4cxx namespace log4cxx
{ {
namespace spi namespace spi
{ {
class LoggerRepository; class LoggerRepository;
typedef helpers::ObjectPtrT<LoggerRepository> LoggerReposito typedef helpers::ObjectPtrT<LoggerRepository> LoggerReposit
ryPtr; oryPtr;
class RepositorySelector;
typedef helpers::ObjectPtrT<RepositorySelector> RepositorySe
lectorPtr;
/** /**
The <code>LogManager</code> uses one (and only one) The <code>LogManager</code> uses one (and only one)
<code>RepositorySelector</code> implementation to select the <code>RepositorySelector</code> implementation to select the
{@link LoggerRepository LoggerRepository} {@link log4cxx::spi::LoggerRepository LoggerRepository}
for a particular application context. for a particular application context.
<p>It is the responsability of the <code>RepositorySelector</code> <p>It is the responsability of the <code>RepositorySelector</code>
implementation to track the application context. log4cxx makes no implementation to track the application context. log4cxx makes no
assumptions about the application context or on its management. assumptions about the application context or on its management.
<p>See also LogManager. <p>See also LogManager.
*/ */
class LOG4CXX_EXPORT RepositorySelector : public virtual hel class LOG4CXX_EXPORT RepositorySelector : public virtual he
pers::Object lpers::Object
{ {
public: public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(RepositorySelector) DECLARE_ABSTRACT_LOG4CXX_OBJECT(RepositorySelector)
virtual ~RepositorySelector() {} virtual ~RepositorySelector() {}
virtual LoggerRepositoryPtr& getLoggerRepository() = virtual LoggerRepositoryPtr& getLoggerRepository()
0; = 0;
}; };
} //namespace spi LOG4CXX_PTR_DEF(RepositorySelector);
}; //namespace log4cxx } //namespace spi
} //namespace log4cxx
#endif //_LOG4CXX_SPI_REPOSITORY_SELECTOR_H #endif //_LOG4CXX_SPI_REPOSITORY_SELECTOR_H
 End of changes. 4 change blocks. 
27 lines changed or deleted 25 lines changed or added


 resourcebundle.h   resourcebundle.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_RESOURCE_BUNDLE_H #ifndef _LOG4CXX_HELPERS_RESOURCE_BUNDLE_H
#define _LOG4CXX_HELPERS_RESOURCE_BUNDLE_H #define _LOG4CXX_HELPERS_RESOURCE_BUNDLE_H
#include <log4cxx/helpers/objectimpl.h> #include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/exception.h>
#include <log4cxx/helpers/locale.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class LOG4CXX_EXPORT MissingResourceException : public Excep class Locale;
tion
{
};
class ResourceBundle; class ResourceBundle;
typedef ObjectPtrT<ResourceBundle> ResourceBundlePtr; LOG4CXX_PTR_DEF(ResourceBundle);
/** /**
Resource bundles contain locale-specific objects Resource bundles contain locale-specific objects
*/ */
class LOG4CXX_EXPORT ResourceBundle : public ObjectImpl class LOG4CXX_EXPORT ResourceBundle : public ObjectImpl
{ {
public: public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(ResourceBundle) DECLARE_ABSTRACT_LOG4CXX_OBJECT(ResourceBundle)
BEGIN_LOG4CXX_CAST_MAP() BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(ResourceBundle) LOG4CXX_CAST_ENTRY(ResourceBundle)
END_LOG4CXX_CAST_MAP() END_LOG4CXX_CAST_MAP()
/** /**
Gets a string for the given key from this resource b Gets a string for the given key from this resource
undle or one of bundle or one of
its parents. Calling this method is equivalent to ca its parents. Calling this method is equivalent to c
lling alling
@param key the key for the desired string @param key the key for the desired string
@return the string for the given key @return the string for the given key
@throw MissingResourceException - if no object for t @throw MissingResourceException - if no object for
he given key the given key
can be found can be found
*/ */
virtual String getString(const String& key) const = virtual LogString getString(const LogString& key) c
0; onst = 0;
/** /**
Gets a resource bundle using the specified base name Gets a resource bundle using the specified base nam
and locale e and locale
@param baseName the base name of the resource bundle @param baseName the base name of the resource bundl
, a fully e, a fully
qualified class name or property filename qualified class name or property filename
@param locale the locale for which a resource bundle @param locale the locale for which a resource bundl
is desired e is desired
*/ */
static ResourceBundlePtr getBundle(const String& bas static ResourceBundlePtr getBundle(const LogString&
eName, baseName,
const Locale& locale); const Locale& locale);
protected: protected:
/* /*
Sets the parent bundle of this bundle. The parent bu Sets the parent bundle of this bundle. The parent b
ndle is undle is
searched by #getString when this bundle does not con searched by #getString when this bundle does not co
tain a particular ntain a particular
resource. resource.
Parameters: Parameters:
parent - this bundle's parent bundle. parent - this bundle's parent bundle.
*/ */
inline void setParent(const ResourceBundlePtr& paren inline void setParent(const ResourceBundlePtr& pare
t) nt1)
{ this->parent = parent; } { this->parent = parent1; }
/** /**
The parent bundle of this bundle. The parent bundle of this bundle.
The parent bundle is searched by #getString when thi The parent bundle is searched by #getString when th
s bundle does is bundle does
not contain a particular resource. not contain a particular resource.
*/ */
ResourceBundlePtr parent; ResourceBundlePtr parent;
}; // class ResourceBundle }; // class ResourceBundle
} // namespace helpers } // namespace helpers
}; // namespace log4cxx } // namespace log4cxx
#endif #endif
 End of changes. 13 change blocks. 
73 lines changed or deleted 69 lines changed or added


 rollingfileappender.h   rollingfileappender.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_ROLLING_FILE_APPENDER_H #if !defined(_LOG4CXX_ROLLING_ROLLING_FILE_APPENDER_H)
#define _LOG4CXX_ROLLING_FILE_APPENDER_H #define _LOG4CXX_ROLLING_ROLLING_FILE_APPENDER_H
#include <log4cxx/fileappender.h>
#include <log4cxx/helpers/optionconverter.h>
namespace log4cxx #include <log4cxx/rolling/rollingfileappenderskeleton.h>
{
/**
RollingFileAppender extends FileAppender to backup the log files whe
n
they reach a certain size.
*/
class LOG4CXX_EXPORT RollingFileAppender : public FileAppender
{
protected:
/**
The default maximum file size is 10MB.
*/
long maxFileSize;
/** namespace log4cxx {
There is one backup file by default. namespace rolling {
*/
int maxBackupIndex;
public: /**
DECLARE_LOG4CXX_OBJECT(RollingFileAppender) * <code>RollingFileAppender</code> extends {@link log4cxx::FileApp
BEGIN_LOG4CXX_CAST_MAP() ender} to backup the log files
LOG4CXX_CAST_ENTRY(RollingFileAppender) * depending on {@link log4cxx::rolling::RollingPolicy RollingPolic
LOG4CXX_CAST_ENTRY_CHAIN(FileAppender) y} and {@link log4cxx::rolling::TriggeringPolicy TriggeringPolicy}.
END_LOG4CXX_CAST_MAP() * <p>
/** * To be of any use, a <code>RollingFileAppender</code> instance mu
The default constructor simply calls its {@link st have both
FileAppender#FileAppender parents constructor}. */ * a <code>RollingPolicy</code> and a <code>TriggeringPolicy</code>
RollingFileAppender(); set up.
* However, if its <code>RollingPolicy</code> also implements the
* <code>TriggeringPolicy</code> interface, then only the former ne
eds to be
* set up. For example, {@link log4cxx::rolling::TimeBasedRollingPo
licy TimeBasedRollingPolicy} acts both as a
* <code>RollingPolicy</code> and a <code>TriggeringPolicy</code>.
*
* <p><code>RollingFileAppender</code> can be configured programatt
ically or
* using {@link log4cxx::xml::DOMConfigurator}. Here is a sample
* configration file:
/** <pre>&lt;?xml version="1.0" encoding="UTF-8" ?>
Instantiate a RollingFileAppender and open the file designat &lt;!DOCTYPE log4j:configuration>
ed by
<code>filename</code>. The opened filename will become the o
uput
destination for this appender.
<p>If the <code>append</code> parameter is true, the file wi &lt;log4j:configuration debug="true">
ll be
appended to. Otherwise, the file desginated by
<code>filename</code> will be truncated before being opened.
*/
RollingFileAppender(const LayoutPtr& layout, const String& f
ileName, bool append);
/** &lt;appender name="ROLL" class="org.apache.log4j.rolling.RollingF
Instantiate a FileAppender and open the file designated by ileAppender">
<code>filename</code>. The opened filename will become the o <b>&lt;rollingPolicy class="org.apache.log4j.rolling.TimeBasedR
utput ollingPolicy">
destination for this appender. &lt;param name="FileNamePattern" value="/wombat/foo.%d{yyyy-M
<p>The file will be appended to. */ M}.gz"/>
RollingFileAppender(const LayoutPtr& layout, const String& f &lt;/rollingPolicy></b>
ileName);
~RollingFileAppender(); &lt;layout class="org.apache.log4j.PatternLayout">
&lt;param name="ConversionPattern" value="%c{1} - %m%n"/>
&lt;/layout>
&lt;/appender>
/** &lt;root">
Returns the value of the <b>MaxBackupIndex</b> option. &lt;appender-ref ref="ROLL"/>
*/ &lt;/root>
inline int getMaxBackupIndex() const
{ return maxBackupIndex; }
/** &lt;/log4j:configuration>
Get the maximum size that the output file is allowed to reac </pre>
h
before being rolled over to backup files.
*/
inline long getMaximumFileSize() const
{ return maxFileSize; }
/** *<p>This configuration file specifies a monthly rollover schedule
Implements the usual roll over behaviour. including
* automatic compression of the archived files. See
* {@link TimeBasedRollingPolicy} for more details.
*
*
*
*
* */
class LOG4CXX_EXPORT RollingFileAppender : public RollingFileAppend
erSkeleton {
DECLARE_LOG4CXX_OBJECT(RollingFileAppender)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(RollingFileAppender)
LOG4CXX_CAST_ENTRY_CHAIN(RollingFileAppenderSkeleton)
END_LOG4CXX_CAST_MAP()
<p>If <code>MaxBackupIndex</code> is positive, then files public:
{<code>File.1</code>, ..., <code>File.MaxBackupIndex -1</cod RollingFileAppender();
e>}
are renamed to {<code>File.2</code>, ...,
<code>File.MaxBackupIndex</code>}. Moreover, <code>File</cod
e> is
renamed <code>File.1</code> and closed. A new <code>File</co
de> is
created to receive further log output.
<p>If <code>MaxBackupIndex</code> is equal to zero, then the using RollingFileAppenderSkeleton::getRollingPolicy;
<code>File</code> is truncated with no backup files created.
*/
// synchronization not necessary since doAppend is alreasy s
ynched
void rollOver();
/** using RollingFileAppenderSkeleton::getTriggeringPolicy;
Set the maximum number of backup files to keep around.
<p>The <b>MaxBackupIndex</b> option determines how many back /**
up * Sets the rolling policy. In case the 'policy' argument also im
files are kept before the oldest is erased. This option take plements
s * {@link TriggeringPolicy}, then the triggering policy for this
a positive integer value. If set to zero, then there will be appender
no * is automatically set to be the policy argument.
backup files and the log file will be truncated when it reac * @param policy
hes */
<code>MaxFileSize</code>. using RollingFileAppenderSkeleton::setRollingPolicy;
*/
inline void setMaxBackupIndex(int maxBackupIndex)
{ this->maxBackupIndex = maxBackupIndex; }
/** using RollingFileAppenderSkeleton::setTriggeringPolicy;
Set the maximum size that the output file is allowed to reac
h
before being rolled over to backup files.
<p>In configuration files, the <b>MaxFileSize</b> option tak };
es an
long integer in the range 0 - 2^63. You can specify the valu
e
with the suffixes "KB", "MB" or "GB" so that the integer is
interpreted being expressed respectively in kilobytes, megab
ytes
or gigabytes. For example, the value "10KB" will be interpre
ted
as 10240.
*/
inline void setMaxFileSize(const String& value)
{ maxFileSize = helpers::OptionConverter::toFileSize
(
value, maxFileSize + 1); }
virtual void setOption(const String& option, const String& v alue); LOG4CXX_PTR_DEF(RollingFileAppender);
protected: }
/** }
This method differentiates RollingFileAppender from its pare
nt
class.
*/
virtual void subAppend(const spi::LoggingEventPtr& event);
}; // class RollingFileAppender
} // namespace log4cxx
#endif //_LOG4CXX_ROLLING_FILE_APPENDER_H #endif
 End of changes. 21 change blocks. 
132 lines changed or deleted 85 lines changed or added


 serversocket.h   serversocket.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_SERVER_SOCKET_H #ifndef _LOG4CXX_HELPERS_SERVER_SOCKET_H
#define _LOG4CXX_HELPERS_SERVER_SOCKET_H #define _LOG4CXX_HELPERS_SERVER_SOCKET_H
#include <log4cxx/helpers/socket.h> #include <log4cxx/helpers/socket.h>
#include <log4cxx/helpers/exception.h> #include <log4cxx/helpers/mutex.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class LOG4CXX_EXPORT ServerSocket class LOG4CXX_EXPORT ServerSocket
{ {
public: public:
/** Creates a server socket on a specified port. /** Creates a server socket on a specified port.
*/ */
ServerSocket(int port); ServerSocket(int port);
/** Creates a server socket and binds it to the spec
ified local
port number, with the specified backlog.
*/
ServerSocket(int port, int backlog);
/** Create a server with the specified port, listen
backlog,
and local IP address to bind to.
*/
ServerSocket(int port, int backlog, InetAddress bind
Addr);
~ServerSocket();
/** Listens for a connection to be made to this sock
et and
accepts it
*/
SocketPtr accept();
/** Closes this socket. virtual ~ServerSocket();
*/
inline void close()
{ socketImpl->close(); }
/** Returns the local address of this server socket. /** Listens for a connection to be made to this soc
*/ ket and
inline InetAddress getInetAddress() const accepts it
{ return socketImpl->getInetAddress(); } */
SocketPtr accept();
/** Returns the port on which this socket is listeni /** Closes this socket.
ng. */
*/ void close();
inline int getLocalPort() const
{ return socketImpl->getLocalPort(); }
/** Returns the implementation address and implement /** Retrive setting for SO_TIMEOUT.
ation */
port of this socket as a String int getSoTimeout() const;
*/
inline String toString() const
{ return socketImpl->toString(); }
/** Retrive setting for SO_TIMEOUT. /** Enable/disable SO_TIMEOUT with the specified ti
*/ meout, in milliseconds.
int getSoTimeout() const; */
void setSoTimeout(int timeout);
/** Enable/disable SO_TIMEOUT with the specified tim private:
eout, in milliseconds. Pool pool;
*/ Mutex mutex;
void setSoTimeout(int timeout); apr_socket_t* socket;
int timeout;
protected: };
SocketImplPtr socketImpl; } // namespace helpers
}; } // namespace log4cxx
} // namespace helpers
}; // namespace log4cxx
#endif //_LOG4CXX_HELPERS_SERVER_SOCKET_H #endif //_LOG4CXX_HELPERS_SERVER_SOCKET_H
 End of changes. 10 change blocks. 
67 lines changed or deleted 39 lines changed or added


 simplelayout.h   simplelayout.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_SIMPLE_LAYOUT_H #ifndef _LOG4CXX_SIMPLE_LAYOUT_H
#define _LOG4CXX_SIMPLE_LAYOUT_H #define _LOG4CXX_SIMPLE_LAYOUT_H
#if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/layout.h> #include <log4cxx/layout.h>
namespace log4cxx namespace log4cxx
{ {
class SimpleLayout; /**
typedef helpers::ObjectPtrT<SimpleLayout> SimpleLayoutPtr; SimpleLayout consists of the level of the log statement,
followed by " - " and then the log message itself. For example,
/**
SimpleLayout consists of the level of the log statement,
followed by " - " and then the log message itself. For example,
<pre> <pre>
DEBUG - Hello world DEBUG - Hello world
</pre> </pre>
<p> <p>
<p>PatternLayout offers a much more powerful alternative. <p>PatternLayout offers a much more powerful alternative.
*/ */
class LOG4CXX_EXPORT SimpleLayout : public Layout class LOG4CXX_EXPORT SimpleLayout : public Layout
{ {
public: public:
DECLARE_LOG4CXX_OBJECT(SimpleLayout) DECLARE_LOG4CXX_OBJECT(SimpleLayout)
BEGIN_LOG4CXX_CAST_MAP() BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(SimpleLayout) LOG4CXX_CAST_ENTRY(SimpleLayout)
LOG4CXX_CAST_ENTRY_CHAIN(Layout) LOG4CXX_CAST_ENTRY_CHAIN(Layout)
END_LOG4CXX_CAST_MAP() END_LOG4CXX_CAST_MAP()
/** /**
Returns the log statement in a format consisting of the Returns the log statement in a format consisting of the
<code>level</code>, followed by " - " and then the <code>level</code>, followed by " - " and then the
<code>message</code>. For example, <pre> INFO - "A message" <code>message</code>. For example, <pre> INFO - "A message"
</pre> </pre>
<p>The <code>category</code> parameter is ignored. @return A byte array in SimpleLayout format.
<p> */
@return A byte array in SimpleLayout format. virtual void format(LogString& output,
*/ const spi::LoggingEventPtr& event,
virtual void format(ostream& output, const spi::LoggingEvent log4cxx::helpers::Pool& pool) const;
Ptr& event) const;
/** /**
The SimpleLayout does not handle the throwable contained wit The SimpleLayout does not handle the throwable contained wi
hin thin
{@link spi::LoggingEvent LoggingEvents}. Thus, it returns {@link spi::LoggingEvent LoggingEvents}. Thus, it returns
<code>true</code>. <code>true</code>.
*/ */
bool ignoresThrowable() const { return true; } bool ignoresThrowable() const { return true; }
virtual void activateOptions() {} virtual void activateOptions(log4cxx::helpers::Pool& /* p *
virtual void setOption(const String& option, const String& v /) {}
alue) {} virtual void setOption(const LogString& /* option */,
}; const LogString& /* value */) {}
};
LOG4CXX_PTR_DEF(SimpleLayout);
} // namespace log4cxx } // namespace log4cxx
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#endif //_LOG4CXX_SIMPLE_LAYOUT_H #endif //_LOG4CXX_SIMPLE_LAYOUT_H
 End of changes. 11 change blocks. 
47 lines changed or deleted 55 lines changed or added


 smtpappender.h   smtpappender.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_NET_SMTP_H #ifndef _LOG4CXX_NET_SMTP_H
#define _LOG4CXX_NET_SMTP_H #define _LOG4CXX_NET_SMTP_H
#include <log4cxx/config.h>
#ifdef HAVE_SMTP
#include <log4cxx/appenderskeleton.h> #include <log4cxx/appenderskeleton.h>
#include <log4cxx/helpers/cyclicbuffer.h> #include <log4cxx/helpers/cyclicbuffer.h>
#include <log4cxx/spi/triggeringeventevaluator.h> #include <log4cxx/spi/triggeringeventevaluator.h>
namespace log4cxx namespace log4cxx
{ {
namespace net namespace net
{ {
class SMTPAppender; /**
typedef helpers::ObjectPtrT<SMTPAppender> SMTPAppenderPtr; Send an e-mail when a specific logging event occurs, typica
lly on
errors or fatal errors.
<p>The number of logging events delivered in this e-mail de
pend on
the value of <b>BufferSize</b> option. The
<code>SMTPAppender</code> keeps only the last
<code>BufferSize</code> logging events in its cyclic buffer
. This
keeps memory requirements at a reasonable level while still
delivering useful application context.
*/
class LOG4CXX_EXPORT SMTPAppender : public AppenderSkeleton
{
private:
/** private:
Send an e-mail when a specific logging event occurs, typical SMTPAppender(const SMTPAppender&);
ly on SMTPAppender& operator=(const SMTPAppender&);
errors or fatal errors. static bool asciiCheck(const LogString& value, cons
<p>The number of logging events delivered in this e-mail dep t LogString& label);
end on /**
the value of <b>BufferSize</b> option. The This method determines if there is a sense in attem
<code>SMTPAppender</code> keeps only the last pting to append.
<code>BufferSize</code> logging events in its cyclic buffer. <p>It checks whether there is a set output target a
This nd also if
keeps memory requirements at a reasonable level while still there is a set layout. If these checks fail, then t
delivering useful application context. he boolean
*/ value <code>false</code> is returned. */
class LOG4CXX_EXPORT SMTPAppender : public AppenderSkeleton bool checkEntryConditions();
{
private:
String to;
String from;
String subject;
String smtpHost;
int bufferSize; // 512
bool locationInfo;
helpers::CyclicBuffer cb;
void * session;
String encoding;
String charset;
protected: LogString to;
spi::TriggeringEventEvaluatorPtr evaluator; LogString cc;
LogString bcc;
LogString from;
LogString subject;
LogString smtpHost;
LogString smtpUsername;
LogString smtpPassword;
int smtpPort;
int bufferSize; // 512
bool locationInfo;
helpers::CyclicBuffer cb;
spi::TriggeringEventEvaluatorPtr evaluator;
public: public:
DECLARE_LOG4CXX_OBJECT(SMTPAppender) DECLARE_LOG4CXX_OBJECT(SMTPAppender)
BEGIN_LOG4CXX_CAST_MAP() BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(SMTPAppender) LOG4CXX_CAST_ENTRY(SMTPAppender)
LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton) LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
END_LOG4CXX_CAST_MAP() END_LOG4CXX_CAST_MAP()
/** SMTPAppender();
The default constructor will instantiate the appende /**
r with a The default constructor will instantiate the append
spi::TriggeringEventEvaluator that will trigger on e er with a
vents with spi::TriggeringEventEvaluator that will trigger on
level ERROR or higher.*/ events with
SMTPAppender(); level ERROR or higher.*/
SMTPAppender(log4cxx::helpers::Pool& p);
/** /**
Use <code>evaluator</code> passed as parameter as th Use <code>evaluator</code> passed as parameter as t
e he
spi::TriggeringEventEvaluator for this net::SMTPAppe spi::TriggeringEventEvaluator for this net::SMTPApp
nder. ender.
*/ */
SMTPAppender(spi::TriggeringEventEvaluatorPtr evalua SMTPAppender(spi::TriggeringEventEvaluatorPtr evalu
tor); ator);
~SMTPAppender(); ~SMTPAppender();
/** /**
Set options Set options
*/ */
virtual void setOption(const String& option, const S virtual void setOption(const LogString& option, con
tring& value); st LogString& value);
/** /**
Activate the specified options, such as the smtp hos Activate the specified options, such as the smtp ho
t, the st, the
recipient, from, etc. recipient, from, etc.
*/ */
virtual void activateOptions(); virtual void activateOptions(log4cxx::helpers::Pool
& p);
/** /**
Perform SMTPAppender specific appending actions, mai Perform SMTPAppender specific appending actions, ma
nly adding inly adding
the event to a cyclic buffer and checking if the eve the event to a cyclic buffer and checking if the ev
nt triggers ent triggers
an e-mail to be sent. */ an e-mail to be sent. */
virtual void append(const spi::LoggingEventPtr& even virtual void append(const spi::LoggingEventPtr& eve
t); nt, log4cxx::helpers::Pool& p);
/** virtual void close();
This method determines if there is a sense in attemp
ting to append.
<p>It checks whether there is a set output target an
d also if
there is a set layout. If these checks fail, then th
e boolean
value <code>false</code> is returned. */
bool checkEntryConditions();
virtual void close(); /**
Returns value of the <b>To</b> option.
*/
LogString getTo() const;
std::vector<String> parseAddress(const String& addre /**
ssStr); Returns value of the <b>cc</b> option.
*/
LogString getCc() const;
/** /**
Returns value of the <b>To</b> option. Returns value of the <b>bcc</b> option.
*/ */
inline const String& getTo() const LogString getBcc() const;
{ return to; }
/** /**
The <code>SMTPAppender</code> requires a {@link The <code>SMTPAppender</code> requires a {@link
Layout layout}. */ Layout layout}. */
virtual bool requiresLayout() const virtual bool requiresLayout() const;
{ return true; }
/** /**
Send the contents of the cyclic buffer as an e-mail Send the contents of the cyclic buffer as an e-mail
message. message.
*/ */
void sendBuffer(); void sendBuffer(log4cxx::helpers::Pool& p);
/** /**
Returns value of the <b>Charset</b> option. Returns value of the <b>EvaluatorClass</b> option.
*/ */
inline const String& getCharset() const LogString getEvaluatorClass();
{ return charset; }
/** /**
Returns value of the <b>Encoding</b> option. Returns value of the <b>From</b> option.
*/ */
inline const String& getEncoding() const LogString getFrom() const;
{ return encoding; }
/** /**
Returns value of the <b>EvaluatorClass</b> option. Returns value of the <b>Subject</b> option.
*/ */
String getEvaluatorClass(); LogString getSubject() const;
/** /**
Returns value of the <b>From</b> option. The <b>From</b> option takes a string value which s
*/ hould be a
inline const String& getFrom() const e-mail address of the sender.
{ return from; } */
void setFrom(const LogString& from);
/** /**
Returns value of the <b>Subject</b> option. The <b>Subject</b> option takes a string value whic
*/ h should be a
inline const String& getSubject() const the subject of the e-mail message.
{ return subject; } */
void setSubject(const LogString& subject);
/** /**
The <b>Charset</b> option takes a string value which The <b>BufferSize</b> option takes a positive integ
should be the er
charset of the mail (<code>us-ascii</code>, <code>is representing the maximum number of logging events t
o8859_1</code>, o collect in a
<code>iso8859_2</code>, <code>iso8859_3</code>). cyclic buffer. When the <code>BufferSize</code> is
*/ reached,
inline void setCharset(const String& charset) oldest events are deleted as new events are added t
{ this->charset = charset; } o the
buffer. By default the size of the cyclic buffer is
512 events.
*/
void setBufferSize(int bufferSize);
/** /**
The <b>Encoding</b> option takes a string value whic The <b>SMTPHost</b> option takes a string value whi
h should be the ch should be a
encoding type of the mail (<code>7bit</code>, <code> the host name of the SMTP server that will send the
8bit</code>, e-mail message.
<code>base64</code>, <code>binary</code>, <code>quot */
ed</code>). void setSMTPHost(const LogString& smtpHost);
*/
inline void setEncoding(const String& charset)
{ this->encoding = encoding; }
/** /**
The <b>From</b> option takes a string value which sh Returns value of the <b>SMTPHost</b> option.
ould be a */
e-mail address of the sender. LogString getSMTPHost() const;
*/
inline void setFrom(const String& from)
{ this->from = from; }
/** /**
The <b>Subject</b> option takes a string value which The <b>SMTPPort</b> option takes a string value whi
should be a ch should be a
the subject of the e-mail message. the port of the SMTP server that will send the e-ma
*/ il message.
inline void setSubject(const String& subject) */
{ this->subject = subject; } void setSMTPPort(int port);
/** /**
The <b>BufferSize</b> option takes a positive intege Returns value of the <b>SMTPHost</b> option.
r */
representing the maximum number of logging events to int getSMTPPort() const;
collect in a
cyclic buffer. When the <code>BufferSize</code> is r
eached,
oldest events are deleted as new events are added to
the
buffer. By default the size of the cyclic buffer is
512 events.
*/
void setBufferSize(int bufferSize);
/** /**
The <b>SMTPHost</b> option takes a string value whic The <b>To</b> option takes a string value which sho
h should be a uld be a
the host name of the SMTP server that will send the comma separated list of e-mail address of the recip
e-mail message. ients.
*/ */
inline void setSMTPHost(const String& smtpHost) void setTo(const LogString& to);
{ this->smtpHost = smtpHost; }
/** /**
Returns value of the <b>SMTPHost</b> option. The <b>Cc</b> option takes a string value which sho
*/ uld be a
inline const String& getSMTPHost() const comma separated list of e-mail address of the cc'd
{ return smtpHost; } recipients.
*/
void setCc(const LogString& to);
/** /**
The <b>To</b> option takes a string value which shou The <b>Bcc</b> option takes a string value which sh
ld be a ould be a
comma separated list of e-mail address of the recipi comma separated list of e-mail address of the bcc'd
ents. recipients.
*/ */
inline void setTo(const String& to) void setBcc(const LogString& to);
{ this->to = to; }
/** /**
Returns value of the <b>BufferSize</b> option. The <b>SMTPUsername</b> option takes a string value
*/ which should be a
inline int getBufferSize() const the user name for the SMTP server.
{ return bufferSize; } */
void setSMTPUsername(const LogString& newVal);
/** /**
The <b>EvaluatorClass</b> option takes a string valu Returns value of the <b>SMTPUsername</b> option.
e */
representing the name of the class implementing the LogString getSMTPUsername() const;
spi::TriggeringEventEvaluator interface. A correspon
ding object will
be instantiated and assigned as the triggering event
evaluator
for the SMTPAppender.
*/
void setEvaluatorClass(const String& value);
/** /**
The <b>LocationInfo</b> option takes a boolean value The <b>SMTPPassword</b> option takes a string value
. By which should be a
default, it is set to false which means there will b the password for the SMTP server.
e no effort */
to extract the location information related to the e void setSMTPPassword(const LogString& newVal);
vent. As a
result, the layout that formats the events as they a
re sent out
in an e-mail is likely to place the wrong location i
nformation
(if present in the format).
<p>Location information extraction is comparatively /**
very slow and Returns value of the <b>SMTPPassword</b> option.
should be avoided unless performance is not a concer */
n. LogString getSMTPPassword() const;
*/
inline void setLocationInfo(bool locationInfo)
{ this->locationInfo = locationInfo; }
/** /**
Returns value of the <b>LocationInfo</b> option. Returns value of the <b>BufferSize</b> option.
*/ */
inline bool getLocationInfo() const inline int getBufferSize() const
{ return locationInfo; } { return bufferSize; }
}; // class SMTPAppender
class LOG4CXX_EXPORT DefaultEvaluator : /**
public virtual spi::TriggeringEventEvaluator, * Gets the current triggering evaluator.
public virtual helpers::ObjectImpl * @return triggering evaluator.
{ */
public: log4cxx::spi::TriggeringEventEvaluatorPtr getEvalua
DECLARE_LOG4CXX_OBJECT(DefaultEvaluator) tor() const;
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(spi::TriggeringEventEvalu /**
ator) * Sets the triggering evaluator.
END_LOG4CXX_CAST_MAP() * @param trigger triggering evaluator.
/** */
Is this <code>event</code> the e-mail triggering eve void setEvaluator(log4cxx::spi::TriggeringEventEval
nt? uatorPtr& trigger);
<p>This method returns <code>true</code>, if the eve
nt level /**
has ERROR level or higher. Otherwise it returns The <b>EvaluatorClass</b> option takes a string val
<code>false</code>. ue
*/ representing the name of the class implementing the
virtual bool isTriggeringEvent(const spi::LoggingEve spi::TriggeringEventEvaluator interface. A correspo
ntPtr& event); nding object will
}; // class DefaultEvaluator be instantiated and assigned as the triggering even
} // namespace net t evaluator
}; // namespace log4cxx for the SMTPAppender.
*/
void setEvaluatorClass(const LogString& value);
/**
The <b>LocationInfo</b> option is provided for comp
atibility with log4j
and has no effect in log4cxx.
*/
void setLocationInfo(bool locationInfo);
/**
Returns value of the <b>LocationInfo</b> option.
*/
bool getLocationInfo() const;
}; // class SMTPAppender
LOG4CXX_PTR_DEF(SMTPAppender);
} // namespace net
} // namespace log4cxx
#endif // HAVE_SMTP
#endif // _LOG4CXX_NET_SMTP_H #endif // _LOG4CXX_NET_SMTP_H
 End of changes. 38 change blocks. 
265 lines changed or deleted 264 lines changed or added


 socket.h   socket.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_SOCKET_H #ifndef _LOG4CXX_HELPERS_SOCKET_H
#define _LOG4CXX_HELPERS_SOCKET_H #define _LOG4CXX_HELPERS_SOCKET_H
#include <log4cxx/helpers/tchar.h> extern "C" {
#include <log4cxx/helpers/socketimpl.h> struct apr_socket_t;
#include <log4cxx/helpers/socketinputstream.h> }
#include <log4cxx/helpers/socketoutputstream.h>
#include <log4cxx/helpers/inetaddress.h>
#include <log4cxx/helpers/pool.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class ServerSocker; class ByteBuffer;
/**
class Socket; <p>This class implements client sockets (also called just "
typedef helpers::ObjectPtrT<Socket> SocketPtr; sockets"). A socket
is an endpoint for communication between two machines.
class SocketOutputStream; <p>The actual work of the socket is performed by an instanc
typedef helpers::ObjectPtrT<SocketOutputStream> SocketOutput e of the SocketImpl
StreamPtr; class. An application, by changing the socket factory that
creates the socket
class SocketInputStream; implementation, can configure itself to create sockets appr
typedef helpers::ObjectPtrT<SocketInputStream> SocketInputSt opriate to the
reamPtr; local firewall.
*/
/** class LOG4CXX_EXPORT Socket : public helpers::ObjectImpl
<p>This class implements client sockets (also called just "s {
ockets"). A socket public:
is an endpoint for communication between two machines. DECLARE_ABSTRACT_LOG4CXX_OBJECT(Socket)
<p>The actual work of the socket is performed by an instance BEGIN_LOG4CXX_CAST_MAP()
of the SocketImpl LOG4CXX_CAST_ENTRY(Socket)
class. An application, by changing the socket factory that c END_LOG4CXX_CAST_MAP()
reates the socket
implementation, can configure itself to create sockets appro
priate to the
local firewall.
*/
class LOG4CXX_EXPORT Socket : public helpers::ObjectImpl
{
friend class ServerSocket;
protected:
/** Creates an unconnected socket.
*/
Socket();
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Socket)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(Socket)
END_LOG4CXX_CAST_MAP()
/** Creates a stream socket and connects it to the s
pecified port
number at the specified IP address.
*/
Socket(InetAddress address, int port);
/** Creates a socket and connects it to the specifie
d remote
address on the specified remote port.
*/
Socket(InetAddress address, int port,
InetAddress localAddr, int localPort);
protected:
/** Creates an unconnected Socket
with a user-specified SocketImpl.
*/
Socket(SocketImplPtr impl);
public: /** Creates a stream socket and connects it to the
/** Creates a stream socket and connects it to the s specified port
pecified number at the specified IP address.
port number on the named host. */
*/ Socket(InetAddressPtr& address, int port);
Socket(const String& host, int port); Socket(apr_socket_t* socket, apr_pool_t* pool);
~Socket();
/** Creates a socket and connects it to the specifi size_t write(ByteBuffer&);
ed remote
host on the specified remote port.
*/
Socket(const String& host, int port,
InetAddress localAddr, int localPort);
size_t read(void * buf, size_t len) const /** Closes this socket. */
{ return socketImpl->read(buf, len); } void close();
size_t write(const void * buf, size_t len) /** Returns the value of this socket's address fiel
{ return socketImpl->write(buf, len); } d. */
InetAddressPtr getInetAddress() const;
/** Closes this socket. */ /** Returns the value of this socket's port field.
void close() */
{ socketImpl->close(); } int getPort() const;
private:
Socket(const Socket&);
Socket& operator=(const Socket&);
/** Returns the value of this socket's address field Pool pool;
. */
inline InetAddress getInetAddress() const
{ return socketImpl->getInetAddress(); }
/** Returns the value of this socket's localport fie apr_socket_t* socket;
ld. */
inline int getLocalPort() const
{ return socketImpl->getLocalPort(); }
/** Returns the value of this socket's port field. * /** The IP address of the remote end of this socket.
/ */
inline int getPort() const InetAddressPtr address;
{ return socketImpl->getPort(); }
/** Returns an output stream for this socket. */ /** The port number on the remote host to which
SocketOutputStreamPtr getOutputStream(); this socket is connected. */
int port;
};
/** Returns an input stream for this socket. */ LOG4CXX_PTR_DEF(Socket);
SocketInputStreamPtr getInputStream();
protected: } // namespace helpers
SocketImplPtr socketImpl; } // namespace log4cxx
};
} // namespace helpers
}; // namespace log4cxx
#endif // _LOG4CXX_HELPERS_SOCKET_H #endif // _LOG4CXX_HELPERS_SOCKET_H
 End of changes. 14 change blocks. 
108 lines changed or deleted 65 lines changed or added


 socketappender.h   socketappender.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_NET_SOCKET_APPENDER_H #ifndef _LOG4CXX_NET_SOCKET_APPENDER_H
#define _LOG4CXX_NET_SOCKET_APPENDER_H #define _LOG4CXX_NET_SOCKET_APPENDER_H
#include <log4cxx/appenderskeleton.h> #include <log4cxx/net/socketappenderskeleton.h>
#include <log4cxx/helpers/socket.h> #include <log4cxx/helpers/objectoutputstream.h>
#include <log4cxx/helpers/thread.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace net
{ {
class SocketOutputStream;
typedef helpers::ObjectPtrT<SocketOutputStream> SocketOutput
StreamPtr;
}
namespace net
{
class LOG4CXX_EXPORT SocketAppender;
typedef helpers::ObjectPtrT<SocketAppender> SocketAppenderPt
r;
/** /**
Sends {@link spi::LoggingEvent LoggingEvent} objects to a remote a Sends {@link log4cxx::spi::LoggingEvent LoggingEvent} objects to a
log server, remote a log server,
usually a {@link net::SocketNode SocketNode}. usually Apache Chainsaw.
<p>The SocketAppender has the following properties: <p>The SocketAppender has the following properties:
- If sent to a {@link net::SocketNode SocketNode}, remote logging - If sent to Apache Chainsaw, remote logging
is non-intrusive as far as the log event is concerned. In ot is non-intrusive as far as the log event is concerned. In o
her ther
words, the event will be logged with the same time stamp, {@link words, the event will be logged with the same time stamp, {@link
NDC NDC}, location info as if it were logged locally by NDC NDC}, location info as if it were logged locally by
the client. the client.
- SocketAppenders do not use a layout. They ship a - SocketAppenders do not use a layout. They ship a
serialized {@link spi::LoggingEvent LoggingEvent} object serialized {@link log4cxx::spi::LoggingEvent LoggingEvent} object
to the server side. to the server side.
- Remote logging uses the TCP protocol. Consequently, if - Remote logging uses the TCP protocol. Consequently, if
the server is reachable, then log events will eventually arrive the server is reachable, then log events will eventually arrive
at the server. at the server.
- If the remote server is down, the logging requests are - If the remote server is down, the logging requests are
simply dropped. However, if and when the server comes back up, simply dropped. However, if and when the server comes back up,
then event transmission is resumed transparently. This then event transmission is resumed transparently. This
transparent reconneciton is performed by a <em>connector</em> transparent reconneciton is performed by a <em>connector</em>
thread which periodically attempts to connect to the server. thread which periodically attempts to connect to the server.
skipping to change at line 87 skipping to change at line 79
the presence of a connector thread. A connector thread exists the presence of a connector thread. A connector thread exists
only if the connection to the server is down. To avoid this only if the connection to the server is down. To avoid this
destruction problem, you should #close the the destruction problem, you should #close the the
<code>SocketAppender</code> explicitly. See also next item. <code>SocketAppender</code> explicitly. See also next item.
@n @n Long lived applications which create/destroy many @n @n Long lived applications which create/destroy many
<code>SocketAppender</code> instances should be aware of this <code>SocketAppender</code> instances should be aware of this
destruction problem. Most other applications can safely destruction problem. Most other applications can safely
ignore it. ignore it.
- If the application hosting the <code>SocketAppender</code> - If the application hosting the <code>SocketAppender</code>
exits before the <code>SocketAppender</code> is closed eithe r exits before the <code>SocketAppender</code> is closed eith er
explicitly or subsequent to destruction, then there might explicitly or subsequent to destruction, then there might
be untransmitted data in the pipe which might be lost. be untransmitted data in the pipe which might be lost.
@n @n To avoid lost data, it is usually sufficient to @n @n To avoid lost data, it is usually sufficient to
#close the <code>SocketAppender</code> either explicitly or by #close the <code>SocketAppender</code> either explicitly or by
calling the LogManager#shutdown method calling the LogManager#shutdown method
before exiting the application. before exiting the application.
*/ */
class LOG4CXX_EXPORT SocketAppender : public AppenderSkeleton class LOG4CXX_EXPORT SocketAppender : public SocketAppenderSkeleton
{ {
class Connector; public:
friend class Connector; /**
public: The default port number of remote logging server (4560).
/** */
The default port number of remote logging server (4560). static int DEFAULT_PORT;
*/
static int DEFAULT_PORT;
/**
The default reconnection delay (30000 milliseconds or 30 sec
onds).
*/
static int DEFAULT_RECONNECTION_DELAY;
protected:
/**
host name
*/
String remoteHost;
/**
IP address
*/
helpers::InetAddress address;
int port;
helpers::SocketOutputStreamPtr os;
int reconnectionDelay;
bool locationInfo;
public:
DECLARE_LOG4CXX_OBJECT(SocketAppender)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(SocketAppender)
LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
END_LOG4CXX_CAST_MAP()
SocketAppender();
~SocketAppender();
/**
Connects to remote server at <code>address</code> and <code>
port</code>.
*/
SocketAppender(unsigned long address, int port);
/**
Connects to remote server at <code>host</code> and <code>por
t</code>.
*/
SocketAppender(const String& host, int port);
/**
Connect to the specified <b>RemoteHost</b> and <b>Port</b>.
*/
void activateOptions();
/**
Set options
*/
virtual void setOption(const String& option, const S
tring& value);
/**
* Close this appender.
*
* <p>This will mark the appender as closed and call then
* #cleanUp method.
* */
void close();
/**
* Drop the connection to the remote host and release the und
erlying
* connector thread if it has been created
* */
void cleanUp();
void connect();
virtual void append(const spi::LoggingEventPtr& event);
/**
* The SocketAppender does not use a layout. Hence, this meth
od
* returns <code>false</code>.
* */
bool requiresLayout() const
{ return false; }
/**
* The <b>RemoteHost</b> option takes a string value which sh
ould be
* the host name of the server where a
* {@link net::SocketNode SocketNode} is running.
* */
inline void setRemoteHost(const String& host)
{ address = helpers::InetAddress::getByName(host);
remoteHost = host; }
/**
Returns value of the <b>RemoteHost</b> option.
*/
inline const String& getRemoteHost() const
{ return remoteHost; }
/** /**
The <b>Port</b> option takes a positive integer representing The default reconnection delay (30000 milliseconds or 30 se
the port where the server is waiting for connections. conds).
*/ */
void setPort(int port) static int DEFAULT_RECONNECTION_DELAY;
{ this->port = port; }
/** DECLARE_LOG4CXX_OBJECT(SocketAppender)
Returns value of the <b>Port</b> option. BEGIN_LOG4CXX_CAST_MAP()
*/ LOG4CXX_CAST_ENTRY(SocketAppender)
int getPort() const LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
{ return port; } END_LOG4CXX_CAST_MAP()
/** SocketAppender();
The <b>LocationInfo</b> option takes a boolean value. If tru ~SocketAppender();
e,
the information sent to the remote host will include locatio
n
information. By default no location information is sent to t
he server.
*/
void setLocationInfo(bool locationInfo)
{ this->locationInfo = locationInfo; }
/** /**
Returns value of the <b>LocationInfo</b> option. Connects to remote server at <code>address</code> and <code
*/ >port</code>.
bool getLocationInfo() const */
{ return locationInfo; } SocketAppender(helpers::InetAddressPtr& address, int port);
/** /**
The <b>ReconnectionDelay</b> option takes a positive integer Connects to remote server at <code>host</code> and <code>po
representing the number of milliseconds to wait between each rt</code>.
failed connection attempt to the server. The default value o */
f SocketAppender(const LogString& host, int port);
this option is 30000 which corresponds to 30 seconds.
<p>Setting this option to zero turns off reconnection protected:
capability. virtual void setSocket(log4cxx::helpers::SocketPtr& socket,
*/ log4cxx::helpers::Pool& p);
void setReconnectionDelay(int reconnectionDelay)
{ this->reconnectionDelay = reconnectionDelay; }
/** virtual void cleanUp(log4cxx::helpers::Pool& p);
Returns value of the <b>ReconnectionDelay</b> option.
*/
int getReconnectionDelay() const
{ return reconnectionDelay; }
void fireConnector(); virtual int getDefaultDelay() const;
private: virtual int getDefaultPort() const;
/**
The Connector will reconnect when the server becomes
available
again. It does this by attempting to open a new con
nection every
<code>reconnectionDelay</code> milliseconds.
<p>It stops trying whenever a connection is establis void append(const spi::LoggingEventPtr& event, log4cxx::hel
hed. It will pers::Pool& pool);
restart to try reconnect to the server when previpou
sly open
connection is droppped.
*/
class LOG4CXX_EXPORT Connector : public helpers::Thr
ead
{
public:
typedef helpers::Thread BASE_CLASS;
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(Connector)
LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
END_LOG4CXX_CAST_MAP()
bool interrupted; private:
SocketAppender * socketAppender; log4cxx::helpers::ObjectOutputStreamPtr oos;
Connector(SocketAppender * socketAppender); }; // class SocketAppender
virtual void run();
}; // class Connector
typedef helpers::ObjectPtrT<Connector> ConnectorPtr; LOG4CXX_PTR_DEF(SocketAppender);
ConnectorPtr connector;
}; // class SocketAppender
} // namespace net } // namespace net
}; // namespace log4cxx } // namespace log4cxx
#endif // _LOG4CXX_NET_SOCKET_APPENDER_H #endif // _LOG4CXX_NET_SOCKET_APPENDER_H
 End of changes. 23 change blocks. 
210 lines changed or deleted 61 lines changed or added


 sockethubappender.h   sockethubappender.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_NET_SOCKET_HUB_APPENDER_H #ifndef _LOG4CXX_NET_SOCKET_HUB_APPENDER_H
#define _LOG4CXX_NET_SOCKET_HUB_APPENDER_H #define _LOG4CXX_NET_SOCKET_HUB_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/socket.h>
#include <log4cxx/helpers/thread.h>
#include <vector> #include <vector>
#include <log4cxx/helpers/socket.h> #include <log4cxx/helpers/thread.h>
#include <log4cxx/helpers/objectoutputstream.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers {
{ class ObjectOutputStream;
class SocketOutputStream; typedef ObjectPtrT<ObjectOutputStream> ObjectOutputStreamPt
typedef helpers::ObjectPtrT<SocketOutputStream> SocketOutput r;
StreamPtr; }
} namespace net
{
namespace net /**
{ Sends {@link log4cxx::spi::LoggingEvent LoggingEvent} objec
/** ts to a set of remote log
Sends {@link spi::LoggingEvent LoggingEvent} objects to a se servers, usually a SocketNode.
t of remote log
servers, usually a SocketNode.
<p>Acts just like SocketAppender except that instead of
connecting to a given remote log server,
<code>SocketHubAppender</code> accepts connections from the
remote
log servers as clients. It can accept more than one connect
ion.
When a log event is received, the event is sent to the set o
f
currently connected remote log servers. Implemented this way
it does
not require any update to the configuration file to send dat
a to
another remote log server. The remote log server simply conn
ects to
the host and port the <code>SocketHubAppender</code> is runn
ing on.
<p>The <code>SocketHubAppender</code> does not store events
such
that the remote side will events that arrived after the
establishment of its connection. Once connected, events arri
ve in
order as guaranteed by the TCP protocol.
<p>This implementation borrows heavily from the SocketAppend
er.
<p>The SocketHubAppender has the following characteristics:
- If sent to a SocketNode, logging is non-intrusive as <p>Acts just like SocketAppender except that instead of
far as the log event is concerned. In other words, the event connecting to a given remote log server,
will be <code>SocketHubAppender</code> accepts connections from the
logged with the same time stamp, NDC, remote
location info as if it were logged locally. log servers as clients. It can accept more than one connec
tion.
When a log event is received, the event is sent to the set
of
currently connected remote log servers. Implemented this wa
y it does
not require any update to the configuration file to send da
ta to
another remote log server. The remote log server simply con
nects to
the host and port the <code>SocketHubAppender</code> is run
ning on.
- <code>SocketHubAppender</code> does not use a layout. It <p>The <code>SocketHubAppender</code> does not store events
ships a serialized spi::LoggingEvent object to the remote si such
de. that the remote side will events that arrived after the
establishment of its connection. Once connected, events arr
ive in
order as guaranteed by the TCP protocol.
- <code>SocketHubAppender</code> relies on the TCP <p>This implementation borrows heavily from the SocketAppen
protocol. Consequently, if the remote side is reachable, the der.
n log
events will eventually arrive at remote client.
- If no remote clients are attached, the logging requests ar <p>The SocketHubAppender has the following characteristics:
e
simply dropped.
- Logging events are automatically <em>buffered</em> by the - If sent to a SocketNode, logging is non-intrusive as
native TCP implementation. This means that if the link to re far as the log event is concerned. In other words, the even
mote t will be
client is slow but still faster than the rate of (log) event logged with the same time stamp, NDC,
production, the application will not be affected by the slow location info as if it were logged locally.
network
connection. However, if the network connection is slower the
n the
rate of event production, then the local application can onl
y
progress at the network rate. In particular, if the network
link to
the the remote client is down, the application will be block
ed.
@n @n On the other hand, if the network link is up, but the
remote
client is down, the client will not be blocked when making l
og
requests but the log events will be lost due to client
unavailability.
@n @n The single remote client case extends to multiple clie
nts
connections. The rate of logging will be determined by the s
lowest
link.
- If the application hosting the <code>SocketHubAppender</co - <code>SocketHubAppender</code> does not use a layout. It
de> ships a serialized spi::LoggingEvent object to the remote s
exits before the <code>SocketHubAppender</code> is closed ei ide.
ther
explicitly or subsequent to garbage collection, then there m
ight
be untransmitted data in the pipe which might be lost. This
is a
common problem on Windows based systems.
@n @n To avoid lost data, it is usually sufficient to #close
the <code>SocketHubAppender</code> either explicitly or by c
alling
the LogManager#shutdown method before
exiting the application.
*/
class LOG4CXX_EXPORT SocketHubAppender : public AppenderSkel - <code>SocketHubAppender</code> relies on the TCP
eton protocol. Consequently, if the remote side is reachable, th
{ en log
private: events will eventually arrive at remote client.
/**
The default port number of the ServerSocket will be
created on.
*/
static int DEFAULT_PORT;
int port; - If no remote clients are attached, the logging requests a
std::vector<helpers::SocketOutputStreamPtr> oosList; re
bool locationInfo; simply dropped.
public: - Logging events are automatically <em>buffered</em> by the
DECLARE_LOG4CXX_OBJECT(SocketHubAppender) native TCP implementation. This means that if the link to r
BEGIN_LOG4CXX_CAST_MAP() emote
LOG4CXX_CAST_ENTRY(SocketHubAppender) client is slow but still faster than the rate of (log) even
LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton) t
END_LOG4CXX_CAST_MAP() production, the application will not be affected by the slo
w network
connection. However, if the network connection is slower th
en the
rate of event production, then the local application can on
ly
progress at the network rate. In particular, if the network
link to
the the remote client is down, the application will be bloc
ked.
@n @n On the other hand, if the network link is up, but the
remote
client is down, the client will not be blocked when making
log
requests but the log events will be lost due to client
unavailability.
@n @n The single remote client case extends to multiple cli
ents
connections. The rate of logging will be determined by the
slowest
link.
SocketHubAppender(); - If the application hosting the <code>SocketHubAppender</c
~SocketHubAppender(); ode>
exits before the <code>SocketHubAppender</code> is closed e
ither
explicitly or subsequent to garbage collection, then there
might
be untransmitted data in the pipe which might be lost. This
is a
common problem on Windows based systems.
@n @n To avoid lost data, it is usually sufficient to #clos
e
the <code>SocketHubAppender</code> either explicitly or by
calling
the LogManager#shutdown method before
exiting the application.
*/
/** class LOG4CXX_EXPORT SocketHubAppender : public AppenderSke
Connects to remote server at <code>address</code> an leton
d <code>port</code>. {
*/ private:
SocketHubAppender(int port) ; /**
The default port number of the ServerSocket will be
created on.
*/
static int DEFAULT_PORT;
/** int port;
Set up the socket server on the specified port. LOG4CXX_LIST_DEF(ObjectOutputStreamList, log4cxx::h
*/ elpers::ObjectOutputStreamPtr);
virtual void activateOptions(); ObjectOutputStreamList streams;
bool locationInfo;
/** public:
Set options DECLARE_LOG4CXX_OBJECT(SocketHubAppender)
*/ BEGIN_LOG4CXX_CAST_MAP()
virtual void setOption(const String& option, const S LOG4CXX_CAST_ENTRY(SocketHubAppender)
tring& value); LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
END_LOG4CXX_CAST_MAP()
/** SocketHubAppender();
Close this appender. ~SocketHubAppender();
<p>This will mark the appender as closed and
call then #cleanUp method.
*/
virtual void close();
/** /**
Release the underlying ServerMonitor thread, and dro Connects to remote server at <code>address</code> a
p the connections nd <code>port</code>.
to all connected remote servers. */ */
void cleanUp(); SocketHubAppender(int port) ;
/** /**
Append an event to all of current connections. */ Set up the socket server on the specified port.
virtual void append(const spi::LoggingEventPtr& even */
t); virtual void activateOptions(log4cxx::helpers::Pool
& p);
/** /**
The SocketHubAppender does not use a layout. Hence, Set options
this method returns */
<code>false</code>. */ virtual void setOption(const LogString& option, con
virtual bool requiresLayout() const st LogString& value);
{ return false; }
/** virtual void close();
The <b>Port</b> option takes a positive integer repr
esenting
the port where the server is waiting for connections
. */
inline void setPort(int port)
{ this->port = port; }
/** /**
Returns value of the <b>Port</b> option. */ Append an event to all of current connections. */
inline int getPort() const virtual void append(const spi::LoggingEventPtr& eve
{ return port; } nt, log4cxx::helpers::Pool& p);
/** /**
The <b>LocationInfo</b> option takes a boolean value The SocketHubAppender does not use a layout. Hence,
. If true, this method returns
the information sent to the remote host will include <code>false</code>. */
location virtual bool requiresLayout() const
information. By default no location information is s { return false; }
ent to the server. */
inline void setLocationInfo(bool locationInfo)
{ this->locationInfo = locationInfo; }
/** /**
Returns value of the <b>LocationInfo</b> option. */ The <b>Port</b> option takes a positive integer rep
inline bool getLocationInfo() const resenting
{ return locationInfo; } the port where the server is waiting for connection
s. */
inline void setPort(int port1)
{ this->port = port1; }
/** /**
Start the ServerMonitor thread. */ Returns value of the <b>Port</b> option. */
private: inline int getPort() const
void startServer(); { return port; }
/** /**
This class is used internally to monitor a ServerSoc The <b>LocationInfo</b> option takes a boolean valu
ket e. If true,
and register new connections in a vector passed in t the information sent to the remote host will includ
he e location
constructor. */ information. By default no location information is
class LOG4CXX_EXPORT ServerMonitor : sent to the server. */
public helpers::Runnable, inline void setLocationInfo(bool locationInfo1)
public helpers::ObjectImpl { this->locationInfo = locationInfo1; }
{
private:
int port;
std::vector<helpers::SocketOutputStreamPtr>
oosList;
bool keepRunning;
helpers::Thread * monitorThread;
public: /**
BEGIN_LOG4CXX_CAST_MAP() Returns value of the <b>LocationInfo</b> option. */
LOG4CXX_CAST_ENTRY(ServerMonitor) inline bool getLocationInfo() const
END_LOG4CXX_CAST_MAP() { return locationInfo; }
/** /**
Create a thread and start the monitor. */ Start the ServerMonitor thread. */
ServerMonitor(int port, private:
const std::vector<helpers::SocketOutputStrea void startServer();
mPtr>& oosList);
/** helpers::Thread thread;
Stops the monitor. This method will not retu static void* LOG4CXX_THREAD_FUNC monitor(apr_thread
rn until _t* thread, void* data);
the thread has finished executing. */
void stopMonitor();
/** }; // class SocketHubAppender
Method that runs, monitoring the ServerSocke LOG4CXX_PTR_DEF(SocketHubAppender);
t and adding connections as } // namespace net
they connect to the socket. */ } // namespace log4cxx
void run();
}; // class ServerMonitor
typedef helpers::ObjectPtrT<ServerMonitor> ServerMon #if defined(_MSC_VER)
itorPtr; #pragma warning ( pop )
ServerMonitorPtr serverMonitor; #endif
}; // class SocketHubAppender
} // namespace net
}; // namespace log4cxx
#endif // _LOG4CXX_NET_SOCKET_HUB_APPENDER_H #endif // _LOG4CXX_NET_SOCKET_HUB_APPENDER_H
 End of changes. 33 change blocks. 
230 lines changed or deleted 192 lines changed or added


 socketoutputstream.h   socketoutputstream.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_SOCKET_OUTPUT_STREAM_H #ifndef _LOG4CXX_HELPERS_SOCKET_OUTPUT_STREAM_H
#define _LOG4CXX_HELPERS_SOCKET_OUTPUT_STREAM_H #define _LOG4CXX_HELPERS_SOCKET_OUTPUT_STREAM_H
#include <log4cxx/helpers/tchar.h> #if defined(_MSC_VER)
#include <log4cxx/helpers/objectimpl.h> #pragma warning ( push )
#include <log4cxx/helpers/objectptr.h> #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
#include <log4cxx/helpers/outputstream.h>
#include <log4cxx/helpers/socket.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class Socket;
typedef ObjectPtrT<Socket> SocketPtr;
class SocketOutputStream;
typedef ObjectPtrT<SocketOutputStream> SocketOutputStreamPtr
;
class LOG4CXX_EXPORT SocketOutputStream : public ObjectImpl class LOG4CXX_EXPORT SocketOutputStream : public OutputStre
{ am
public: {
DECLARE_ABSTRACT_LOG4CXX_OBJECT(SocketOutputStream) public:
BEGIN_LOG4CXX_CAST_MAP() DECLARE_ABSTRACT_LOG4CXX_OBJECT(SocketOutputStream)
LOG4CXX_CAST_ENTRY(SocketOutputStream) BEGIN_LOG4CXX_CAST_MAP()
END_LOG4CXX_CAST_MAP() LOG4CXX_CAST_ENTRY(SocketOutputStream)
LOG4CXX_CAST_ENTRY_CHAIN(OutputStream)
END_LOG4CXX_CAST_MAP()
SocketOutputStream(SocketPtr socket); SocketOutputStream(const SocketPtr& socket);
~SocketOutputStream(); ~SocketOutputStream();
void write(const void * buffer, size_t len); virtual void close(Pool& p);
void write(unsigned int value); virtual void flush(Pool& p);
void write(int value); virtual void write(ByteBuffer& buf, Pool& p);
void write(unsigned long value);
void write(long value);
void write(const String& value);
// some write functions are missing ...
/** Close the stream and dereference the socket. private:
*/ LOG4CXX_LIST_DEF(ByteList, unsigned char);
void close(); ByteList array;
SocketPtr socket;
//
// prevent copy and assignment statements
SocketOutputStream(const SocketOutputStream&);
SocketOutputStream& operator=(const SocketOutputStre
am&);
/** Flushes this output stream and forces any buffer };
ed output
bytes to be written out.
*/
void flush();
protected: LOG4CXX_PTR_DEF(SocketOutputStream);
SocketPtr socket;
/** memory stream buffer */ } // namespace helpers
/* class membuf : } // namespace log4cxx
public std::basic_streambuf<char, std::char_
traits<char> >
{
public:
const void * buffer() const;
const size_t size() const;
}*/
unsigned char * beg, * cur, * end; #if defined(_MSC_VER)
}; #pragma warning ( pop )
} // namespace helpers #endif
}; // namespace log4cxx
#endif // _LOG4CXX_HELPERS_SOCKET_OUTPUT_STREAM_H #endif // _LOG4CXX_HELPERS_SOCKET_OUTPUT_STREAM_H
 End of changes. 11 change blocks. 
55 lines changed or deleted 46 lines changed or added


 strictmath.h   strictmath.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_STRICTMATH_H #ifndef _LOG4CXX_HELPERS_STRICTMATH_H
#define _LOG4CXX_HELPERS_STRICTMATH_H #define _LOG4CXX_HELPERS_STRICTMATH_H
#include <log4cxx/config.h> #include <log4cxx/log4cxx.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
/** /**
The class StrictMath contains methods for performing basic n The class StrictMath contains methods for performing basic
umeric numeric
operations operations
*/ */
class StrictMath class StrictMath
{ {
public: public:
template<typename _type> static inline const _type& template<typename _type> static inline const _type&
minimum(const _type& a, const _type& b) minimum(const _type& a, const _type& b)
{ {
return (a < b) ? a : b; return (a < b) ? a : b;
} }
template<typename _type> static inline const _type& template<typename _type> static inline const _type&
maximum(const _type& a, const _type& b) maximum(const _type& a, const _type& b)
{ {
return (a > b) ? a : b; return (a > b) ? a : b;
} }
}; // class StrictMath }; // class StrictMath
} // namespace helpers } // namespace helpers
}; // namespace log4cx } // namespace log4cx
#endif //_LOG4CXX_HELPERS_STRICTMATH_H #endif //_LOG4CXX_HELPERS_STRICTMATH_H
 End of changes. 4 change blocks. 
29 lines changed or deleted 30 lines changed or added


 stringhelper.h   stringhelper.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_STRING_HELPER_H #ifndef _LOG4CXX_HELPERS_STRING_HELPER_H
#define _LOG4CXX_HELPERS_STRING_HELPER_H #define _LOG4CXX_HELPERS_STRING_HELPER_H
#include <log4cxx/config.h> #include <log4cxx/logstring.h>
#include <log4cxx/helpers/tchar.h> #include <vector>
#include <stdarg.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
/** class Pool;
String manipulation routines /**
*/ String manipulation routines
*/
class LOG4CXX_EXPORT StringHelper class LOG4CXX_EXPORT StringHelper
{ {
public: public:
static String toUpperCase(const String& s); static LogString trim(const LogString& s);
static String toLowerCase(const String& s); static bool startsWith(const LogString& s, const LogString& suf
static String trim(const String& s); fix);
static bool equalsIgnoreCase(const String& s1, const static bool endsWith(const LogString& s, const LogString& suffi
String& s2); x);
static bool endsWith(const String& s, const String& static bool equalsIgnoreCase(const LogString& s1,
suffix); const logchar* upper, const logchar* lower);
/** static bool equalsIgnoreCase(const LogString& s1,
Creates a message with the given pattern and uses it const LogString& upper, const LogString& lower);
to format the
given arguments.
This method provides a means to produce concatenated static int toInt(const LogString& s);
messages in static log4cxx_int64_t toInt64(const LogString& s);
language-neutral way.
@param pattern the pattern for this message. The dif static void toString(int i, log4cxx::helpers::Pool& pool, LogSt
ferent arguments ring& dst);
are represented in the pattern string by the symbols static void toString(log4cxx_int64_t i, log4cxx::helpers::Pool&
{0} to {9} pool, LogString& dst);
static void toString(size_t i, log4cxx::helpers::Pool& pool, Lo
gString& dst);
@param argList a variable list of srrings to be form static void toString(bool val, LogString& dst);
atted and
substituted. The type of the strings must be (TCHAR static LogString toLowerCase(const LogString& s);
*).
*/ static LogString format(const LogString& pattern, const std::ve
static String format(const String& pattern, va_list ctor<LogString>& params);
argList);
}; };
} }
} }
#endif //_LOG4CXX_HELPERS_STRING_HELPER_H #endif //_LOG4CXX_HELPERS_STRING_HELPER_H
 End of changes. 7 change blocks. 
36 lines changed or deleted 35 lines changed or added


 stringmatchfilter.h   stringmatchfilter.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_STRING_MATCH_FILTER_H #ifndef _LOG4CXX_FILTER_STRING_MATCH_FILTER_H
#define _LOG4CXX_VARIA_STRING_MATCH_FILTER_H #define _LOG4CXX_FILTER_STRING_MATCH_FILTER_H
#include <log4cxx/spi/filter.h> #include <log4cxx/spi/filter.h>
namespace log4cxx namespace log4cxx
{ {
namespace varia namespace filter
{ {
/** /**
This is a very simple filter based on string matching. This is a very simple filter based on string matching.
<p>The filter admits two options <b>StringToMatch</b> and
<b>AcceptOnMatch</b>. If there is a match between the value
of the
StringToMatch option and the message of the {@link spi::Logg
ingEvent
LoggingEvent}, then the #decide method returns
{@link spi::Filter#ACCEPT ACCEPT} if the <b>AcceptOnMatch</b
> option
value is true, if it is false then {@link spi::Filter#DENY D
ENY} is
returned. If there is no match, {@link spi::Filter#NEUTRAL N
EUTRAL}
is returned.
<p>See configuration files <a
href="../xml/doc-files/test6.xml">test6.xml</a>, <a
href="../xml/doc-files/test7.xml">test7.xml</a>, <a
href="../xml/doc-files/test8.xml">test8.xml</a>, <a
href="../xml/doc-files/test9.xml">test9.xml</a>, and <a
href="../xml/doc-files/test10.xml">test10.xml</a> for exampl
es of
seeting up a <code>StringMatchFilter</code>.
*/
class StringMatchFilter; <p>The filter admits two options <b>StringToMatch</b> and
typedef helpers::ObjectPtrT<StringMatchFilter> StringMatchFi <b>AcceptOnMatch</b>. If there is a match between the value
lterPtr; of the
StringToMatch option and the message of the {@link spi::Log
gingEvent
LoggingEvent}, then the #decide method returns
{@link log4cxx::spi::Filter#ACCEPT ACCEPT} if the <b>Accept
OnMatch</b> option
value is true, if it is false then {@link log4cxx::spi::Fil
ter#DENY DENY} is
returned. If there is no match, {@link log4cxx::spi::Filter
#NEUTRAL NEUTRAL}
is returned.
class LOG4CXX_EXPORT StringMatchFilter : public spi::Filter <p>See configuration files <a
{ href="../xml/doc-files/test6.xml">test6.xml</a>, <a
private: href="../xml/doc-files/test7.xml">test7.xml</a>, <a
static String STRING_TO_MATCH_OPTION; href="../xml/doc-files/test8.xml">test8.xml</a>, <a
static String ACCEPT_ON_MATCH_OPTION; href="../xml/doc-files/test9.xml">test9.xml</a>, and <a
href="../xml/doc-files/test10.xml">test10.xml</a> for examp
les of
seeting up a <code>StringMatchFilter</code>.
*/
bool acceptOnMatch; class LOG4CXX_EXPORT StringMatchFilter : public spi::Filter
String stringToMatch; {
private:
bool acceptOnMatch;
LogString stringToMatch;
public: public:
typedef spi::Filter BASE_CLASS; typedef spi::Filter BASE_CLASS;
DECLARE_LOG4CXX_OBJECT(StringMatchFilter) DECLARE_LOG4CXX_OBJECT(StringMatchFilter)
BEGIN_LOG4CXX_CAST_MAP() BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(StringMatchFilter) LOG4CXX_CAST_ENTRY(StringMatchFilter)
LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS) LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
END_LOG4CXX_CAST_MAP() END_LOG4CXX_CAST_MAP()
StringMatchFilter(); StringMatchFilter();
/** /**
Set options Set options
*/ */
virtual void setOption(const String& option, virtual void setOption(const LogString& option,
const String& value); const LogString& value);
inline void setStringToMatch(const String& stringToM inline void setStringToMatch(const LogString& strin
atch) gToMatch1)
{ this->stringToMatch = stringToMatch; } { this->stringToMatch.assign(stringToMatch1
); }
inline const String& getStringToMatch() const inline const LogString& getStringToMatch() const
{ return stringToMatch; } { return stringToMatch; }
inline void setAcceptOnMatch(bool acceptOnMatch) inline void setAcceptOnMatch(bool acceptOnMatch1)
{ this->acceptOnMatch = acceptOnMatch; } { this->acceptOnMatch = acceptOnMatch1; }
inline bool getAcceptOnMatch() const inline bool getAcceptOnMatch() const
{ return acceptOnMatch; } { return acceptOnMatch; }
/** /**
Returns {@link spi::Filter#NEUTRAL NEUTRAL} Returns {@link log4cxx::spi::Filter#NEUTRAL NEUTRAL
is there is no string match. }
*/ is there is no string match.
FilterDecision decide(const spi::LoggingEventPtr& ev */
ent) const; FilterDecision decide(const spi::LoggingEventPtr& e
}; // class StringMatchFilter vent) const;
} // namespace varia }; // class StringMatchFilter
}; // namespace log4cxx LOG4CXX_PTR_DEF(StringMatchFilter);
} // namespace filter
} // namespace log4cxx
#endif // _LOG4CXX_VARIA_STRING_MATCH_FILTER_H #endif // _LOG4CXX_FILTER_STRING_MATCH_FILTER_H
 End of changes. 15 change blocks. 
76 lines changed or deleted 73 lines changed or added


 stringtokenizer.h   stringtokenizer.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_STRING_TOKENIZER_H #ifndef _LOG4CXX_HELPERS_STRING_TOKENIZER_H
#define _LOG4CXX_HELPERS_STRING_TOKENIZER_H #define _LOG4CXX_HELPERS_STRING_TOKENIZER_H
#include <log4cxx/helpers/tchar.h> #include <log4cxx/logstring.h>
#include <log4cxx/helpers/exception.h> #include <log4cxx/helpers/exception.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class LOG4CXX_EXPORT NoSuchElementException : public Excepti class LOG4CXX_EXPORT StringTokenizer
on {
{ public:
}; StringTokenizer(const LogString& str, const LogStri
ng& delim);
~StringTokenizer();
bool hasMoreTokens() const;
LogString nextToken();
class LOG4CXX_EXPORT StringTokenizer protected:
{ LogString src;
public: LogString delim;
StringTokenizer(const String& str, const String& del size_t pos;
im);
~StringTokenizer();
bool hasMoreTokens() const;
String nextToken();
protected: private:
TCHAR * str; // prevent copy and assignment statements
String delim; StringTokenizer(const StringTokenizer&);
TCHAR * token; StringTokenizer& operator=(const StringTokenizer&);
TCHAR * state; }; // class StringTokenizer
}; // class StringTokenizer } // namespace helpers;
} // namespace helpers; } // namespace log4cxx;
}; // namespace log4cxx;
#endif //_LOG4CXX_HELPERS_STRING_TOKENIZER_H #endif //_LOG4CXX_HELPERS_STRING_TOKENIZER_H
 End of changes. 5 change blocks. 
28 lines changed or deleted 28 lines changed or added


 syslogappender.h   syslogappender.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_NET_SYSLOG_APPENDER_H #ifndef _LOG4CXX_NET_SYSLOG_APPENDER_H
#define _LOG4CXX_NET_SYSLOG_APPENDER_H #define _LOG4CXX_NET_SYSLOG_APPENDER_H
#include <log4cxx/appenderskeleton.h> #include <log4cxx/appenderskeleton.h>
#include <log4cxx/helpers/syslogwriter.h> #include <log4cxx/helpers/syslogwriter.h>
#ifndef HAVE_SYSLOG
#endif
namespace log4cxx namespace log4cxx
{ {
namespace net namespace net
{ {
class SyslogAppender; /** Use SyslogAppender to send log messages to a remote sys
typedef helpers::ObjectPtrT<SyslogAppender> SyslogAppenderPt log daemon.*/
r; class LOG4CXX_EXPORT SyslogAppender : public AppenderSkelet
on
/** Use SyslogAppender to send log messages to a remote sysl {
og daemon.*/ public:
class LOG4CXX_EXPORT SyslogAppender : public AppenderSkeleto DECLARE_LOG4CXX_OBJECT(SyslogAppender)
n BEGIN_LOG4CXX_CAST_MAP()
{ LOG4CXX_CAST_ENTRY(SyslogAppender)
public: LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
DECLARE_LOG4CXX_OBJECT(SyslogAppender) END_LOG4CXX_CAST_MAP()
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(SyslogAppender)
LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
END_LOG4CXX_CAST_MAP()
SyslogAppender(); SyslogAppender();
SyslogAppender(const LayoutPtr& layout, int syslogFa SyslogAppender(const LayoutPtr& layout, int syslogF
cility); acility);
SyslogAppender(const LayoutPtr& layout, SyslogAppender(const LayoutPtr& layout,
const String& syslogHost, int syslogFacility const LogString& syslogHost, int syslogFaci
); lity);
~SyslogAppender(); ~SyslogAppender();
/** Release any resources held by this SyslogAppende /** Release any resources held by this SyslogAppend
r.*/ er.*/
void close(); void close();
/** /**
Returns the specified syslog facility as a lower-cas Returns the specified syslog facility as a lower-ca
e String, se String,
e.g. "kern", "user", etc. e.g. "kern", "user", etc.
*/ */
static String getFacilityString(int syslogFacility); static LogString getFacilityString(int syslogFacili
ty);
/** /**
Returns the integer value corresponding to the named Returns the integer value corresponding to the name
syslog d syslog
facility, or -1 if it couldn't be recognized. facility, or -1 if it couldn't be recognized.
@param facilityName one of the strings KERN, USER, M @param facilityName one of the strings KERN, USER,
AIL, DAEMON, MAIL, DAEMON,
AUTH, SYSLOG, LPR, NEWS, UUCP, CRON, AUTHPRIV, FTP, AUTH, SYSLOG, LPR, NEWS, UUCP, CRON, AUTHPRIV, FTP,
LOCAL0, LOCAL0,
LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCA LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOC
L7. AL7.
The matching is case-insensitive. The matching is case-insensitive.
*/ */
static int getFacility(const String &facilityName); static int getFacility(const LogString &facilityNam
e);
void append(const spi::LoggingEventPtr& event); void append(const spi::LoggingEventPtr& event, log4 cxx::helpers::Pool& p);
/** /**
This method returns immediately as options are activ This method returns immediately as options are acti
ated when they vated when they
are set. are set.
*/ */
void activateOptions(); void activateOptions(log4cxx::helpers::Pool& p);
void setOption(const String& option, const String& v void setOption(const LogString& option, const LogSt
alue); ring& value);
/** /**
The SyslogAppender requires a layout. Hence, this me The SyslogAppender requires a layout. Hence, this m
thod returns ethod returns
<code>true</code>. <code>true</code>.
*/ */
virtual bool requiresLayout() const virtual bool requiresLayout() const
{ return true; } { return true; }
/** /**
The <b>SyslogHost</b> option is the name of the the The <b>SyslogHost</b> option is the name of the the
syslog host syslog host
where log output should go. where log output should go.
<b>WARNING</b> If the SyslogHost is not set, then th <b>WARNING</b> If the SyslogHost is not set, then t
is appender his appender
will fail. will fail.
*/ */
void setSyslogHost(const String& syslogHost); void setSyslogHost(const LogString& syslogHost);
/** /**
Returns the value of the <b>SyslogHost</b> option. Returns the value of the <b>SyslogHost</b> option.
*/ */
inline const String& getSyslogHost() const inline const LogString& getSyslogHost() const
{ return syslogHost; } { return syslogHost; }
/** /**
Set the syslog facility. This is the <b>Facility</b> Set the syslog facility. This is the <b>Facility</b
option. > option.
<p>The <code>facilityName</code> parameter must be o <p>The <code>facilityName</code> parameter must be
ne of the one of the
strings KERN, USER, MAIL, DAEMON, AUTH, SYSLOG, LPR, strings KERN, USER, MAIL, DAEMON, AUTH, SYSLOG, LPR
NEWS, UUCP, , NEWS, UUCP,
CRON, AUTHPRIV, FTP, LOCAL0, LOCAL1, LOCAL2, LOCAL3, CRON, AUTHPRIV, FTP, LOCAL0, LOCAL1, LOCAL2, LOCAL3
LOCAL4, , LOCAL4,
LOCAL5, LOCAL6, LOCAL7. Case is unimportant. LOCAL5, LOCAL6, LOCAL7. Case is unimportant.
*/ */
void setFacility(const String& facilityName); void setFacility(const LogString& facilityName);
/** /**
Returns the value of the <b>Facility</b> option. Returns the value of the <b>Facility</b> option.
*/ */
inline String getFacility() const inline LogString getFacility() const
{ return getFacilityString(syslogFacility); { return getFacilityString(syslogFacility);
} }
/** /**
If the <b>FacilityPrinting</b> option is set to true If the <b>FacilityPrinting</b> option is set to tru
, the printed e, the printed
message will include the facility name of the applic message will include the facility name of the appli
ation. It is cation. It is
<em>false</em> by default. <em>false</em> by default.
*/ */
inline void setFacilityPrinting(bool facilityPrintin inline void setFacilityPrinting(bool facilityPrinti
g) ng1)
{ this->facilityPrinting = facilityPrinting; { this->facilityPrinting = facilityPrinting
} 1; }
/** /**
Returns the value of the <b>FacilityPrinting</b> opt Returns the value of the <b>FacilityPrinting</b> op
ion. tion.
*/ */
inline bool getFacilityPrinting() const inline bool getFacilityPrinting() const
{ return facilityPrinting; } { return facilityPrinting; }
protected: protected:
void initSyslogFacilityStr(); void initSyslogFacilityStr();
int syslogFacility; // Have LOG_USER as default int syslogFacility; // Have LOG_USER as default
String facilityStr; LogString facilityStr;
bool facilityPrinting; bool facilityPrinting;
helpers::SyslogWriter * sw; helpers::SyslogWriter * sw;
String syslogHost; LogString syslogHost;
}; // class SyslogAppender private:
SyslogAppender(const SyslogAppender&);
SyslogAppender& operator=(const SyslogAppender&);
}; // class SyslogAppender
LOG4CXX_PTR_DEF(SyslogAppender);
} // namespace net } // namespace net
}; // namespace log4cxx } // namespace log4cxx
#endif // _LOG4CXX_NET_SYSLOG_APPENDER_H #endif // _LOG4CXX_NET_SYSLOG_APPENDER_H
 End of changes. 19 change blocks. 
128 lines changed or deleted 128 lines changed or added


 syslogwriter.h   syslogwriter.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_SYSLOG_WRITER_H
#define _LOG4CXX_SYSLOG_WRITER_H
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/inetaddress.h> #include <log4cxx/helpers/inetaddress.h>
#include <log4cxx/helpers/datagramsocket.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class DatagramSocket; /**
typedef helpers::ObjectPtrT<DatagramSocket> DatagramSocketPt SyslogWriter is a wrapper around the DatagramSocket class
r; it writes text to the specified host on the port 514 (UNIX
syslog)
*/
class LOG4CXX_EXPORT SyslogWriter
{
public:
SyslogWriter(const LogString& syslogHost);
void write(const LogString& string);
/** private:
SyslogWriter is a wrapper around the DatagramSocket class LogString syslogHost;
it writes text to the specified host on the port 514 (UNIX s InetAddressPtr address;
yslog) DatagramSocketPtr ds;
*/ };
class LOG4CXX_EXPORT SyslogWriter } // namespace helpers
{ } // namespace log4cxx
public:
SyslogWriter(const String& syslogHost);
void write(const String& string);
private: #endif
String syslogHost;
InetAddress address;
DatagramSocketPtr ds;
};
} // namespace helpers
}; // namespace log4cxx
 End of changes. 6 change blocks. 
20 lines changed or deleted 29 lines changed or added


 system.h   system.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_SYSTEM_H #ifndef _LOG4CXX_HELPERS_SYSTEM_H
#define _LOG4CXX_HELPERS_SYSTEM_H #define _LOG4CXX_HELPERS_SYSTEM_H
#include <log4cxx/config.h> #include <log4cxx/logstring.h>
#include <log4cxx/helpers/tchar.h> #include <log4cxx/helpers/exception.h>
#include <log4cxx/helpers/exception.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class Properties; class Properties;
/** The System class contains several useful class fields an
d methods.
It cannot be instantiated.
*/
class LOG4CXX_EXPORT System
{
public:
/** Returns the current time in milliseconds since midnight
(0 hour),
January 1, 1970.
Returns the current time in milliseconds. Note that while th
e unit of
time of the return value is a millisecond, the granularity o
f the value
depends on the underlying operating system and may be larger
. For
example, many operating systems measure time in units of ten
s of
milliseconds.
@return the difference, measured in milliseconds, between th
e current
time and midnight, January 1, 1970 UTC.
*/
static int64_t currentTimeMillis();
/**
Gets the system property indicated by the specified key.
@param key the name of the system property.
@return the string value of the system property, or the defa /** The System class contains several useful class fields a
ult value if nd methods.
there is no property with that key. It cannot be instantiated.
*/
class LOG4CXX_EXPORT System
{
public:
@throws IllegalArgumentException if key is empty. /**
*/ Gets the system property indicated by the specified key.
static String getProperty(const String& key);
/** @param key the name of the system property.
Sets the system property indicated by the specified key.
@param key the name of the system property. @return the string value of the system property, or the def
@param value the value of the system property. ault value if
there is no property with that key.
@throws IllegalArgumentException if key is empty. @throws IllegalArgumentException if key is empty.
*/ */
static void setProperty(const String& key, const String& val static LogString getProperty(const LogString& key);
ue);
static void setProperties(const Properties& props); };
}; } // namespace helpers
} // namespace helpers } // namespace log4cxx
}; // namespace log4cxx
#endif //_LOG4CXX_HELPERS_SYSTEM_H #endif //_LOG4CXX_HELPERS_SYSTEM_H
 End of changes. 9 change blocks. 
61 lines changed or deleted 30 lines changed or added


 tchar.h   tchar.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_TCHAR_H #ifndef _LOG4CXX_HELPERS_TCHAR_H
#define _LOG4CXX_HELPERS_TCHAR_H #define _LOG4CXX_HELPERS_TCHAR_H
#include <log4cxx/config.h> #error log4cxx/helpers/tchar.h is obsolete, see details following this line
#include <string> .
#include <iostream>
#include <sstream>
#include <cwchar>
#include <algorithm> // min & max
#include <stdio.h> // sprintf
#include <streambuf> // basic_streambuf
#include <log4cxx/helpers/strictmath.h>
class Convert
{
public:
static wchar_t * ansiToUnicode(wchar_t * dst, const char * src)
{
::mbstowcs(dst, src, 512);
return dst;
}
static char * unicodeToAnsi(char * dst, const wchar_t * src)
{
::wcstombs(dst, src, 512);
return dst;
}
static void int64ToString(wchar_t * dst, size_t maxlen, const int64_
t& ll)
{
#ifdef WIN32
_snwprintf(dst, maxlen, L"%I64d", ll);
#else
swprintf(dst, maxlen, L"%lld", ll);
#endif
}
static void int64ToString(char * dst, size_t maxlen, const int64_t&
ll)
{
#ifdef WIN32
_snprintf(dst, maxlen, "%I64d", ll);
#else
snprintf(dst, maxlen, "%lld", ll);
#endif
}
};
namespace std
{
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& os, const int64_t
& ll)
{
_CharT buff[21];
Convert::int64ToString(buff, 20, ll);
os << buff;
return os;
}
}
#ifdef MUST_UNDEF_T
#undef _T
#endif
#ifdef WIN32
#ifndef USES_CONVERSION
#include <malloc.h>
#define USES_CONVERSION void * _dst = _alloca(1024);
#endif
#else
#include <alloca.h>
#define USES_CONVERSION void * _dst = alloca(1024);
#endif
#ifndef W2A
#define W2A(src) Convert::unicodeToAnsi((char *)_dst, src)
#endif
#ifndef A2W
#define A2W(src) Convert::ansiToUnicode((wchar_t *)_dst, src)
#endif
#ifdef UNICODE
#include <wctype.h>
#ifndef _T
#define _T(x) L ## x
#endif
#ifndef TCHAR
typedef wchar_t TCHAR;
#endif
#define totupper towupper
#define totlower towlower
#define tcout std::wcout
#define tcerr std::wcerr
#ifdef WIN32
#define tstrncasecmp _wcsnicmp
#else
#define tstrncasecmp wcsncasecmp
#endif // WIN32
#ifndef T2A
#define T2A(src) W2A(src)
#endif
#ifndef T2W
#define T2W(src) src
#endif
#ifndef A2T
#define A2T(src) A2W(src)
#endif
#ifndef W2T
#define W2T(src) src
#endif
#define ttol(s) wcstol(s, 0, 10)
#define itot _itow
#define tcscmp wcscmp
#else // Not UNICODE
#include <ctype.h>
#ifndef _T
#define _T(x) x
#endif
typedef char TCHAR;
#define totupper toupper
#define totlower tolower
#define tcout std::cout
#define tcerr std::cerr
#ifdef WIN32
#define tstrncasecmp _strnicmp
#else
#define tstrncasecmp strncasecmp
#endif // WIN32
#ifndef T2A
#define T2A(src) src
#endif
#ifndef T2W
#define T2W(src) A2W(src)
#endif
#ifndef A2T
#define A2T(src) src
#endif
#ifndef W2T
#define W2T(src) W2A(src)
#endif
#define ttol atol
#define itot itoa
#define tcscmp strcmp
#endif // UNICODE
#define _MinInc size_t(512)
#define _MaxInc size_t(100 * 1024)
namespace log4cxx
{
class stringbuf : public std::basic_streambuf<TCHAR>
{
public:
typedef std::basic_streambuf<TCHAR> base;
typedef base::char_type char_type;
typedef base::traits_type traits_type;
typedef std::allocator<char_type> allocator_type;
typedef traits_type::int_type int_type;
~stringbuf()
{
char_type * b = pbase();
if (b)
{
al.deallocate(b, epptr() - b);
}
}
virtual int_type overflow(
int_type c = stringbuf::traits_type::eof())
{
using namespace std;
if (traits_type::eq_int_type(traits_type::eof(), c))
{
return traits_type::not_eof(c);
}
char_type *b = pbase();
if (b == 0)
{
char_type * p = (char_type *)al.allocate(_Mi
nInc, 0);
setp(p, p + _MinInc);
}
else
{
size_t os = epptr() - b; // taille allou
size_t is =
helpers::StrictMath::maximum(
helpers::StrictMath::minimum(
(os * 2), _MaxInc),_MinInc)
+ 1; // incr
char_type *p = (char_type *)al.allocate(os +
is, 0);
traits_type::copy(p, b, os);
al.deallocate(b, epptr() - b);
setp(p, p + os + is);
pbump((int)os);
}
*pptr() = c;
pbump(1);
return traits_type::not_eof(c);
}
std::basic_string<char_type> str() const
{
return std::basic_string<char_type>(pbase(), pptr()
- pbase());
}
void str(const std::basic_string<char_type>& s)
{
setp(pbase(), epptr());
}
virtual pos_type seekoff(off_type off, std::ios_base::seekdi
r way,
std::ios_base::openmode mode = std::ios_base::in | s
td::ios_base::out)
{
pos_type ret = pos_type(off_type(-1));
if (mode == std::ios_base::out)
{
if (way == std::ios_base::beg)
{
setp(pbase(), epptr());
ret = pos_type(off);
pbump(off);
}
else if (way == std::ios_base::end)
{
setp(pbase(), epptr());
ret = pos_type(off + epptr() - pbase
());
pbump(off + epptr() - pbase());
}
else if (way == std::ios_base::cur)
{
pbump(off);
ret = pos_type(pptr() - pbase());
}
}
return ret;
}
virtual pos_type seekpos(pos_type pos,
std::ios_base::openmode mode = std::ios_base::in | s
td::ios_base::out)
{
std::streamoff off = (std::streamoff)pos;
if (pbase() + off > epptr())
{
return pos_type(-1);
}
else
{
setp(pbase(), epptr());
pbump(off);
return pos;
}
}
protected:
allocator_type al;
};
class StringBuffer : public std::basic_ostream<TCHAR>
{
public:
StringBuffer() : std::basic_ostream<TCHAR>(0)
{ this->init(&buffer); }
inline std::basic_string<TCHAR> str() const
{ return buffer.str(); }
inline void str(const std::basic_string<TCHAR>& s)
{ buffer.str(s); }
protected:
stringbuf buffer;
};
typedef std::basic_string<TCHAR> String; /**
typedef std::basic_ostream<TCHAR> ostream; * A short history of log4cxx's tchar.h
typedef std::basic_istream<TCHAR> istream; *
} * The previous log4cxx/helpers/tchar.h contained macros that
* attempted to replicate macros and functions defined by
* the Microsoft SDK's tchar.h and related header files
* such as _T() and TCHAR.
*
* When building apps using both log4cxx and Microsoft SDK's tchar.h,
* these definitions could conflict and, for example, the code generated
* by _T("Foo") would depend on the include order of the two
* tchar.h's.
*
* The motivation of tchar.h in the Microsoft SDK was to
* support presenting either a wide-char or multi-byte char
* facade to a C API depending on the presence of
* the _UNICODE or _MBCS preprocessor macros. When _UNICODE
* was set then tchar was typedef'd as wchar_t and, for example,
* the CreateProcess macro was defined to be CreateProcessW, If
* _MBCS was defined, then tchar was typedef'd as char
* and CreateProcess macro was defined to be CreateProcessA.
*
* In either case, the setting of _UNICODE or _MBCS
* didn't affect the implementation of the operating system.
* If you were running the Windows NT family, all the multi-byte
* methods delegated to a wide-char implementation.
* In the Windows 9x family, most wide-char methods delegated
* to a multi-byte implementation.
*
* In practice, most Microsoft Windows executables were either
* wide-char or multi-byte centric. However, they did not
* have to be exclusively so. An application built with
* _UNICODE, could still call multi-byte API functions,
* they would just need to explicitly call CreateProcessA
* instead of using the facade macro. An executable could
* also use both a multi-byte centric and wide-char centric
* DLL's since all the calls eventually hit the same
* underlying implementation be it a wide-char on in
* Windows NT or multi-char in Windows 9x.
*
* The use of log4cxx/helpers/tchar.h in log4cxx 0.9.7 was
* undesirable because it made log4cxx either exclusively
* wide-char or exclusively multi-byte and had to be consistant
* with the character model of the calling executable.
* This would make it extremely difficult to use
* log4cxx when DLL's with different character models
* where called by the same application. Since log4cxx
* was C++, not C, function overloading could be
* used instead of the CreateProcess et al macros
* used in the Windows headers.
*
* In the rework before the 0.9.8, the following changes
* were made to log4cxx:
*
* 1. All inclusions of log4cxx/helpers/tchar.h
* and use of TCHAR, log4cxx::String and _T
* were removed from log4cxx.
* 2. log4cxx/logstring.h was added to define the
* implementation character model using the log4cxx::logchar
* and log4cxx::LogString typedefs and LOG4CXX_STR macro.
* 3. Methods commonly used by calling applications were defined
* in both wide-char and multi-byte and both pointer and string
* forms with conversion to the implementation character
* model delayed as long as possible.
* 4. Use of Standard Template Library streams within
* log4cxx was substantially reduced (but not totally
* elminated).
* 5. The LOG4CXX_DEBUG and similar macros were simplified
* and now only take arguments that evaluate to
* character pointers or strings and no longer take
* the right hand side of an insertion operation:
*
* // This used to work, but no longer
* LOG4CXX_DEBUG(logger, "foo" << i);
*
* If you extensively used this idiom, please consider
* migrating to stream-like API defined in log4cxx/stream.h.
*
* 6. The LOG4CXX_DEBUG and similar use the LOG4CXX_LOCATION
* macro to define the log statement location instead of
* using __FILE__ and __LINE__. Logger::debug and
* similar now take const LocationInfo& instead of
* separate const char* and int arguments. This allows
* class and method names to appear in location info.
* 7. log4cxx include files no longer include config.h
* or related files. config.h and related files
* may be used by log4cxx implementation, but have
* no effect on the exposed API.
*
* It is expected that the default implementation character
* model will be wchar_t. However this may vary by platform
* and may be changed based on feedback.
*
* Developers using log4cxx should seldom be concerned
* with the internal character model of log4cxx unless
* writing custom appenders or layouts. An application
* should not be using log4cxx::logchar, log4cxx::LogString
* or LOG4CXX_STR unless dealing with something that is
* clearly a log4cxx internal. If you find something
* defined as using or returning LogString that you
* don't consider a log4cxx internal, please file a
* bug report or post a message to one of the mailing lists.
*
* wchar_t literals should be preferred in log requests since
* since they eliminate potential encoding confusion
* when the development and deployment encodings are different.
*
* Migration strategies:
*
* If you followed the examples in the previous log4cxx versions,
* you may have _T() macros littered through your code
* and inclusions of this file. If you are on the Microsoft
* platform, the simplest solution is to just include
* the Platform SDK's tchar.h which would result your log
* statements matching the character model of your application.
*
* If you targetting another platform and your only use of
* _T() in related to log4cxx, then I would recommend replacing
* all _T() with another macro (say MYAPP_LOGSTR())
* and defining that macro in a commonly included header file
* or defining _T() in a commonly included header file.
*
* I would first try defining these macros as
*
* #define _T(str) L ## str
*
* If that results in too many compilation errors, then try:
*
* #define _T(str) str
*
* Using the first form will result in wchar_t literals which
* will avoid potential encoding confusion and is expected
* to result in slightly better performance when logging.
*
* Since the best choice for _T() depends on the application,
* there is not a definition within log4cxx.
*
* Use encoding conversion macros A2T, W2T, et al should
* not longer be necessary. If you are doing a lot of
* work converting between encodings, you might consider
* using the stream-like interface in log4cxx/stream.h
* which defines insertion operators for multi-byte
* strings in addition to exposing all the
* insertion operations defined for
* std::basic_ostream<wchar_t>.
*
*/
#endif //_LOG4CXX_HELPERS_TCHAR_H #endif //_LOG4CXX_HELPERS_TCHAR_H
 End of changes. 3 change blocks. 
308 lines changed or deleted 155 lines changed or added


 telnetappender.h   telnetappender.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_NET_TELNET_APPENDER_H #ifndef _LOG4CXX_NET_TELNET_APPENDER_H
#define _LOG4CXX_NET_TELNET_APPENDER_H #define _LOG4CXX_NET_TELNET_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/socket.h> #include <log4cxx/helpers/socket.h>
#include <log4cxx/helpers/serversocket.h> #include <log4cxx/helpers/serversocket.h>
#include <log4cxx/helpers/thread.h> #include <log4cxx/helpers/thread.h>
#include <vector> #include <vector>
#include <log4cxx/helpers/charsetencoder.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers {
{ class ByteBuffer;
class SocketOutputStream; }
typedef helpers::ObjectPtrT<SocketOutputStream> SocketOutput namespace net
StreamPtr; {
}
namespace net
{
/** /**
<p>The TelnetAppender is a log4cxx appender that specializes in <p>The TelnetAppender is a log4cxx appender that specializes in
writing to a read-only socket. The output is provided in a writing to a read-only socket. The output is provided in a
telnet-friendly way so that a log can be monitored over TCP/IP. telnet-friendly way so that a log can be monitored over TCP/IP.
Clients using telnet connect to the socket and receive log data. Clients using telnet connect to the socket and receive log data.
This is handy for remote monitoring, especially when monitoring a This is handy for remote monitoring, especially when monitoring a
servlet. servlet.
<p>Here is a list of the available configuration options: <p>Here is a list of the available configuration options:
skipping to change at line 62 skipping to change at line 66
</tr> </tr>
<tr> <tr>
<td>Port</td> <td>Port</td>
<td>optional</td> <td>optional</td>
<td>This parameter determines the port to use for announcing log events. T he default port is 23 (telnet).</td> <td>This parameter determines the port to use for announcing log events. T he default port is 23 (telnet).</td>
<td>5875</td> <td>5875</td>
</table> </table>
*/ */
class LOG4CXX_EXPORT TelnetAppender : public AppenderSkeleton class LOG4CXX_EXPORT TelnetAppender : public AppenderSkeleton
{ {
class SocketHandler; class SocketHandler;
friend class SocketHandler; friend class SocketHandler;
private: private:
static int DEFAULT_PORT; static const int DEFAULT_PORT;
SocketHandler * sh; static const int MAX_CONNECTIONS;
int port; int port;
public:
DECLARE_LOG4CXX_OBJECT(TelnetAppender)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(TelnetAppender)
LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
END_LOG4CXX_CAST_MAP()
TelnetAppender(); public:
~TelnetAppender(); DECLARE_LOG4CXX_OBJECT(TelnetAppender)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(TelnetAppender)
LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
END_LOG4CXX_CAST_MAP()
/** TelnetAppender();
This appender requires a layout to format the text t ~TelnetAppender();
o the
attached client(s). */
virtual bool requiresLayout() const
{ return true; }
/** all of the options have been set, create the soc /**
ket handler and This appender requires a layout to format the text
wait for connections. */ to the
void activateOptions(); attached client(s). */
virtual bool requiresLayout() const
{ return true; }
/** LogString getEncoding() const;
Set options void setEncoding(const LogString& value);
*/
virtual void setOption(const String& option, const S
tring& value);
/** /** all of the options have been set, create the so
Returns value of the <b>Port</b> option. cket handler and
*/ wait for connections. */
int getPort() const void activateOptions(log4cxx::helpers::Pool& p);
{ return port; }
/** /**
The <b>Port</b> option takes a positive integer representing Set options
the port where the server is waiting for connections. */
*/ virtual void setOption(const LogString& option, con
void setPort(int port) st LogString& value);
{ this->port = port; }
/** shuts down the appender. */ /**
void close(); Returns value of the <b>Por
t</b> option.
*/
int getPort() const
{ return port; }
protected: /**
/** Handles a log event. For this appender, that me The <b>Port</b> option take
ans writing the s a positive integer representing
message to each connected client. */ the port where the server i
virtual void append(const spi::LoggingEventPtr& even s waiting for connections.
t) ; */
void setPort(int port1)
{ this->port = port1; }
//-------------------------------------------------- /** shuts down the appender. */
-------- SocketHandler: void close();
private: protected:
/** The SocketHandler class is used to accept connec /** Handles a log event. For this appender, that m
tions from eans writing the
clients. It is threaded so that clients can connect message to each connected client. */
/disconnect virtual void append(const spi::LoggingEventPtr& eve
asynchronously. */ nt, log4cxx::helpers::Pool& p) ;
class LOG4CXX_EXPORT SocketHandler : public helpers:
:Thread
{
private:
bool done;
std::vector<helpers::SocketOutputStreamPtr>
writers;
std::vector<helpers::SocketPtr> connections;
helpers::ServerSocket serverSocket;
std::vector<helpers::SocketPtr>::size_type M
AX_CONNECTIONS;
public: //-------------------------------------------------
SocketHandler(int port); --------- SocketHandler:
/** make sure we close all network connectio private:
ns when this handler // prevent copy and assignment statements
is destroyed. */ TelnetAppender(const TelnetAppender&);
void finalize(); TelnetAppender& operator=(const TelnetAppender&);
/** sends a message to each of the clients i typedef log4cxx::helpers::SocketPtr Connection;
n telnet-friendly output. */ LOG4CXX_LIST_DEF(ConnectionList, Connection);
void send(const String& message);
/** void write(log4cxx::helpers::ByteBuffer&);
Continually accepts client connections. Cli void writeStatus(const log4cxx::helpers::SocketPtr&
ent connections socket, const LogString& msg, log4cxx::helpers::Pool& p);
are refused when MAX_CONNECTIONS is reached. ConnectionList connections;
*/ LogString encoding;
virtual void run(); log4cxx::helpers::CharsetEncoderPtr encoder;
helpers::ServerSocket* serverSocket;
helpers::Thread sh;
size_t activeConnections;
static void* LOG4CXX_THREAD_FUNC acceptConnections(
apr_thread_t* thread, void* data);
}; // class TelnetAppender
protected: LOG4CXX_PTR_DEF(TelnetAppender);
void print(helpers::SocketOutputStreamPtr& o
s, const String& sz);
}; // class SocketHandler
}; // class TelnetAppender
} // namespace net } // namespace net
}; // namespace log4cxx } // namespace log4cxx
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#endif // _LOG4CXX_NET_TELNET_APPENDER_H #endif // _LOG4CXX_NET_TELNET_APPENDER_H
 End of changes. 21 change blocks. 
104 lines changed or deleted 97 lines changed or added


 thread.h   thread.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_THREAD_H #ifndef _LOG4CXX_HELPERS_THREAD_H
#define _LOG4CXX_HELPERS_THREAD_H #define _LOG4CXX_HELPERS_THREAD_H
#include <log4cxx/config.h> #include <log4cxx/log4cxx.h>
#include <log4cxx/helpers/object.h> #include <log4cxx/helpers/pool.h>
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/exception.h>
#include <log4cxx/mdc.h>
// Windows specific : #if !defined(LOG4CXX_THREAD_FUNC)
// winspool.h defines MIN_PRIORITY and MAX_PRIORITY #if defined(_WIN32)
#ifdef MIN_PRIORITY #define LOG4CXX_THREAD_FUNC __stdcall
#define OLD_MIN_PRIORITY MIN_PRIORITY #else
#undef MIN_PRIORITY #define LOG4CXX_THREAD_FUNC
#endif #endif
#ifdef MAX_PRIORITY
#define OLD_MAX_PRIORITY MAX_PRIORITY
#undef MAX_PRIORITY
#endif #endif
extern "C" {
typedef struct apr_thread_t apr_thread_t;
}
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class LOG4CXX_EXPORT ThreadException : public Exception class Pool;
{ class ThreadLocal;
};
class LOG4CXX_EXPORT InterruptedException : public Exception
{
};
/** The Runnable interface should be implemented by any clas
s whose
instances are intended to be executed by a thread.
The class must define a method of no arguments called run.
*/
class LOG4CXX_EXPORT Runnable : public virtual Object
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Runnable)
/** When an object implementing interface Runnable i
s used to
create a thread, starting the thread causes the obje
ct's run
method to be called in that separately executing thr
ead.
*/
virtual void run() = 0;
};
typedef ObjectPtrT<Runnable> RunnablePtr;
/** A thread is a thread of execution in a program.
*/
class LOG4CXX_EXPORT Thread : public virtual ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Thread)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(Thread)
END_LOG4CXX_CAST_MAP()
/** Allocates a new Thread object.*/
Thread();
/** Allocates a new Thread object.*/
Thread(RunnablePtr runnable);
virtual ~Thread();
/** Returns the current thread identifier
*/
static unsigned long getCurrentThreadId();
/** Causes the currently executing thread to sleep (
temporarily
cease execution) for the specified number of millise
conds.
*/
static void sleep(long millis);
/** Causes this thread to begin execution;
calls the run method of this thread.
*/
void start();
/** If this thread was constructed using a separate typedef void* (LOG4CXX_THREAD_FUNC *Runnable)(apr_thread_t* thr
Runnable ead, void* data);
run object, then that Runnable object's run method i /**
s called; * This class implements an approximation of java.util.Thr
otherwise, this method does nothing and returns. ead.
*/ */
virtual void run(); class LOG4CXX_EXPORT Thread
{
public:
/**
* Create new instance.
*/
Thread();
/**
* Destructor.
*/
~Thread();
/** Waits for this thread to die. /**
*/ * Runs the specified method on a newly created th
void join(); read.
*/
void run(Runnable start, void* data);
void join();
enum inline bool isActive() { return thread != 0; }
{
MIN_PRIORITY = 1,
NORM_PRIORITY = 2,
MAX_PRIORITY = 3
};
/** Changes the priority of this thread. /**
*/ * Causes the currently executing thread to sleep f
void setPriority(int newPriority); or the
* specified number of milliseconds.
* @param millis milliseconds.
* @throws Interrupted Exception if the thread is i
nterrupted.
*/
static void sleep(int millis);
/**
* Sets interrupted status for current thread to t
rue.
*/
static void currentThreadInterrupt();
/**
* Sets interrupted status to true.
*/
void interrupt();
/**
* Tests if the current thread has been interrupte
d and
* sets the interrupted status to false.
*/
static bool interrupted();
/** bool isAlive();
Atomic increment bool isCurrentThread() const;
*/ void ending();
static long InterlockedIncrement(volatile long * val
);
/** private:
Atomic decrement Pool p;
*/ apr_thread_t* thread;
static long InterlockedDecrement(volatile long * val volatile unsigned int alive;
); volatile unsigned int interruptedStatus;
Thread(const Thread&);
Thread& operator=(const Thread&);
protected: /**
/** Thread descriptor */ * This class is used to encapsulate the paramete
#ifdef HAVE_PTHREAD rs to
pthread_t thread; * Thread::run when they are passed to Thread::la
#elif defined(HAVE_MS_THREAD) uncher.
void * thread; *
#endif */
RunnablePtr runnable; class LaunchPackage {
MDC::Map parentMDCMap; public:
}; /**
* Placement new to create LaunchPackage in sp
ecified pool.
* LaunchPackage needs to be dynamically alloc
ated since
* since a stack allocated instance may go out
of scope
* before thread is launched.
*/
static void* operator new(size_t, Pool& p);
/**
* operator delete would be called if exception
during construction.
*/
static void operator delete(void*, Pool& p);
/**
* Create new instance.
*/
LaunchPackage(Thread* thread, Runnable runnable
, void* data);
/**
* Gets thread parameter.
* @return thread.
*/
Thread* getThread() const;
/**
* Gets runnable parameter.
* @return runnable.
*/
Runnable getRunnable() const;
/**
* gets data parameter.
* @return thread.
*/
void* getData() const;
private:
LaunchPackage(const LaunchPackage&);
LaunchPackage& operator=(const LaunchPackage&);
Thread* thread;
Runnable runnable;
void* data;
};
typedef ObjectPtrT<Thread> ThreadPtr; /**
* This object atomically sets the specified memor
y location
* to non-zero on construction and to zero on dest
ruction.
* Used to maintain Thread.alive.
*/
class LaunchStatus {
public:
/*
* Construct new instance.
* @param p address of memory to set to non-ze
ro on construction, zero on destruction.
*/
LaunchStatus(volatile unsigned int* p);
/**
* Destructor.
*/
~LaunchStatus();
private:
LaunchStatus(const LaunchStatus&);
LaunchStatus& operator=(const LaunchStatus&);
volatile unsigned int* alive;
};
} // namespace helpers /**
}; //namespace log4cxx * This method runs on the created thread and sets
up thread-local storage
* used to keep the reference to the corresponding
Thread object and
* is responsible for maintaining Thread.alive.
*/
static void* LOG4CXX_THREAD_FUNC launcher(apr_threa
d_t* thread, void* data);
/**
* Get a key to the thread local storage used to
hold the reference to
* the corresponding Thread object.
*/
static ThreadLocal& getThreadLocal();
};
} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_THREAD_H #endif //_LOG4CXX_HELPERS_THREAD_H
 End of changes. 16 change blocks. 
127 lines changed or deleted 172 lines changed or added


 threadspecificdata.h   threadspecificdata.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_THREAD_SPECIFIC_DATA_H #ifndef _LOG4CXX_HELPERS_THREAD_SPECIFIC_DATA_H
#define _LOG4CXX_HELPERS_THREAD_SPECIFIC_DATA_H #define _LOG4CXX_HELPERS_THREAD_SPECIFIC_DATA_H
#include <log4cxx/config.h> #include <log4cxx/ndc.h>
#include <log4cxx/mdc.h>
#ifdef HAVE_PTHREAD
#include <pthread.h>
#endif
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class LOG4CXX_EXPORT ThreadSpecificData /**
{ * This class contains all the thread-specific
public: * data in use by log4cxx.
ThreadSpecificData(); */
~ThreadSpecificData(); class LOG4CXX_EXPORT ThreadSpecificData
void * GetData() const; {
void SetData(void * data); public:
ThreadSpecificData();
~ThreadSpecificData();
protected: /**
#ifdef HAVE_PTHREAD * Gets current thread specific data.
pthread_key_t key; * @return thread specific data, may be null.
#elif defined(HAVE_MS_THREAD) */
void * key; static ThreadSpecificData* getCurrentData();
#endif /**
}; * Release this ThreadSpecficData if empty.
} // namespace helpers */
}; // namespace log4cxx void recycle();
static void put(const LogString& key, const LogStri
ng& val);
static void push(const LogString& val);
static void inherit(const log4cxx::NDC::Stack& stac
k);
log4cxx::NDC::Stack& getStack();
log4cxx::MDC::Map& getMap();
private:
static ThreadSpecificData& getDataNoThreads();
static ThreadSpecificData* createCurrentData();
log4cxx::NDC::Stack ndcStack;
log4cxx::MDC::Map mdcMap;
};
} // namespace helpers
} // namespace log4cxx
#endif #endif
 End of changes. 4 change blocks. 
28 lines changed or deleted 47 lines changed or added


 timezone.h   timezone.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_TIMEZONE_H #ifndef _LOG4CXX_HELPERS_TIMEZONE_H
#define _LOG4CXX_HELPERS_TIMEZONE_H #define _LOG4CXX_HELPERS_TIMEZONE_H
#include <log4cxx/config.h> #include <log4cxx/logstring.h>
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/helpers/objectimpl.h> #include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/objectptr.h> #include <log4cxx/helpers/objectptr.h>
#include <map>
struct apr_time_exp_t;
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
class TimeZone; class TimeZone;
typedef helpers::ObjectPtrT<TimeZone> TimeZonePtr; LOG4CXX_PTR_DEF(TimeZone);
class LOG4CXX_EXPORT TimeZone : public helpers::ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(TimeZone)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(TimeZone)
END_LOG4CXX_CAST_MAP()
TimeZone(const String& ID);
~TimeZone();
/**
Returns the offset of this time zone from UTC at the
specified
date. If Daylight Saving Time is in effect at the sp
ecified date,
the offset value is adjusted with the amount of dayl
ight saving.
@param date the date represented in milliseconds sin
ce January 1,
1970 00:00:00 GMT
@return the amount of time in milliseconds to add to
UTC to get
local time.
*/
int getOffset(int64_t date) const;
static TimeZonePtr getDefault();
static TimeZonePtr getTimeZone(const String& ID);
/**
Queries if the given date is in daylight savings tim
e in this time
zone.
@param date the given Date.
@return true if the given date is in daylight saving
s time, false,
otherwise.
*/
bool inDaylightTime(int64_t date) const;
/**
Returns the amount of time to be added to local stan
dard time to
get local wall clock time.
@return the amount of saving time in milliseconds
*/
inline int getDSTSavings() const
{ return DSTSavings; }
/**
Returns the amount of time in milliseconds to add to
UTC to get
standard time in this time zone.
Because this value is not affected by daylight savin class LOG4CXX_EXPORT TimeZone : public helpers::ObjectImpl
g time, it is {
called raw offset. public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(TimeZone)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(TimeZone)
END_LOG4CXX_CAST_MAP()
@return the amount of raw offset time in millisecond static const TimeZonePtr& getDefault();
s to add to static const TimeZonePtr& getGMT();
UTC. static const TimeZonePtr getTimeZone(const LogString& ID);
*/
inline int getRawOffset() const
{ return rawOffset; }
/** const LogString getID() const {
Queries if this time zone uses daylight savings time return id;
. }
@return true if this time zone uses daylight savings
time, false,
otherwise.
*/
inline bool useDaylightTime() const
{ return DSTSavings != 0; }
protected: /**
String ID; * Expand an APR time into the human readable
int rawOffset; * components for this timezone.
int DSTSavings; */
virtual log4cxx_status_t explode(apr_time_exp_t* result,
log4cxx_time_t input) const = 0;
class Rule protected:
{ TimeZone(const LogString& ID);
public: virtual ~TimeZone();
Rule(int year);
int year;
int64_t startDate;
int64_t endDate;
};
typedef std::map<long, Rule *> RuleMap; const LogString id;
mutable RuleMap rules; };
static TimeZonePtr defaultTimeZone; }
};
}
} }
#endif //_LOG4CXX_HELPERS_TIMEZONE_H #endif //_LOG4CXX_HELPERS_TIMEZONE_H
 End of changes. 11 change blocks. 
104 lines changed or deleted 38 lines changed or added


 transform.h   transform.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_TRANSFORM_H #ifndef _LOG4CXX_HELPERS_TRANSFORM_H
#define _LOG4CXX_HELPERS_TRANSFORM_H #define _LOG4CXX_HELPERS_TRANSFORM_H
#include <log4cxx/helpers/tchar.h> #include <log4cxx/logstring.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace helpers
{ {
/** /**
Utility class for transforming strings. Utility class for transforming strings.
*/ */
class LOG4CXX_EXPORT Transform class LOG4CXX_EXPORT Transform
{ {
private: public:
static String CDATA_START; /**
static String CDATA_END; * This method takes a string which may contain HTML
static String CDATA_PSEUDO_END; tags (ie,
static String CDATA_EMBEDED_END; * &lt;b&gt;, &lt;table&gt;, etc) and replaces any '
static String::size_type CDATA_END_LEN; <' and '>'
* characters with respective predefined entity refe
public: rences.
/** *
* This method takes a string which may contain HTML * @param buf output stream where to write the modif
tags (ie, ied string.
* &lt;b&gt;, &lt;table&gt;, etc) and replaces any '< * @param input The text to be converted.
' and '>' * @return The input string with the characters '<'
* characters with respective predefined entity refer and '>' replaced with
ences. * &amp;lt; and &amp;gt; respectively.
* * */
* @param buf output stream where to write the modifi static void appendEscapingTags(
ed string. LogString& buf, const LogString& input);
* @param input The text to be converted.
* @return The input string with the characters '<' a
nd '>' replaced with
* &amp;lt; and &amp;gt; respectively.
* */
static void appendEscapingTags(
ostream& buf, const String& input);
/** /**
* Ensures that embeded CDEnd strings (]]>) are handl * Ensures that embeded CDEnd strings (]]>) are hand
ed properly led properly
* within message, NDC and throwable tag text. * within message, NDC and throwable tag text.
* *
* @param buf output stream holding the XML data to t * @param buf output stream holding the XML data to
his point. The this point. The
* initial CDStart (<![CDATA[) and final CDEnd (]]>) * initial CDStart (<![CDATA[) and final CDEnd (]]>)
of the CDATA of the CDATA
* section are the responsibility of the calling meth * section are the responsibility of the calling met
od. hod.
* @param input The String that is inserted into an e * @param input The String that is inserted into an
xisting CDATA existing CDATA
* Section within buf. * Section within buf.
*/ */
static void appendEscapingCDATA( static void appendEscapingCDATA(
ostream& buf, const String& input); LogString& buf, const LogString& input);
}; // class Transform }; // class Transform
} // namespace helpers } // namespace helpers
}; //namespace log4cxx } //namespace log4cxx
#endif // _LOG4CXX_HELPERS_TRANSFORM_H #endif // _LOG4CXX_HELPERS_TRANSFORM_H
 End of changes. 4 change blocks. 
58 lines changed or deleted 52 lines changed or added


 triggeringeventevaluator.h   triggeringeventevaluator.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_TRIGGERING_EVENT_EVALUATOR_H #ifndef _LOG4CXX_SPI_TRIGGERING_EVENT_EVALUATOR_H
#define _LOG4CXX_SPI_TRIGGERING_EVENT_EVALUATOR_H #define _LOG4CXX_SPI_TRIGGERING_EVENT_EVALUATOR_H
#include <log4cxx/helpers/object.h> #include <log4cxx/spi/loggingevent.h>
#include <log4cxx/helpers/objectptr.h>
namespace log4cxx namespace log4cxx
{ {
namespace spi namespace spi
{ {
class TriggeringEventEvaluator; /**
typedef helpers::ObjectPtrT<TriggeringEventEvaluator> Implementions of this interface allow certain appenders to
TriggeringEventEvaluatorPtr; decide
when to perform an appender specific action.
class LoggingEvent;
typedef helpers::ObjectPtrT<Logger> LoggerPtr;
/**
Implementions of this interface allow certain appenders to d
ecide
when to perform an appender specific action.
<p>For example the {@link net::SMTPAppender SMTPAppender} se <p>For example the {@link net::SMTPAppender SMTPAppender} s
nds ends
an email when the #isTriggeringEvent method returns an email when the #isTriggeringEvent method returns
<code>true</code> and adds the event to an internal buffer w <code>true</code> and adds the event to an internal buffer
hen the when the
returned result is <code>false</code>. returned result is <code>false</code>.
*/ */
class LOG4CXX_EXPORT TriggeringEventEvaluator : public virtu class LOG4CXX_EXPORT TriggeringEventEvaluator : public virt
al helpers::Object ual helpers::Object
{ {
public: public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(TriggeringEventEvalu DECLARE_ABSTRACT_LOG4CXX_OBJECT(TriggeringEventEval
ator) uator)
/** /**
Is this the triggering event? Is this the triggering event?
*/ */
virtual bool isTriggeringEvent(const spi::LoggingEve virtual bool isTriggeringEvent(const spi::LoggingEv
ntPtr& event) = 0; entPtr& event) = 0;
}; };
} LOG4CXX_PTR_DEF(TriggeringEventEvaluator);
}
} }
#endif // _LOG4CXX_SPI_TRIGGERING_EVENT_EVALUATOR_H #endif // _LOG4CXX_SPI_TRIGGERING_EVENT_EVALUATOR_H
 End of changes. 5 change blocks. 
40 lines changed or deleted 34 lines changed or added


 ttcclayout.h   ttcclayout.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_TTCC_LAYOUT_H #ifndef _LOG4CXX_TTCC_LAYOUT_H
#define _LOG4CXX_TTCC_LAYOUT_H #define _LOG4CXX_TTCC_LAYOUT_H
#if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/helpers/datelayout.h> #include <log4cxx/helpers/datelayout.h>
namespace log4cxx namespace log4cxx
{ {
class TTCCLayout;
typedef helpers::ObjectPtrT<TTCCLayout> TTCCLayoutPtr;
/** /**
TTCC layout format consists of time, thread, category and nested TTCC layout format consists of time, thread, logger name and nested
diagnostic context information, hence the name. diagnostic context information, hence the name.
<p>Each of the four fields can be individually enabled or <p>Each of the four fields can be individually enabled or
disabled. The time format depends on the <code>DateFormat</code> disabled. The time format depends on the <code>DateFormat</code>
used. used.
<p>Here is an example TTCCLayout output with the <p>Here is an example TTCCLayout output with the
{@link helpers::RelativeTimeDateFormat RelativeTimeDateFormat}. {@link helpers::RelativeTimeDateFormat RelativeTimeDateFormat}.
<pre> <pre>
skipping to change at line 55 skipping to change at line 59
317 [main] INFO examples.SortAlgo.DUMP - Element [0] = 0 317 [main] INFO examples.SortAlgo.DUMP - Element [0] = 0
331 [main] INFO examples.SortAlgo.DUMP - Element [1] = 1 331 [main] INFO examples.SortAlgo.DUMP - Element [1] = 1
343 [main] INFO examples.Sort - The next log statement should be an er ror message. 343 [main] INFO examples.Sort - The next log statement should be an er ror message.
346 [main] ERROR examples.SortAlgo.DUMP - Tried to dump an uninitialize d array. 346 [main] ERROR examples.SortAlgo.DUMP - Tried to dump an uninitialize d array.
467 [main] INFO examples.Sort - Exiting main method. 467 [main] INFO examples.Sort - Exiting main method.
</pre> </pre>
<p>The first field is the number of milliseconds elapsed since the <p>The first field is the number of milliseconds elapsed since the
start of the program. The second field is the thread outputting the start of the program. The second field is the thread outputting the
log statement. The third field is the level, the fourth field is log statement. The third field is the level, the fourth field is
the category to which the statement belongs. the logger to which the statement belongs.
<p>The fifth field (just before the '-') is the nested diagnostic <p>The fifth field (just before the '-') is the nested diagnostic
context. Note the nested diagnostic context may be empty as in the context. Note the nested diagnostic context may be empty as in the
first two statements. The text after the '-' is the message of the first two statements. The text after the '-' is the message of the
statement. statement.
<p><b>WARNING</b> Do not use the same TTCCLayout instance from <p><b>WARNING</b> Do not use the same TTCCLayout instance from
within different appenders. The TTCCLayout is not thread safe when within different appenders. The TTCCLayout is not thread safe when
used in his way. However, it is perfectly safe to use a TTCCLayout used in his way. However, it is perfectly safe to use a TTCCLayout
instance from just one appender. instance from just one appender.
<p>PatternLayout offers a much more flexible alternative. <p>PatternLayout offers a much more flexible alternative.
*/ */
class LOG4CXX_EXPORT TTCCLayout : public helpers::DateLayout class LOG4CXX_EXPORT TTCCLayout : public helpers::DateLayout
{ {
private: private:
// Internal representation of options // Internal representation of options
bool threadPrinting; bool threadPrinting;
bool categoryPrefixing; bool categoryPrefixing;
bool contextPrinting; bool contextPrinting;
bool filePrinting; bool filePrinting;
public: public:
DECLARE_LOG4CXX_OBJECT(TTCCLayout) DECLARE_LOG4CXX_OBJECT(TTCCLayout)
BEGIN_LOG4CXX_CAST_MAP() BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(TTCCLayout) LOG4CXX_CAST_ENTRY(TTCCLayout)
LOG4CXX_CAST_ENTRY_CHAIN(Layout) LOG4CXX_CAST_ENTRY_CHAIN(Layout)
END_LOG4CXX_CAST_MAP() END_LOG4CXX_CAST_MAP()
/** /**
Instantiate a TTCCLayout object with {@link Instantiate a TTCCLayout object with {@link
helpers::RelativeTimeDateFormat RelativeTimeDateFormat} as the date helpers::RelativeTimeDateFormat RelativeTimeDateFormat} as the date
formatter in the local time zone. formatter in the local time zone.
*/ */
TTCCLayout(); TTCCLayout();
/** /**
Instantiate a TTCCLayout object using the local time zone. The Instantiate a TTCCLayout object using the local time zone. The
DateFormat used will depend on the <code>dateFormatType</code>. DateFormat used will depend on the <code>dateFormatType</code>.
<p>This constructor just calls the {@link <p>This constructor just calls the {@link
helpers::DateLayout#setDateFormat DateLayout::setDateFormat} method. helpers::DateLayout#setDateFormat DateLayout::setDateFormat} method
*/ .
TTCCLayout(const String& dateFormatType); */
TTCCLayout(const LogString& dateFormatType);
/** /**
The <b>ThreadPrinting</b> option specifies whether the name of the The <b>ThreadPrinting</b> option specifies whether the name of the
current thread is part of log output or not. This is true by default current thread is part of log output or not. This is true by defaul
. t.
*/ */
inline void setThreadPrinting(bool threadPrinting) inline void setThreadPrinting(bool threadPrinting1)
{ this->threadPrinting = threadPrinting; } { this->threadPrinting = threadPrinting1; }
/** /**
Returns value of the <b>ThreadPrinting</b> option. Returns value of the <b>ThreadPrinting</b> option.
*/ */
inline bool getThreadPrinting() const inline bool getThreadPrinting() const
{ return threadPrinting; } { return threadPrinting; }
/** /**
The <b>CategoryPrefixing</b> option specifies whether Logger The <b>CategoryPrefixing</b> option specifies whether Logger
name is part of log output or not. This is true by default. name is part of log output or not. This is true by default.
*/ */
inline void setCategoryPrefixing(bool categoryPrefixing) inline void setCategoryPrefixing(bool categoryPrefixing1)
{ this->categoryPrefixing = categoryPrefixing; } { this->categoryPrefixing = categoryPrefixing1; }
/** /**
Returns value of the <b>CategoryPrefixing</b> option. Returns value of the <b>CategoryPrefixing</b> option.
*/ */
inline bool getCategoryPrefixing() const inline bool getCategoryPrefixing() const
{ return categoryPrefixing; } { return categoryPrefixing; }
/** /**
The <b>ContextPrinting</b> option specifies log output will include The <b>ContextPrinting</b> option specifies log output will include
the nested context information belonging to the current thread. the nested context information belonging to the current thread.
This is true by default. This is true by default.
*/ */
inline void setContextPrinting(bool contextPrinting) inline void setContextPrinting(bool contextPrinting1)
{ this->contextPrinting = contextPrinting; } { this->contextPrinting = contextPrinting1; }
/** /**
Returns value of the <b>ContextPrinting</b> option. Returns value of the <b>ContextPrinting</b> option.
*/ */
inline bool getContextPrinting() const inline bool getContextPrinting() const
{ return contextPrinting; } { return contextPrinting; }
/** /**
The <b>FilePrinting</b> option specifies log output will include The <b>FilePrinting</b> option specifies log output will include
the file and the line where the log statement was written. the file and the line where the log statement was written.
*/ */
inline void setFilePrinting(bool filePrinting) inline void setFilePrinting(bool filePrinting1)
{ this->filePrinting = filePrinting; } { this->filePrinting = filePrinting1; }
/** /**
Returns value of the <b>ContextPrinting</b> option. Returns value of the <b>ContextPrinting</b> option.
*/ */
inline bool getFilePrinting() const inline bool getFilePrinting() const
{ return filePrinting; } { return filePrinting; }
/** /**
In addition to the level of the statement and message, this function In addition to the level of the statement and message, this functio
writes to the ouput stream time, thread, category and NDC n
information. writes to the ouput stream time, thread, logger and NDC
information.
<p>Time, thread, category and diagnostic context are printed <p>Time, thread, logger and diagnostic context are printed
depending on options. depending on options.
@param output @param output destination to receive formatted output.
@param event @param event event to format.
*/ @param pool pool used to allocate memory needed during formatting.
virtual void format(ostream& output, const spi::LoggingEventPtr& eve */
nt) const; virtual void format(LogString& output,
const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool
) const;
/** /**
The TTCCLayout does not handle the throwable contained within The TTCCLayout does not handle the throwable contained within
{@link spi::LoggingEvent LoggingEvents}. Thus, it returns {@link spi::LoggingEvent LoggingEvents}. Thus, it returns
<code>true</code>. <code>true</code>.
*/ */
virtual bool ignoresThrowable() const { return true; } virtual bool ignoresThrowable() const { return true; }
}; };
LOG4CXX_PTR_DEF(TTCCLayout);
} }
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#endif #endif
 End of changes. 22 change blocks. 
100 lines changed or deleted 113 lines changed or added


 writerappender.h   writerappender.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_WRITER_APPENDER_H #ifndef _LOG4CXX_WRITER_APPENDER_H
#define _LOG4CXX_WRITER_APPENDER_H #define _LOG4CXX_WRITER_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/outputstreamwriter.h>
namespace log4cxx namespace log4cxx
{ {
class WriterAppender;
typedef helpers::ObjectPtrT<WriterAppender> WriterAppenderPtr;
/** namespace helpers {
WriterAppender appends log events to a standard output stream class Transcoder;
(ostream or wostream) }
*/
class LOG4CXX_EXPORT WriterAppender : public AppenderSkeleton
{
protected:
/**
Immediate flush means that the underlying writer or output s
tream
will be flushed at the end of each append operation. Immedia
te
flush is slower but ensures that each append request is actu
ally
written. If <code>immediateFlush</code> is set to
<code>false</code>, then there is a good chance that the las /**
t few WriterAppender appends log events to a standard output stream
logs events are not actually written to persistent media if */
and class LOG4CXX_EXPORT WriterAppender : public AppenderSkeleton
when the application crashes. {
private:
/**
Immediate flush means that the underlying writer or output
stream
will be flushed at the end of each append operation. Immedi
ate
flush is slower but ensures that each append request is act
ually
written. If <code>immediateFlush</code> is set to
<code>false</code>, then there is a good chance that the la
st few
logs events are not actually written to persistent media if
and
when the application crashes.
<p>The <code>immediateFlush</code> variable is set to <p>The <code>immediateFlush</code> variable is set to
<code>true</code> by default. <code>true</code> by default.
*/ */
bool immediateFlush; bool immediateFlush;
/** /**
The encoding to use when opening an input stream. The encoding to use when opening an input stream.
<p>The <code>encoding</code> variable is set to <code>""</co <p>The <code>encoding</code> variable is set to <code>""</c
de> by ode> by
default which results in the utilization of the system's def default which results in the utilization of the system's de
ault fault
encoding. */ encoding. */
String encoding; LogString encoding;
/** This is the output stream where we will write to.*/ /**
ostream * os; * This is the {@link Writer Writer} where we will write to
.
*/
log4cxx::helpers::WriterPtr writer;
public: public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(WriterAppender) DECLARE_ABSTRACT_LOG4CXX_OBJECT(WriterAppender)
BEGIN_LOG4CXX_CAST_MAP() BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(WriterAppender) LOG4CXX_CAST_ENTRY(WriterAppender)
LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton) LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
END_LOG4CXX_CAST_MAP() END_LOG4CXX_CAST_MAP()
/** /**
This default constructor does nothing.*/ This default constructor does nothing.*/
WriterAppender(); WriterAppender();
protected:
WriterAppender(const LayoutPtr& layout,
log4cxx::helpers::WriterPtr& writer);
WriterAppender(const LayoutPtr& layout);
/** public:
Instantiate a WriterAppender and set the output destination ~WriterAppender();
to
<code>os</code>.*/
WriterAppender(const LayoutPtr& layout, ostream * os);
~WriterAppender(); /**
Derived appenders should override this method if option str
ucture
requires it.
*/
virtual void activateOptions(log4cxx::helpers::Pool& pool);
/** /**
If the <b>ImmediateFlush</b> option is set to If the <b>ImmediateFlush</b> option is set to
<code>true</code>, the appender will flush at the end of eac <code>true</code>, the appender will flush at the end of ea
h ch
write. This is the default behavior. If the option is set to write. This is the default behavior. If the option is set t
<code>false</code>, then the underlying stream can defer wri o
ting <code>false</code>, then the underlying stream can defer wr
to physical medium to a later time. iting
to physical medium to a later time.
<p>Avoiding the flush operation at the end of each append re <p>Avoiding the flush operation at the end of each append r
sults in esults in
a performance gain of 10 to 20 percent. However, there is sa a performance gain of 10 to 20 percent. However, there is s
fety afety
tradeoff involved in skipping flushing. Indeed, when flushin tradeoff involved in skipping flushing. Indeed, when flushi
g is ng is
skipped, then it is likely that the last few log events will skipped, then it is likely that the last few log events wil
not l not
be recorded on disk when the application exits. This is a hi be recorded on disk when the application exits. This is a h
gh igh
price to pay even for a 20% performance gain. price to pay even for a 20% performance gain.
*/ */
void setImmediateFlush(bool value) { immediateFlush = value; void setImmediateFlush(bool value);
} /**
Returns value of the <b>ImmediateFlush</b> option.
*/
bool getImmediateFlush() const { return immediateFlush; }
/** /**
Returns value of the <b>ImmediateFlush</b> option. This method is called by the AppenderSkeleton#doAppend
*/ method.
bool getImmediateFlush() const { return immediateFlush; }
/** <p>If the output stream exists and is writable then write a
This method is called by the AppenderSkeleton#doAppend log
method. statement to the output stream. Otherwise, write a single w
arning
message to <code>stderr</code>.
<p>If the output stream exists and is writable then write a <p>The format of the output will depend on this appender's
log layout.
statement to the output stream. Otherwise, write a single wa
rning
message to <code>stderr</code>.
<p>The format of the output will depend on this appender's */
layout. virtual void append(const spi::LoggingEventPtr& event, log4
cxx::helpers::Pool& p);
*/ protected:
virtual void append(const spi::LoggingEventPtr& event); /**
This method determines if there is a sense in attempting to
append.
protected: <p>It checks whether there is a set output target and also
/** if
This method determines if there is a sense in attempting to there is a set layout. If these checks fail, then the boole
append. an
value <code>false</code> is returned. */
virtual bool checkEntryConditions() const;
<p>It checks whether there is a set output target and also i public:
f /**
there is a set layout. If these checks fail, then the boolea Close this appender instance. The underlying stream or writ
n er is
value <code>false</code> is returned. */ also closed.
virtual bool checkEntryConditions() const;
public: <p>Closed appenders cannot be reused.
/** */
Close this appender instance. The underlying stream or write virtual void close();
r is
also closed.
<p>Closed appenders cannot be reused. protected:
*/ /**
virtual void close(); * Close the underlying {@link log4cxx::helpers::Writer}.
* */
void closeWriter();
protected: /**
/** Returns an OutputStreamWriter when passed an OutputStre
* Close the underlying output stream. am. The
* */ encoding used will depend on the value of the
virtual void closeWriter() = 0; <code>encoding</code> property. If the encoding value
is
specified incorrectly the writer will be opened using t
he default
system encoding (an error message will be printed to th
e loglog. */
virtual log4cxx::helpers::WriterPtr createWriter(
log4cxx::helpers::OutputStreamPtr& os);
public: public:
const String& getEncoding() const { return encoding; } LogString getEncoding() const;
void setEncoding(const String& value) { encoding = value; } void setEncoding(const LogString& value);
void setOption(const LogString& option,
const LogString& value);
protected: /**
/** <p>Sets the Writer where the log output will go. The
specified Writer must be opened by the user and be
writable.
Actual writing occurs here. <p>The <code>java.io.Writer</code> will be closed when th
e
appender instance is closed.
<p>Most subclasses of <code>WriterAppender</code> will need <p><b>WARNING:</b> Logging to an unopened Writer will fai
to l.
override this method. <p>
*/ @param writer An already opened Writer. */
virtual void subAppend(const spi::LoggingEventPtr& event); void setWriter(const log4cxx::helpers::WriterPtr& writer);
/** virtual bool requiresLayout() const;
The WriterAppender requires a layout. Hence, this method returns
<code>true</code>.
*/
public:
virtual bool requiresLayout() const { return true; }
/** protected:
Clear internal references to the writer and other variables. /**
Actual writing occurs here.
*/
virtual void subAppend(const spi::LoggingEventPtr& event, lo
g4cxx::helpers::Pool& p);
Subclasses can override this method for an alternate closing /**
behavior. */ Write a footer as produced by the embedded layout's
Layout#appendFooter method. */
virtual void writeFooter(log4cxx::helpers::Pool& p);
protected: /**
virtual void reset(); Write a header as produced by the embedded layout's
Layout#appendHeader method. */
virtual void writeHeader(log4cxx::helpers::Pool& p);
/** private:
Write a footer as produced by the embedded layout's //
Layout#appendFooter method. */ // prevent copy and assignment
protected: WriterAppender(const WriterAppender&);
virtual void writeFooter(); WriterAppender& operator=(const WriterAppender&);
};
LOG4CXX_PTR_DEF(WriterAppender);
/**
Write a header as produced by the embedded layout's
Layout#appendHeader method. */
protected:
virtual void writeHeader();
};
} //namespace log4cxx } //namespace log4cxx
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
#endif //_LOG4CXX_WRITER_APPENDER_H #endif //_LOG4CXX_WRITER_APPENDER_H
 End of changes. 37 change blocks. 
151 lines changed or deleted 190 lines changed or added


 xml.h   xml.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_XML_H #ifndef _LOG4CXX_HELPERS_XML_H
#define _LOG4CXX_HELPERS_XML_H #define _LOG4CXX_HELPERS_XML_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 <log4cxx/helpers/object.h> #include <log4cxx/helpers/object.h>
#include <log4cxx/helpers/exception.h> #include <log4cxx/helpers/exception.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers class File;
{ namespace helpers
class XMLDOMNode; {
typedef helpers::ObjectPtrT<XMLDOMNode> XMLDOMNodePtr; class XMLDOMNode;
typedef helpers::ObjectPtrT<XMLDOMNode> XMLDOMNodePtr;
class XMLDOMDocument; class XMLDOMDocument;
typedef helpers::ObjectPtrT<XMLDOMDocument> XMLDOMDocumentPt typedef helpers::ObjectPtrT<XMLDOMDocument> XMLDOMDocumentP
r; tr;
class XMLDOMElement; class XMLDOMNodeList;
typedef helpers::ObjectPtrT<XMLDOMElement> XMLDOMElementPtr; typedef helpers::ObjectPtrT<XMLDOMNodeList> XMLDOMNodeListP
tr;
class XMLDOMNodeList; class LOG4CXX_EXPORT DOMException : public RuntimeException
typedef helpers::ObjectPtrT<XMLDOMNodeList> XMLDOMNodeListPt {
r; public:
DOMException() : RuntimeException(LOG4CXX_STR("DOM exce
ption")) {}
};
class LOG4CXX_EXPORT DOMException : public RuntimeException /**
{ The XMLDOMNode interface is the primary datatype for the en
}; tire Document
Object Model.
*/
class LOG4CXX_EXPORT XMLDOMNode : virtual public Object
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(XMLDOMNode)
enum XMLDOMNodeType
{
NOT_IMPLEMENTED_NODE = 0,
ELEMENT_NODE = 1,
DOCUMENT_NODE = 9
};
/** virtual XMLDOMNodeListPtr getChildNodes() = 0;
The XMLDOMNode interface is the primary datatype for the ent virtual XMLDOMNodeType getNodeType() = 0;
ire Document virtual XMLDOMDocumentPtr getOwnerDocument() = 0;
Object Model. };
*/ LOG4CXX_PTR_DEF(XMLDOMNode);
class LOG4CXX_EXPORT XMLDOMNode : virtual public Object
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(XMLDOMNode)
enum XMLDOMNodeType
{
NOT_IMPLEMENTED_NODE = 0,
ELEMENT_NODE = 1,
DOCUMENT_NODE = 9
};
virtual XMLDOMNodeListPtr getChildNodes() = 0; /**
virtual XMLDOMNodeType getNodeType() = 0; The XMLDOMElement interface represents an element in an XML
virtual XMLDOMDocumentPtr getOwnerDocument() = 0; document
}; */
class LOG4CXX_EXPORT XMLDOMElement : virtual public XMLDOMN
ode
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(XMLDOMElement)
virtual LogString getTagName() = 0;
virtual LogString getAttribute(const LogString& nam
e) = 0;
};
LOG4CXX_PTR_DEF(XMLDOMElement);
/** /**
The XMLDOMDocument interface represents an entire XML docume The XMLDOMDocument interface represents an entire XML docum
nt. ent.
Conceptually, it is the root of the document tree, and provi Conceptually, it is the root of the document tree, and prov
des the ides the
primary access to the document's data. primary access to the document's data.
*/ */
class LOG4CXX_EXPORT XMLDOMDocument : virtual public XMLDOMN class LOG4CXX_EXPORT XMLDOMDocument : virtual public XMLDOM
ode Node
{ {
public: public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(XMLDOMDocument) DECLARE_ABSTRACT_LOG4CXX_OBJECT(XMLDOMDocument)
virtual void load(const String& fileName) = 0; virtual void load(const File& fileName) = 0;
virtual XMLDOMElementPtr getDocumentElement() = 0; virtual XMLDOMElementPtr getDocumentElement() = 0;
virtual XMLDOMElementPtr getElementById(const String virtual XMLDOMElementPtr getElementById(const LogSt
& tagName, ring& tagName,
const String& elementId) = 0; const LogString& elementId) = 0;
}; };
LOG4CXX_PTR_DEF(XMLDOMDocument);
/** /**
The XMLDOMElement interface represents an element in an XML The XMLDOMNodeList interface provides the abstraction of an
document ordered
*/ collection of nodes, without defining or constraining how t
class LOG4CXX_EXPORT XMLDOMElement : virtual public XMLDOMNo his
de collection is implemented.
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(XMLDOMElement)
virtual String getTagName() = 0;
virtual String getAttribute(const String& name) = 0;
};
/** XMLDOMNodeList objects in the DOM are live.
The XMLDOMNodeList interface provides the abstraction of an
ordered
collection of nodes, without defining or constraining how th
is
collection is implemented.
XMLDOMNodeList objects in the DOM are live. The items in the XMLDOMNodeList are accessible via an integ
ral index,
starting from 0.
*/
class LOG4CXX_EXPORT XMLDOMNodeList : virtual public Object
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(XMLDOMNodeList)
virtual int getLength() = 0;
virtual XMLDOMNodePtr item(int index) = 0;
};
LOG4CXX_PTR_DEF(XMLDOMNodeList);
} // namespace helpers
} // namespace log4cxx
The items in the XMLDOMNodeList are accessible via an integr #if defined(_MSC_VER)
al index, #pragma warning ( pop )
starting from 0. #endif
*/
class LOG4CXX_EXPORT XMLDOMNodeList : virtual public Object
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(XMLDOMNodeList)
virtual int getLength() = 0;
virtual XMLDOMNodePtr item(int index) = 0;
};
} // namespace helpers
}; // namespace log4cxx
#endif // _LOG4CXX_HELPERS_XML_H #endif // _LOG4CXX_HELPERS_XML_H
 End of changes. 15 change blocks. 
90 lines changed or deleted 106 lines changed or added


 xmllayout.h   xmllayout.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_LAYOUT_H #ifndef _LOG4CXX_XML_LAYOUT_H
#define _LOG4CXX_XML_LAYOUT_H #define _LOG4CXX_XML_LAYOUT_H
#include <log4cxx/layout.h> #include <log4cxx/layout.h>
namespace log4cxx namespace log4cxx
{ {
namespace xml namespace xml
{ {
class XMLLayout;
typedef helpers::ObjectPtrT<XMLLayout> XMLLayoutPtr;
/** /**
The output of the XMLLayout consists of a series of log4j:ev The output of the XMLLayout consists of a series of log4j:e
ent vent
elements as defined in the <a elements. It does not output a
href="doc-files/log4j.dtd">log4j.dtd</a>. It does not output complete well-formed XML file. The output is designed to b
a e
complete well-formed XML file. The output is designed to be included as an <em>external entity</em> in a separate file
included as an <em>external entity</em> in a separate file t to form
o form a correct XML file.
a correct XML file.
<p>For example, if <code>abc</code> is the name of the file <p>For example, if <code>abc</code> is the name of the file
where where
the XMLLayout ouput goes, then a well-formed XML file would the XMLLayout ouput goes, then a well-formed XML file would
be: be:
<code> <code>
<?xml version="1.0" ?> <?xml version="1.0" ?>
<!DOCTYPE log4j:eventSet SYSTEM "log4j.dtd" [<!ENTITY data S YSTEM "abc">]> <!DOCTYPE log4j:eventSet [<!ENTITY data SYSTEM "abc">]>
<log4j:eventSet version="1.2" xmlns:log4j="http://jakarta.ap ache.org/log4j/"> <log4j:eventSet version="1.2" xmlns:log4j="http://jakarta.a pache.org/log4j/">
@&data; @&data;
</log4j:eventSet> </log4j:eventSet>
</code> </code>
<p>This approach enforces the independence of the XMLLayout <p>This approach enforces the independence of the XMLLayout
and the and the
appender where it is embedded. appender where it is embedded.
*/ */
class LOG4CXX_EXPORT XMLLayout : public Layout class LOG4CXX_EXPORT XMLLayout : public Layout
{ {
private: private:
/**
A string constant used in naming the option for sett
ing the the
location information flag. Current value of this st
ring
constant is <b>LocationInfo</b>.
*/
static String LOCATION_INFO_OPTION;
// Print no location info by default // Print no location info by default
bool locationInfo; //= false bool locationInfo; //= false
bool properties; // = false
public: public:
DECLARE_LOG4CXX_OBJECT(XMLLayout) DECLARE_LOG4CXX_OBJECT(XMLLayout)
BEGIN_LOG4CXX_CAST_MAP() BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(XMLLayout) LOG4CXX_CAST_ENTRY(XMLLayout)
LOG4CXX_CAST_ENTRY_CHAIN(Layout) LOG4CXX_CAST_ENTRY_CHAIN(Layout)
END_LOG4CXX_CAST_MAP() END_LOG4CXX_CAST_MAP()
XMLLayout(); XMLLayout();
/** /**
The <b>LocationInfo</b> option takes a boolean value The <b>LocationInfo</b> option takes a boolean valu
. By e. By
default, it is set to false which means there will b default, it is set to false which means there will
e no location be no location
information output by this layout. If the the option information output by this layout. If the the optio
is set to n is set to
true, then the file name and line number of the stat true, then the file name and line number of the sta
ement tement
at the origin of the log statement will be output. at the origin of the log statement will be output.
<p>If you are embedding this layout within a SMTPApp <p>If you are embedding this layout within a SMTPAp
ender pender
then make sure to set the then make sure to set the
<b>LocationInfo</b> option of that appender as well. <b>LocationInfo</b> option of that appender as well
*/ .
inline void setLocationInfo(bool locationInfo) */
{ this->locationInfo = locationInfo; } inline void setLocationInfo(bool locationInfo1)
{ this->locationInfo = locationInfo1; }
/** /**
Returns the current value of the <b>LocationInfo</b> Returns the current value of the <b>LocationInfo</b
option. > option.
*/ */
inline bool getLocationInfo() const inline bool getLocationInfo() const
{ return locationInfo; } { return locationInfo; }
/** No options to activate. */ /**
void activateOptions() { } * Sets whether MDC key-value pairs should be outpu
t, default false.
* @param flag new value.
*
*/
inline void setProperties(bool flag) {
properties = flag;
}
/** /**
Set options * Gets whether MDC key-value pairs should be output
*/ .
virtual void setOption(const String& option, * @return true if MDC key-value pairs are output.
const String& value); *
*/
inline bool getProperties() {
return properties;
}
/** /** No options to activate. */
* Formats a {@link spi::LoggingEvent LoggingEvent} void activateOptions(log4cxx::helpers::Pool& /* p *
* in conformance with the log4cxx.dtd. /) { }
**/
virtual void format(ostream& output, const spi::Logg
ingEventPtr& event) const;
/** /**
The XMLLayout prints and does not ignore exceptions. Set options
Hence the */
return value <code>false</code>. virtual void setOption(const LogString& option,
*/ const LogString& value);
virtual bool ignoresThrowable() const
{ return false; }
}; // class XMLLayout /**
} // namespace xml * Formats a {@link spi::LoggingEvent LoggingEvent}
}; // namespace log4cxx * in conformance with the log4cxx.dtd.
**/
virtual void format(LogString& output,
const spi::LoggingEventPtr& event,
log4cxx::helpers::Pool& p) const;
/**
The XMLLayout prints and does not ignore exceptions
. Hence the
return value <code>false</code>.
*/
virtual bool ignoresThrowable() const
{ return false; }
}; // class XMLLayout
LOG4CXX_PTR_DEF(XMLLayout);
} // namespace xml
} // namespace log4cxx
#endif // _LOG4CXX_XML_LAYOUT_H #endif // _LOG4CXX_XML_LAYOUT_H
 End of changes. 21 change blocks. 
100 lines changed or deleted 115 lines changed or added


 xmlsocketappender.h   xmlsocketappender.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_NET_XML_SOCKET_APPENDER_H #ifndef _LOG4CXX_NET_XML_SOCKET_APPENDER_H
#define _LOG4CXX_NET_XML_SOCKET_APPENDER_H #define _LOG4CXX_NET_XML_SOCKET_APPENDER_H
#include <log4cxx/appenderskeleton.h> #include <log4cxx/net/socketappenderskeleton.h>
#include <log4cxx/helpers/socket.h> #include <log4cxx/helpers/writer.h>
#include <log4cxx/helpers/thread.h>
namespace log4cxx namespace log4cxx
{ {
namespace helpers namespace net
{ {
class SocketOutputStream;
typedef helpers::ObjectPtrT<SocketOutputStream> SocketOutput
StreamPtr;
}
namespace net
{
class XMLSocketAppender;
typedef helpers::ObjectPtrT<XMLSocketAppender> XMLSocketAppe
nderPtr;
/** /**
Sends {@link spi::LoggingEvent LoggingEvent} objects in XML format Sends {@link log4cxx::spi::LoggingEvent LoggingEvent} objects in XM
to a remote a log server, usually a XMLSocketNode. L format
to a remote a log server, usually a XMLSocketNode.
<p>The XMLSocketAppender has the following properties: <p>The XMLSocketAppender has the following properties:
- If sent to a XMLSocketNode, remote logging - If sent to a XMLSocketNode, remote logging
is non-intrusive as far as the log event is concerned. In ot her is non-intrusive as far as the log event is concerned. In o ther
words, the event will be logged with the same time stamp, {@link words, the event will be logged with the same time stamp, {@link
NDC NDC}, location info as if it were logged locally by NDC NDC}, location info as if it were logged locally by
the client. the client.
- XMLSocketAppenders use exclusively an XMLLayout. They ship an - XMLSocketAppenders use exclusively an XMLLayout. They ship an
XML stream representing a {@link spi::LoggingEvent LoggingEvent} ob ject XML stream representing a {@link spi::LoggingEvent LoggingEvent} ob ject
to the server side. to the server side.
- Remote logging uses the TCP protocol. Consequently, if - Remote logging uses the TCP protocol. Consequently, if
the server is reachable, then log events will eventually arrive the server is reachable, then log events will eventually arrive
at the server. at the server.
- If the remote server is down, the logging requests are - If the remote server is down, the logging requests are
simply dropped. However, if and when the server comes back up, simply dropped. However, if and when the server comes back up,
then event transmission is resumed transparently. This then event transmission is resumed transparently. This
transparent reconneciton is performed by a <em>connector</em> transparent reconneciton is performed by a <em>connector</em>
thread which periodically attempts to connect to the server. thread which periodically attempts to connect to the server.
skipping to change at line 87 skipping to change at line 79
the presence of a connector thread. A connector thread exists the presence of a connector thread. A connector thread exists
only if the connection to the server is down. To avoid this only if the connection to the server is down. To avoid this
destruction problem, you should #close the the destruction problem, you should #close the the
<code>XMLSocketAppender</code> explicitly. See also next item. <code>XMLSocketAppender</code> explicitly. See also next item.
@n @n Long lived applications which create/destroy many @n @n Long lived applications which create/destroy many
<code>XMLSocketAppender</code> instances should be aware of this <code>XMLSocketAppender</code> instances should be aware of this
destruction problem. Most other applications can safely destruction problem. Most other applications can safely
ignore it. ignore it.
- If the application hosting the <code>XMLSocketAppender</code> - If the application hosting the <code>XMLSocketAppender</code>
exits before the <code>XMLSocketAppender</code> is closed ei ther exits before the <code>XMLSocketAppender</code> is closed e ither
explicitly or subsequent to destruction, then there might explicitly or subsequent to destruction, then there might
be untransmitted data in the pipe which might be lost. be untransmitted data in the pipe which might be lost.
@n @n To avoid lost data, it is usually sufficient to @n @n To avoid lost data, it is usually sufficient to
#close the <code>XMLSocketAppender</code> either explicitly or by #close the <code>XMLSocketAppender</code> either explicitly or by
calling the LogManager#shutdown method calling the LogManager#shutdown method
before exiting the application. before exiting the application.
*/ */
class LOG4CXX_EXPORT XMLSocketAppender : public AppenderSkeleton class LOG4CXX_EXPORT XMLSocketAppender : public SocketAppenderSkele
{ ton
class Connector; {
friend class Connector; public:
public: /**
/** The default port number of remote logging server (4560).
The default port number of remote logging server (4560). */
*/ static int DEFAULT_PORT;
static int DEFAULT_PORT;
/**
The default reconnection delay (30000 milliseconds or 30 sec
onds).
*/
static int DEFAULT_RECONNECTION_DELAY;
protected:
/**
host name
*/
String remoteHost;
/**
IP address
*/
helpers::InetAddress address;
int port;
helpers::SocketOutputStreamPtr os;
int reconnectionDelay;
bool locationInfo;
char zeroBuffer[1024];
/**
An event XML stream cannot exceed 1024 bytes.
*/
static const int MAX_EVENT_LEN;
public:
DECLARE_LOG4CXX_OBJECT(XMLSocketAppender)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(XMLSocketAppender)
LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
END_LOG4CXX_CAST_MAP()
XMLSocketAppender();
~XMLSocketAppender();
/**
Connects to remote server at <code>address</code> and <code>
port</code>.
*/
XMLSocketAppender(unsigned long address, int port);
/**
Connects to remote server at <code>host</code> and <code>por
t</code>.
*/
XMLSocketAppender(const String& host, int port);
/**
Connect to the specified <b>RemoteHost</b> and <b>Port</b>.
*/
void activateOptions();
/**
Set options
*/
virtual void setOption(const String& option, const S
tring& value);
/**
* Close this appender.
*
* <p>This will mark the appender as closed and call then
* #cleanUp method.
* */
void close();
/**
* Drop the connection to the remote host and release the und
erlying
* connector thread if it has been created
* */
void cleanUp();
void connect();
virtual void append(const spi::LoggingEventPtr& event);
/** /**
* The XMLSocketAppender use an internal XMLLayout. Hence, th The default reconnection delay (30000 milliseconds or 30 se
is method conds).
* returns <code>false</code>. */
* */ static int DEFAULT_RECONNECTION_DELAY;
bool requiresLayout() const
{ return false; }
/** /**
* The <b>RemoteHost</b> option takes a string value which sh An event XML stream cannot exceed 1024 bytes.
ould be */
* the host name of the server where an static const int MAX_EVENT_LEN;
* XMLSocketNode is running.
* */
inline void setRemoteHost(const String& host)
{ address = helpers::InetAddress::getByName(host);
remoteHost = host; }
/** DECLARE_LOG4CXX_OBJECT(XMLSocketAppender)
Returns value of the <b>RemoteHost</b> option. BEGIN_LOG4CXX_CAST_MAP()
*/ LOG4CXX_CAST_ENTRY(XMLSocketAppender)
inline const String& getRemoteHost() const LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
{ return remoteHost; } END_LOG4CXX_CAST_MAP()
/** XMLSocketAppender();
The <b>Port</b> option takes a positive integer representing ~XMLSocketAppender();
the port where the server is waiting for connections.
*/
void setPort(int port)
{ this->port = port; }
/** /**
Returns value of the <b>Port</b> option. Connects to remote server at <code>address</code> and <code
*/ >port</code>.
int getPort() const */
{ return port; } XMLSocketAppender(helpers::InetAddressPtr address, int port
);
/** /**
The <b>LocationInfo</b> option takes a boolean value. If tru Connects to remote server at <code>host</code> and <code>po
e, rt</code>.
the information sent to the remote host will include locatio */
n XMLSocketAppender(const LogString& host, int port);
information. By default no location information is sent to t
he server.
*/
void setLocationInfo(bool locationInfo)
{ this->locationInfo = locationInfo; }
/** protected:
Returns value of the <b>LocationInfo</b> option. virtual void setSocket(log4cxx::helpers::SocketPtr& socket,
*/ log4cxx::helpers::Pool& p);
bool getLocationInfo() const
{ return locationInfo; }
/** virtual void cleanUp(log4cxx::helpers::Pool& p);
The <b>ReconnectionDelay</b> option takes a positive integer
representing the number of milliseconds to wait between each
failed connection attempt to the server. The default value o
f
this option is 30000 which corresponds to 30 seconds.
<p>Setting this option to zero turns off reconnection virtual int getDefaultDelay() const;
capability.
*/
void setReconnectionDelay(int reconnectionDelay)
{ this->reconnectionDelay = reconnectionDelay; }
/** virtual int getDefaultPort() const;
Returns value of the <b>ReconnectionDelay</b> option.
*/
int getReconnectionDelay() const
{ return reconnectionDelay; }
void fireConnector(); void append(const spi::LoggingEventPtr& event, log4cxx::hel pers::Pool& pool);
private: private:
/** log4cxx::helpers::WriterPtr writer;
The Connector will reconnect when the server becomes // prevent copy and assignment statements
available XMLSocketAppender(const XMLSocketAppender&);
again. It does this by attempting to open a new con XMLSocketAppender& operator=(const XMLSocketAppender&);
nection every }; // class XMLSocketAppender
<code>reconnectionDelay</code> milliseconds.
<p>It stops trying whenever a connection is establis
hed. It will
restart to try reconnect to the server when previpou
sly open
connection is droppped.
*/
class LOG4CXX_EXPORT Connector : public helpers::Thr
ead
{
public:
bool interrupted;
XMLSocketAppender * socketAppender;
Connector(XMLSocketAppenderPtr socketAppende LOG4CXX_PTR_DEF(XMLSocketAppender);
r);
virtual void run();
}; // class Connector
Connector * connector;
}; // class XMLSocketAppender
} // namespace net } // namespace net
}; // namespace log4cxx } // namespace log4cxx
#endif // _LOG4CXX_NET_XML_SOCKET_APPENDER_H #endif // _LOG4CXX_NET_XML_SOCKET_APPENDER_H
 End of changes. 23 change blocks. 
204 lines changed or deleted 65 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/