From d98f208124d6a32ff656fb1c66baf0a368dab0d8 Mon Sep 17 00:00:00 2001
From: cnangel <cnangel@gmail.com>
Date: Mon, 23 Jul 2012 22:23:42 +0800
Subject: [PATCH] update for cnangel
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

---
 .gitignore                                 |   59 +++++++++
 INSTALL                                    |    1 +
 Makefile.am                                |    8 ++
 autogen.sh                                 |   25 ++++
 configure.in                               |    5 +-
 debian/Makefile.am                         |    9 ++
 debian/changelog                           |   12 ++
 debian/control                             |   34 +++++
 debian/copyright                           |   19 +++
 debian/liblog4cpp-dev.dirs                 |    2 +
 debian/liblog4cpp-dev.files                |    4 +
 debian/liblog4cpp-doc.dirs                 |    1 +
 debian/liblog4cpp-doc.files                |    1 +
 debian/liblog4cpp0.dirs                    |    1 +
 debian/liblog4cpp0.files                   |    1 +
 debian/liblog4cpp0.postinst                |    7 +
 debian/rules                               |   85 +++++++++++++
 doc/Doxyfile.in                            |    5 +-
 doc/Makefile.am                            |    2 +-
 include/log4cpp/Appender.hh                |   11 ++
 include/log4cpp/Makefile.am                |    4 +-
 include/log4cpp/TimeRollingFileAppender.hh |  116 +++++++++++++++++
 include/log4cpp/config-openvms.h           |    2 +-
 log4cpp.spec.in                            |   93 +++++++++++---
 m4/BB_CHECK_PTHREADS.m4                    |    7 +-
 m4/ac_config_libconfig_in.m4               |    5 +-
 src/Appender.cpp                           |   10 ++
 src/AppendersFactory.cpp                   |    2 +
 src/Makefile.am                            |    4 +-
 src/PatternLayout.cpp                      |    1 +
 src/PropertyConfiguratorImpl.cpp           |   35 +++++
 src/RemoteSyslogAppender.cpp               |    2 +-
 src/TimeRollingFileAppender.cpp            |  190 ++++++++++++++++++++++++++++
 33 个文件被修改，插入 727 行(+)，删除 36 行(-)
 create mode 100644 .gitignore
 create mode 100755 autogen.sh
 create mode 100644 debian/Makefile.am
 create mode 100644 debian/changelog
 create mode 100644 debian/control
 create mode 100644 debian/copyright
 create mode 100644 debian/liblog4cpp-dev.dirs
 create mode 100644 debian/liblog4cpp-dev.files
 create mode 100644 debian/liblog4cpp-doc.dirs
 create mode 100644 debian/liblog4cpp-doc.files
 create mode 100644 debian/liblog4cpp0.dirs
 create mode 100644 debian/liblog4cpp0.files
 create mode 100644 debian/liblog4cpp0.postinst
 create mode 100644 debian/rules
 create mode 100644 include/log4cpp/TimeRollingFileAppender.hh
 create mode 100644 src/TimeRollingFileAppender.cpp

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ca3b0fa
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,59 @@
+blib*
+Makefile
+Makefile.old
+*~
+*swp
+Build
+_build*
+pm_to_blib*
+*.tar.gz
+*.tar.bz2
+.lwpcookies
+cover_db
+*.bak
+*.log
+config.log
+autom4te.cache
+stamp-h1
+Doxyfile
+compile
+config.status
+myconfig.h
+doc/doxygen
+autom4te.cache
+aclocal.m4
+config.guess
+config.h.in
+config.sub
+configure
+depcomp
+install-sh
+ltmain.sh
+missing
+config.h
+libtool
+*.libs
+*.la
+*.deps
+*Makefile.in
+*.o
+*.lo
+*.loT
+*.out
+*dotest
+*.gcno
+*.gcda
+ilike-*
+.gdb_history
+m4/libtool.m4
+m4/ltoptions.m4
+m4/ltsugar.m4
+m4/ltversion.m4
+m4/lt~obsolete.m4
+log4cpp-config
+log4cpp.pc
+doc/html/api
+doc/man
+tests/testbench
+tests/testmain
+log4cpp.spec
diff --git a/INSTALL b/INSTALL
index 53c5e0b..a8ce75a 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,2 +1,3 @@
 See 'Building Log4cpp' section of HTML documentation.
 
+reference to README
diff --git a/Makefile.am b/Makefile.am
index 544bf7a..2a8e17e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,7 @@
+AUTOMAKE_OPTIONS						= foreign
+
+ACLOCAL_AMFLAGS = -I m4
+
 if DOC
 SUBDIRS = msvc6 bcb5 config src include tests doc 
 else
@@ -53,6 +57,10 @@ rpm: dist
 	mv -f /usr/src/redhat/RPMS/*/$(PACKAGE)-doc-$(VERSION)-*.rpm \
 		$(top_srcdir)
 
+debian:
+	chmod a+x $(top_srcdir)/debian/rules
+	dpkg-buildpackage -rfakeroot -sa -us -uc -tc 
+
 docs:
 	$(MAKE) -C doc
 
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..2ab57c4
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# $Id: autogen.sh 1091 2008-06-08 06:37:22Z nicodvb $
+#
+# run this to generate all the initial makefiles, etc.
+
+srcdir=`dirname "$0"`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+cd "$srcdir"
+
+AUTORECONF=${AUTORECONF-autoreconf}
+
+if ! type $AUTORECONF >/dev/null 2>&1; then
+  echo "**Error**: Missing \`autoreconf' program." >&2
+  echo "You will need the autoconf and automake packages." >&2
+  echo "You can download them from ftp://ftp.gnu.org/pub/gnu/." >&2
+  exit 1
+fi
+
+test ! -d "$srcdir/m4" &&  mkdir "$srcdir/m4"
+$AUTORECONF -v --install || exit $?
+cd "$ORIGDIR" || exit $?
+
diff --git a/configure.in b/configure.in
index 1dba52c..b52d804 100644
--- a/configure.in
+++ b/configure.in
@@ -1,4 +1,4 @@
-AC_INIT(log4cpp, 1.1)
+AC_INIT([log4cpp], [1.1.1], [cnangel@gmail.com])
 
 # autoconf 2.50 or higher to rebuild aclocal.m4, because the
 # AC_CREATE_PREFIX_CONFIG_H macro needs the AS_DIRNAME macro.
@@ -19,8 +19,9 @@ AC_SUBST(LT_VERSION)
 AC_CONFIG_AUX_DIR(config)
 AM_CONFIG_HEADER(include/config.h)
 
-AM_INIT_AUTOMAKE
+AM_INIT_AUTOMAKE([log4cpp], [1.1.1])
 
+AC_CONFIG_MACRO_DIR([m4])
 # General "with" options
 # ----------------------------------------------------------------------------
 AC_ARG_WITH(idsa, [  --with-idsa             include idsa support])
diff --git a/debian/Makefile.am b/debian/Makefile.am
new file mode 100644
index 0000000..a8ad9af
--- /dev/null
+++ b/debian/Makefile.am
@@ -0,0 +1,9 @@
+EXTRA_DIST = \
+	changelog control copyright rules \
+	liblog4cpp-dev.dirs \
+	liblog4cpp-dev.files \
+	liblog4cpp-doc.dirs \
+	liblog4cpp-doc.files \
+	liblog4cpp0.dirs \
+	liblog4cpp0.files \
+	liblog4cpp0.postinst
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..81f0b1f
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,12 @@
+log4cpp (0.2.4b-0) unstable; urgency=low
+
+  * The debian packaging files in this directory build un-official packages. 
+    Official log4cpp debian packages are available from the debian archives,
+    see http://packages.debian.org/liblog4cpp*.
+
+ -- Marcel Harkema <marcel@debian.org>  Sat, 21 April 2001 13:36:10 +0200
+
+Local variables:
+mode: debian-changelog
+add-log-mailing-address: "marcel@debian.org"
+End:
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..e1e8d1f
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,34 @@
+Source: log4cpp
+Section: contrib/devel
+Priority: optional
+Maintainer: Marcel Harkema <marcel@debian.org>
+Standards-Version: 3.5.2
+Build-Depends: debhelper (>> 3.0.0), libtool, doxygen, graphviz
+
+Package: liblog4cpp0
+Architecture: any
+Section: libs
+Depends: ${shlibs:Depends}
+Description: A C++ library for flexible logging
+ Log for C++ is a library of C++ classes for flexible logging to files,
+ syslog and other destinations. It is modeled after the Log for
+ Java library (http://jakarta.apache.org/log4j/), staying as close to
+ their API as is reasonable.
+
+Package: liblog4cpp-dev
+Architecture: any
+Depends: liblog4cpp0 (= ${Source-Version}), libc6-dev
+Description: A C++ library for flexible logging (development files)
+ Log for C++ is a library of C++ classes for flexible logging to files,
+ syslog and other destinations. It is modeled after the Log for
+ Java library (http://jakarta.apache.org/log4j/), staying as close to
+ their API as is reasonable.
+
+Package: liblog4cpp-doc
+Architecture: all
+Description: A C++ library for flexible logging (documentation)
+ Log for C++ is a library of C++ classes for flexible logging to files,
+ syslog and other destinations. It is modeled after the Log for
+ Java library (http://jakarta.apache.org/log4j/), staying as close to
+ their API as is reasonable.
+
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..e43d5e7
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,19 @@
+This package was debianized by Marcel Harkema <marcel@debian.org>
+on Sat, 7 Apr 2001 19:24:11 +0100.
+
+Original source has been downloaded from:
+  http://sourceforge.net/projects/log4cpp/
+
+Homepage:
+  http://log4cpp.sourceforge.net/
+
+Copyright:
+  Copyright (C) 2000,2001 LifeLine Networks bv
+  Copyright (C) 2000,2001 Bastiaan Bakker
+
+License:
+  GNU Lesser General Public License.  A copy of the GNU Lesser General
+  Public License, version 2.1, can be found in /usr/share/common-licenses/LGPL-2.1
+
+Debian package maintainer:
+  Marcel Harkema <marcel@debian.org>
diff --git a/debian/liblog4cpp-dev.dirs b/debian/liblog4cpp-dev.dirs
new file mode 100644
index 0000000..38bf9a7
--- /dev/null
+++ b/debian/liblog4cpp-dev.dirs
@@ -0,0 +1,2 @@
+usr/include/log4cpp
+usr/lib
diff --git a/debian/liblog4cpp-dev.files b/debian/liblog4cpp-dev.files
new file mode 100644
index 0000000..62a5128
--- /dev/null
+++ b/debian/liblog4cpp-dev.files
@@ -0,0 +1,4 @@
+usr/lib/liblog4cpp.a
+usr/lib/liblog4cpp.la
+usr/lib/liblog4cpp.so
+usr/include/log4cpp
diff --git a/debian/liblog4cpp-doc.dirs b/debian/liblog4cpp-doc.dirs
new file mode 100644
index 0000000..2ae7ac9
--- /dev/null
+++ b/debian/liblog4cpp-doc.dirs
@@ -0,0 +1 @@
+usr/share/man/man3
diff --git a/debian/liblog4cpp-doc.files b/debian/liblog4cpp-doc.files
new file mode 100644
index 0000000..2ae7ac9
--- /dev/null
+++ b/debian/liblog4cpp-doc.files
@@ -0,0 +1 @@
+usr/share/man/man3
diff --git a/debian/liblog4cpp0.dirs b/debian/liblog4cpp0.dirs
new file mode 100644
index 0000000..6845771
--- /dev/null
+++ b/debian/liblog4cpp0.dirs
@@ -0,0 +1 @@
+usr/lib
diff --git a/debian/liblog4cpp0.files b/debian/liblog4cpp0.files
new file mode 100644
index 0000000..ee5a64d
--- /dev/null
+++ b/debian/liblog4cpp0.files
@@ -0,0 +1 @@
+usr/lib/liblog4cpp.so.*
diff --git a/debian/liblog4cpp0.postinst b/debian/liblog4cpp0.postinst
new file mode 100644
index 0000000..e3d9c57
--- /dev/null
+++ b/debian/liblog4cpp0.postinst
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+if [ "$1" = "configure" ]; then
+  ldconfig
+fi
+
+#DEBHELPER#
diff --git a/debian/rules b/debian/rules
new file mode 100644
index 0000000..dbf2b62
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,85 @@
+#!/usr/bin/make -f
+
+# Uncomment this to turn on verbose mode. 
+export DH_VERBOSE=1
+
+# This is the debhelper compatibility version to use.
+export DH_COMPAT=3
+
+# This has to be exported to make some magic below work.
+export DH_OPTIONS
+
+build: build-stamp
+build-stamp:
+	dh_testdir
+	if [ -x ./autogen.sh ] ; then ./autogen.sh ; fi
+	./configure --prefix=/usr --mandir=\$${prefix}/share/man
+	$(MAKE)
+	touch build-stamp
+
+clean:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp install-stamp
+	-$(MAKE) clean
+	-$(MAKE) distclean
+	dh_clean
+
+install: DH_OPTIONS=
+install: install-stamp
+install-stamp: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+	dh_installdirs
+	# Add here commands to install the package into debian/tmp.
+	$(MAKE) prefix=`pwd`/debian/tmp/usr install
+	dh_movefiles
+	# Copy class documentation (html) to doc/ directory of -doc package.
+	mkdir -p debian/liblog4cpp-doc/usr/share/doc/liblog4cpp-doc/html
+	mv debian/tmp/usr/doc/log4cpp-*/html/* debian/liblog4cpp-doc/usr/share/doc/liblog4cpp-doc/html/
+	touch install-stamp
+
+binary-common:
+	dh_testdir
+	dh_testroot
+#	dh_installdebconf
+	dh_installdocs
+	dh_installexamples
+	dh_installmenu
+#	dh_installlogrotate
+#	dh_installemacsen
+#	dh_installpam
+#	dh_installmime
+#	dh_installinit
+	dh_installman
+	dh_installcron
+	dh_installinfo
+#	dh_undocumented
+	dh_installchangelogs
+	dh_link
+	dh_compress
+	dh_fixperms
+	dh_makeshlibs --noscripts
+	dh_installdeb
+#	dh_perl
+	dh_strip
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+# Build architecture dependant packages using the common target.
+binary-arch: build install
+	$(MAKE) -f debian/rules DH_OPTIONS=-a binary-common
+
+# Build architecture independant packages using the common target.
+binary-indep: build install
+	$(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
+
+# Any other binary targets build just one binary package at a time.
+binary-%: build install
+	$(MAKE) -f debian/rules binary-common DH_OPTIONS=-p$*
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in
index 73161b0..4bde12d 100644
--- a/doc/Doxyfile.in
+++ b/doc/Doxyfile.in
@@ -62,6 +62,7 @@ COLLABORATION_GRAPH  = YES
 INCLUDE_GRAPH        = YES
 INCLUDED_BY_GRAPH    = YES
 GRAPHICAL_HIERARCHY  = YES
-MAX_DOT_GRAPH_WIDTH    = 1024
-MAX_DOT_GRAPH_HEIGHT   = 1024
+#MAX_DOT_GRAPH_WIDTH    = 1024
+#MAX_DOT_GRAPH_HEIGHT   = 1024
 GENERATE_LEGEND        = YES
+DOT_IMAGE_FORMAT = gif
diff --git a/doc/Makefile.am b/doc/Makefile.am
index e98a555..2a2064f 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,7 +1,7 @@
 SUBDIRS = html
 
 man3dir = $(mandir)/man3
-docdir  = $(prefix)/doc/@PACKAGE_TARNAME@-@PACKAGE_VERSION@
+docdir  = $(datadir)/doc/@PACKAGE_TARNAME@-@PACKAGE_VERSION@
 
 EXTRA_DIST = \
 	mainPage.txt
diff --git a/include/log4cpp/Appender.hh b/include/log4cpp/Appender.hh
index 471e3ad..7efe126 100644
--- a/include/log4cpp/Appender.hh
+++ b/include/log4cpp/Appender.hh
@@ -145,6 +145,17 @@ namespace log4cpp {
     };
 
     typedef std::set<Appender *> AppenderSet;
+
+    typedef Appender* InstantiateAmberAppender(const std::string& name, const std::string& config,
+            int category, int version, const std::string& queueName, int subqueueId, int bufferThreshold);
+
+    /**
+     * set the function used to instantiate an AmberAppender,
+     * which returns NULL if failed.
+     */
+    LOG4CPP_EXPORT void setInstantiateAmberAppender(InstantiateAmberAppender* instantiate);
+
+    LOG4CPP_EXPORT InstantiateAmberAppender* getInstantiateAmberAppender();
 }
 
 #endif // _LOG4CPP_APPENDER_HH
diff --git a/include/log4cpp/Makefile.am b/include/log4cpp/Makefile.am
index 608cef0..db5d4b6 100644
--- a/include/log4cpp/Makefile.am
+++ b/include/log4cpp/Makefile.am
@@ -47,7 +47,9 @@ liblog4cppinclude_HEADERS =  \
 	config-win32.h \
 	config-openvms.h \
   config-MinGW32.h \
-	convenience.h
+	convenience.h \
+	TimeRollingFileAppender.hh \
+	$(NULL)
 
 dist-hook:
 	$(RM) -f $(distdir)/config.h
diff --git a/include/log4cpp/TimeRollingFileAppender.hh b/include/log4cpp/TimeRollingFileAppender.hh
new file mode 100644
index 0000000..13a62eb
--- /dev/null
+++ b/include/log4cpp/TimeRollingFileAppender.hh
@@ -0,0 +1,116 @@
+/*
+ * TimeRollingFileAppender.hh
+ *
+ * Copyright 2009, Thomas Zhang. All rights reserved.
+ *
+ * See the COPYING file for the terms of usage and distribution.
+ */
+
+#ifndef _LOG4CPP_TIMEROLLINGFILEAPPENDER_HH
+#define _LOG4CPP_TIMEROLLINGFILEAPPENDER_HH
+
+#include <log4cpp/Portability.hh>
+#include <log4cpp/LayoutAppender.hh>
+#include <string>
+#include <stdarg.h>
+
+namespace log4cpp {
+
+    /**
+       TimeRollingFileAppender is a appender like the FileAppender that rolls over the logfile once
+       it has reached a certain size limit.
+       TimeRollingFileAppender rolls over the logfile on the certain time.
+       @since 0.3.1
+    **/
+    class LOG4CPP_EXPORT TimeRollingFileAppender : public LayoutAppender {
+        public:
+
+        /**
+           Constructs a TimeRollingFileAppender.
+           @param name the name of the Appender.
+           @param fileName the name of the file to which the Appender has 
+           to log.
+           @param maxFileAge the interval of rolling over the logfile.
+           @param backupPattern the time pattern of the logfile name .
+           @param append whether the Appender has to truncate the file or
+           just append to it if it already exists. Defaults to 'true'.
+           @param mode file mode to open the logfile with. Defaults to 00644.
+        **/  
+        TimeRollingFileAppender(const std::string& name, const std::string& fileName,
+                     time_t maxFileAge, std::string backupPattern,
+                     bool append = true, mode_t mode = 00644);
+
+        virtual ~TimeRollingFileAppender();
+        
+        /**
+           Reopens the logfile. 
+           This can be useful for logfiles that are rotated externally,
+           e.g. by logrotate. This method is a NOOP for FileAppenders that
+           have been constructed with a file descriptor.           
+           @returns true if the reopen succeeded.
+        **/
+        virtual bool reopen();
+
+        /**
+           Closes the logfile.
+        **/
+        virtual void close();
+
+        /**
+           Sets the append vs truncate flag.
+           NB. currently the TimeRollingFileAppender opens the logfile in the 
+           constructor. Therefore this method is too late to influence the 
+           first file opening. We'll need something similar to log4j's
+           activateOptions().
+           @param append false to truncate, true to append
+        **/
+        virtual void setAppend(bool append);
+
+        /**
+           Gets the value of the 'append' option.
+        **/
+        virtual bool getAppend() const;
+
+        /**
+           Sets the file open mode.
+        **/
+        virtual void setMode(mode_t mode);
+
+        /**
+           Gets the file open mode.
+        **/
+        virtual mode_t getMode() const;
+
+	/**
+	   Sets the time pattern of the logfile name 
+	   @param backupPattern the time string's format specification that
+           introduced by a '%' character.
+	**/
+        virtual void setBackupPattern(std::string backupPattern);
+
+	/**
+	   Gets the time pattern.
+	**/
+        virtual std::string getBackupPattern() const;
+
+
+        protected:
+        virtual void _append(const LoggingEvent& event);
+
+        std::string _fileName;
+        int _fd;
+        int _flags;
+        mode_t _mode;
+
+	std::string  _backupPattern;
+	time_t _maxFileAge;
+        std::string _fileNamePrefix;
+        time_t _fileCreateTime;
+
+
+	//static std::string concatLogfileName(const time_t now, const time_t maxFileAge, const std::string& fileNamePrefix, time_t& fileCreateTime);
+
+    };
+}
+
+#endif // _LOG4CPP_TIMEROLLINGFILEAPPENDER_HH
diff --git a/include/log4cpp/config-openvms.h b/include/log4cpp/config-openvms.h
index 792c7b0..38c06fa 100644
--- a/include/log4cpp/config-openvms.h
+++ b/include/log4cpp/config-openvms.h
@@ -60,7 +60,7 @@
 
 /* Version number of package */
 #ifndef LOG4CPP_VERSION 
-#define LOG4CPP_VERSION  "1.0" 
+#define LOG4CPP_VERSION  "1.1.0" 
 #endif
  
 /* _INCLUDE_LOG4CPP_CONFIG_OPENVMS_H */
diff --git a/log4cpp.spec.in b/log4cpp.spec.in
index b6563c3..9e59aba 100644
--- a/log4cpp.spec.in
+++ b/log4cpp.spec.in
@@ -1,8 +1,15 @@
-%define  RELEASE 4
-%define  rel     %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE}
+%define is_etc  %(test -z $etc && echo 0 || echo 1)
+%define is_not_etc  %(test -z $etc && echo 1 || echo 0)
+%define  RELEASE 2
+%define  rel     %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE}%{?dist}
 
 %define lib_name log4cpp
+%if %{is_not_etc}
+%define manualdir       %{_docdir}/%{name}
+%endif
+%if %{is_etc}
 %define manualdir       /var/www/html/manual/%{name}
+%endif
 
 Name: @PACKAGE_TARNAME@
 Version: @PACKAGE_VERSION@
@@ -12,13 +19,18 @@ Summary: Log for C++
 License: LGPL
 Group: Development/Libraries
 Vendor:  Bastiaan Bakker <bastiaan.bakker@lifeline.nl>
-Packager: Cedric Le Goater <cedric@legoater.com>
+Packager: junliang.li <cnangel@gmail.com>
 Url: http://log4cpp.sourceforge.net/
 
-Source: ftp://download.sourceforge.net/pub/sourceforge/log4cpp/%name-%version.tar.gz
+#Source: ftp://download.sourceforge.net/pub/sourceforge/log4cpp/%name-%version.tar.gz
+Source0: %{name}-1.1rc1.tar.gz
+Patch0: 0001-update-for-cnangel.patch
 
+%if %{is_not_etc}
 Prefix: %_prefix
-BuildRoot: %_tmppath/%name-%version-root
+%endif
+BuildRoot: %_tmppath/%{name}-%{version}-%{release}-root-%(%{__id} -u -n)
+
 
 %description
 Log for C++ is a library of classes for flexible logging to files, syslog,
@@ -46,52 +58,91 @@ The %name-doc package contains HTML formatted API documention generated by
 the popular doxygen documentation generation tool.
 
 %prep
-%{__rm} -rf $RPM_BUILD_ROOT
-
-%setup
-CC=%{__cc} CXX=%{__cxx} ./configure --prefix=%{prefix} --enable-doxygen 
+%setup -q -n %{name}-1.1
+%patch0 -p1
 
 %build
-%{__make}
+sh ./autogen.sh
+CC=%{__cc} CXX=%{__cxx} ./configure --prefix=%{prefix} --enable-doxygen --with-pthreads --with-pic
+%{__make} %{?_smp_mflags}
 
 %install
 %{__rm} -rf $RPM_BUILD_ROOT
+%makeinstall
+mkdir -p $RPM_BUILD_ROOT%{_libdir}/pkgconfig
+cp -rf log4cpp.pc $RPM_BUILD_ROOT%{_libdir}/pkgconfig/
+mkdir -p $RPM_BUILD_ROOT%{_datadir}/aclocal
+cp -rf log4cpp.m4 $RPM_BUILD_ROOT%{_datadir}/aclocal/
+mkdir -p $RPM_BUILD_ROOT%{manualdir}
+cp -rf doc/html/*.htm* $RPM_BUILD_ROOT%{manualdir}/
+cp -rf doc/html/*.css $RPM_BUILD_ROOT%{manualdir}/
+cp -rf doc/html/*.png $RPM_BUILD_ROOT%{manualdir}/
+cp -rf doc/html/api $RPM_BUILD_ROOT%{manualdir}/
 
-%{__make} prefix=$RPM_BUILD_ROOT%{prefix}docdir=$RPM_BUILD_ROOT/%{manualdir} install
 %clean
 %{__rm} -rf $RPM_BUILD_ROOT
 
 %ifnos solaris2.8 solaris2.9 solaris2.10
+%if %{is_etc}
 %post -p /sbin/ldconfig
 %endif
+%endif
 
 %post devel
 if test "x$RPM_INSTALL_PREFIX0" != "x" ; then
-    %{__perl} -pi -e"s|^libdir='[^\']*'|libdir='$RPM_INSTALL_PREFIX0/lib'|" $RPM_INSTALL_PREFIX0/lib/liblog4cpp.la
-    %{__perl} -pi -e"s|^prefix=\"[^\"]*\"|prefix=\"$RPM_INSTALL_PREFIX0\"|" $RPM_INSTALL_PREFIX0/bin/log4cpp-config
+    %{__perl} -pi -e"s|^libdir='[^\']*'|libdir='$RPM_INSTALL_PREFIX0/%{_lib}'|" $RPM_INSTALL_PREFIX0/%{_lib}/liblog4cpp.la
+    %{__perl} -pi -e"s|/usr|$RPM_INSTALL_PREFIX0|" $RPM_INSTALL_PREFIX0/%{_lib}/pkgconfig/log4cpp.pc
+    %{__perl} -pi -e"s| -O2 ||" $RPM_INSTALL_PREFIX0/%{_lib}/pkgconfig/log4cpp.pc
+    %{__perl} -pi -e"s| -DNDEBUG||" $RPM_INSTALL_PREFIX0/%{_lib}/pkgconfig/log4cpp.pc
+    %{__perl} -pi -e"s|/lib$|/%{_lib}|" $RPM_INSTALL_PREFIX0/%{_lib}/pkgconfig/log4cpp.pc
+    %{__perl} -pi -e"s| prefix=\"[^\"]*\"| prefix=\"$RPM_INSTALL_PREFIX0\"|" $RPM_INSTALL_PREFIX0/bin/log4cpp-config
+    %{__perl} -pi -e"s| -O2 ||" $RPM_INSTALL_PREFIX0/bin/log4cpp-config
+    %{__perl} -pi -e"s| -DNDEBUG||" $RPM_INSTALL_PREFIX0/bin/log4cpp-config
+    %{__perl} -pi -e"s|/lib\"$|/%{_lib}\"|" $RPM_INSTALL_PREFIX0/bin/log4cpp-config
 fi
 
 %ifnos solaris2.8 solaris2.9 solaris2.10 
+%if %{is_etc}
 %postun -p /sbin/ldconfig
 %endif
+%endif
 
 %files
 %defattr(-,root,root,755)
-%attr(755,root,root) %prefix/lib/lib*.so.*
+%{_libdir}/*.so*
 %doc AUTHORS COPYING INSTALL NEWS README THANKS ChangeLog
 
 %files devel
 %defattr(-,root,root,755)
-%prefix/include/*
-%prefix/man/*
-%attr(755,root,root) %prefix/bin/log4cpp-config
-%attr(755,root,root) %prefix/lib/lib*.so
-%attr(644,root,root) %prefix/lib/*.*a
-%attr(644,root,root) %prefix/lib/pkgconfig/log4cpp.pc
-%attr(644,root,root) %prefix/share/aclocal/*.m4
+%{_mandir}/*
+%attr(644,root,root) %{_datadir}/aclocal/*.m4
+%attr(644,root,root) %{_libdir}/*.a
+%attr(644,root,root) %{_libdir}/*.la
+%attr(644,root,root) %{_libdir}/pkgconfig/log4cpp.pc
+%{_includedir}
+%attr(755,root,root) %{_bindir}/log4cpp-config
 
 %files doc
 %defattr(-,root,root)
 %doc %{manualdir}
 
+%changelog
+* Mon Jul 23 2012 Cnangel <cnangel@gmail.com> 1.1.1-2
+- Add amber client interface and TimeRollingFileAppender for log4cpp-1.1 
+* Wed Jul 18 2012 Cnangel <cnangel@gmail.com> 1.1.0-1
+- for build rpm package
+* Tue Jul 17 2012 Cnangel <cnangel@gmail.com> 1.0.8-1
+- keep origin package and use patch
+* Wed May 30 2012 Cnangel <cnangel@gmail.com> 1.0.7-2
+- add amber client interface
+* Tue Aug 23 2011 Cnangel <cnangel@gmail.com> 1.0.6-2
+- fixed assert for -DNDEBUG
+* Mon Apr 18 2011 Cnangel <cnangel@gmail.com> 1.0.6-1
+- add TimeRollingFileAppender and SemaLock
+* Thu Dec 31 2009 Cnangel <cnangel@gmail.com> 1.0.5-6
+- fix rpm for x86_64
+* Wed Mar 18 2009 Cnangel <cnangel@gmail.com> 1.0.5-5
+- fix rpm for new rpmbuild version
+* Fri Feb 20 2009 Cnangel <cnangel@gmail.com> 1.0.4-1
+- create spec file
 
diff --git a/m4/BB_CHECK_PTHREADS.m4 b/m4/BB_CHECK_PTHREADS.m4
index 669b6e3..8e76d1d 100644
--- a/m4/BB_CHECK_PTHREADS.m4
+++ b/m4/BB_CHECK_PTHREADS.m4
@@ -6,12 +6,11 @@ AC_REQUIRE([AC_PROG_CXX])dnl
 AC_REQUIRE([AC_PROG_CPP])dnl
 AC_REQUIRE([AC_PROG_CXXCPP])dnl
 
-
-AC_ARG_WITH(pthreads, [  --with-pthreads         include pthreads support],
-    AC_SEARCH_LIBS(pthread_key_create,pthread,
+AC_ARG_WITH([pthreads], [  --with-pthreads         include pthreads support],
+    [AC_SEARCH_LIBS([pthread_key_create], [pthread],
         [AC_DEFINE(HAVE_THREADING,,[define if threading is enabled])
          AC_DEFINE(USE_PTHREADS,,[define if pthread library is available])
          AC_DEFINE(_PTHREADS,,[define for STL if pthread library is used])],
-    AC_MSG_ERROR([pthreads not found])))
+    [AC_MSG_ERROR([pthreads not found])])])
 
 ])
diff --git a/m4/ac_config_libconfig_in.m4 b/m4/ac_config_libconfig_in.m4
index 1545cb2..636b8c2 100644
--- a/m4/ac_config_libconfig_in.m4
+++ b/m4/ac_config_libconfig_in.m4
@@ -120,7 +120,7 @@ echo 'o=""' >>$LIBCONFIG_FILE
 echo 'h=""' >>$LIBCONFIG_FILE
 echo 'for i ; do' >>$LIBCONFIG_FILE
 echo '  case $i in' >>$LIBCONFIG_FILE
-options="prefix exec-prefix eprefix package version cflags libs bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir infodir mandir target host build pkgdatadir pkglibdir pkgincludedir template-version help"
+options="prefix exec-prefix eprefix package version cflags libs bindir sbindir libexecdir datadir datarootdir sysconfdir sharedstatedir localstatedir libdir infodir mandir target host build pkgdatadir pkglibdir pkgincludedir template-version help"
 echo '    --prefix=*) prefix=`echo $i | sed -e "s/--prefix=//"` ;;' >>$LIBCONFIG_FILE
 echo '    --exec-prefix=*) exec_prefix=`echo $i | sed -e "s/--exec-prefix=//"` ;;' >>$LIBCONFIG_FILE
 echo '    --eprefix=*) exec_prefix=`echo $i | sed -e "s/--eprefix=//"` ;;' >>$LIBCONFIG_FILE
@@ -143,7 +143,7 @@ echo 'done' >>$LIBCONFIG_FILE
 echo ' ' >>$LIBCONFIG_FILE
 # in the order of occurence a standard automake Makefile
 echo '# defaults from configure; set only if not set previously' >>$LIBCONFIG_FILE
-vars="prefix exec_prefix bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir infodir mandir includedir target host build"
+vars="prefix exec_prefix bindir sbindir libexecdir datadir datarootdir sysconfdir sharedstatedir localstatedir libdir infodir mandir includedir target host build"
 for var in $vars ; do
   echo "if test -z \"\$$var\" ; then" >>$LIBCONFIG_FILE
   echo "  $var=\"@$var@\"" >>$LIBCONFIG_FILE
@@ -209,6 +209,7 @@ echo '  --bindir           \$bindir        $bindir' >>$LIBCONFIG_FILE
 echo '  --sbindir          \$sbindir       $sbindir' >>$LIBCONFIG_FILE
 echo '  --libexecdir       \$libexecdir    $libexecdir' >>$LIBCONFIG_FILE
 echo '  --datadir          \$datadir       $datadir' >>$LIBCONFIG_FILE
+echo '  --datarootdir      \$datarootdir   $datarootdir' >>$LIBCONFIG_FILE
 echo '  --sysconfdir       \$sysconfdir    $sysconfdir' >>$LIBCONFIG_FILE
 echo '  --sharedstatedir   \$sharedstatedir$sharedstatedir' >>$LIBCONFIG_FILE
 echo '  --localstatedir    \$localstatedir $localstatedir' >>$LIBCONFIG_FILE
diff --git a/src/Appender.cpp b/src/Appender.cpp
index 7f97e63..d6becd2 100644
--- a/src/Appender.cpp
+++ b/src/Appender.cpp
@@ -14,6 +14,8 @@ namespace log4cpp {
     Appender::AppenderMap* Appender::_allAppenders = 0;
     threading::Mutex Appender::_appenderMapMutex;
 
+    InstantiateAmberAppender* _instantiateAmberAppender;
+
     /* assume _appenderMapMutex locked */
     Appender::AppenderMap& Appender::_getAllAppenders() {
         if (!_allAppenders) 
@@ -77,4 +79,12 @@ namespace log4cpp {
     Appender::~Appender() {
         _removeAppender(this);
     }
+
+    void setInstantiateAmberAppender(InstantiateAmberAppender* instantiate) {
+		_instantiateAmberAppender = instantiate;
+	}
+
+	InstantiateAmberAppender* getInstantiateAmberAppender() {
+		return _instantiateAmberAppender;
+	}
 }
diff --git a/src/AppendersFactory.cpp b/src/AppendersFactory.cpp
index b30eaa9..2c9ad04 100644
--- a/src/AppendersFactory.cpp
+++ b/src/AppendersFactory.cpp
@@ -7,6 +7,7 @@ namespace log4cpp
 
    std::auto_ptr<Appender> create_file_appender(const FactoryParams&);
    std::auto_ptr<Appender> create_roll_file_appender(const FactoryParams&);
+   std::auto_ptr<Appender> create_time_roll_file_appender(const FactoryParams&);
    std::auto_ptr<Appender> create_idsa_appender(const FactoryParams&);
    std::auto_ptr<Appender> create_nt_event_log_appender(const FactoryParams&);
    std::auto_ptr<Appender> create_remote_syslog_appender(const FactoryParams&);
@@ -23,6 +24,7 @@ namespace log4cpp
          
          af->registerCreator("file", &create_file_appender);
          af->registerCreator("roll file", &create_roll_file_appender);
+         af->registerCreator("time roll file", &create_time_roll_file_appender);
          af->registerCreator("remote syslog", &create_remote_syslog_appender);
          af->registerCreator("abort", &create_abort_appender);
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 9beb0f3..f51e2fc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -54,6 +54,8 @@ liblog4cpp_la_SOURCES = \
 	PThreads.cpp \
 	PortabilityImpl.hh \
 	PortabilityImpl.cpp \
-	AbortAppender.cpp
+	TimeRollingFileAppender.cpp \
+	AbortAppender.cpp \
+	$(NULL)
 
 liblog4cpp_la_LDFLAGS = -version-info @LT_VERSION@
diff --git a/src/PatternLayout.cpp b/src/PatternLayout.cpp
index a52ad0f..86d6ec8 100644
--- a/src/PatternLayout.cpp
+++ b/src/PatternLayout.cpp
@@ -24,6 +24,7 @@
 #include <iomanip>
 #include <ctime>
 #include <cstdlib>
+#include <cmath>
 #include "Localtime.hh"
 
 #ifdef LOG4CPP_HAVE_INT64_T
diff --git a/src/PropertyConfiguratorImpl.cpp b/src/PropertyConfiguratorImpl.cpp
index 063bbcb..f1a612c 100644
--- a/src/PropertyConfiguratorImpl.cpp
+++ b/src/PropertyConfiguratorImpl.cpp
@@ -25,6 +25,7 @@
 #include <log4cpp/OstreamAppender.hh>
 #include <log4cpp/FileAppender.hh>
 #include <log4cpp/RollingFileAppender.hh>
+#include <log4cpp/TimeRollingFileAppender.hh>
 #include <log4cpp/AbortAppender.hh>
 #ifdef WIN32
 #include <log4cpp/Win32DebugAppender.hh>
@@ -214,6 +215,40 @@ namespace log4cpp {
             appender = new RollingFileAppender(appenderName, fileName, maxFileSize, maxBackupIndex,
                 append);
         }
+        else if (appenderType == "TimeRollingFileAppender") {
+            std::string fileName = _properties.getString(appenderPrefix + ".fileName", "foobar");
+            size_t maxFileAge = _properties.getInt(appenderPrefix + ".maxFileAge", 24*60*60);
+            std::string backupPattern = _properties.getString(appenderPrefix + ".backupPattern", "%Y%m%d-%H:%M:%S");
+            bool append = _properties.getBool(appenderPrefix + ".append", true);
+            appender = new TimeRollingFileAppender(appenderName, fileName, maxFileAge, backupPattern,
+            append);
+        }
+        else if (appenderType == "AmberAppender") {
+            std::string config = _properties.getString(appenderPrefix + ".config", "");
+            if (config.empty()) {
+                throw ConfigureFailure(std::string("property 'config' must be set. appenderName: ") + appenderName);
+            }
+            int category = _properties.getInt(appenderPrefix + ".category", -1);
+            if (category == -1) {
+                throw ConfigureFailure(std::string("property 'category' must be set. appenderName: ") + appenderName);
+            }
+            int version = _properties.getInt(appenderPrefix + ".version", 0);
+            std::string queueName = _properties.getString(appenderPrefix + ".queueName", "log_queue");
+            int subqueueId = _properties.getInt(appenderPrefix + ".subqueueId", 1);
+            int bufferThreshold = _properties.getInt(appenderPrefix + ".bufferThreshold", 102400);
+            InstantiateAmberAppender* instantiate = getInstantiateAmberAppender();
+            if (instantiate == NULL) {
+                throw ConfigureFailure(std::string("instantiate AmberAppender failed. "
+                		"You SHOULD call AmberAppender::registerClass() "
+                		"before PropertyConfigurator::configure() to fix this. appenderName: ") + appenderName);
+            }
+            appender = (*instantiate)(appenderName, config,
+                    category, version, queueName, subqueueId, bufferThreshold);
+            if (appender == NULL) {
+                throw ConfigureFailure(std::string("instantiate AmberAppender failed. "
+                        "appenderName: ") + appenderName);
+            }
+        }
         else if (appenderType == "SyslogAppender") {
             std::string syslogName = _properties.getString(appenderPrefix + ".syslogName", "syslog");
             std::string syslogHost = _properties.getString(appenderPrefix + ".syslogHost", "localhost");
diff --git a/src/RemoteSyslogAppender.cpp b/src/RemoteSyslogAppender.cpp
index 6243bbb..ed28c8d 100644
--- a/src/RemoteSyslogAppender.cpp
+++ b/src/RemoteSyslogAppender.cpp
@@ -13,7 +13,7 @@
 #    include <unistd.h>
 #endif
 #include <cstdlib>
-#include <stdio.h>
+#include <cstdio>
 #include <cstring>
 #include <sys/types.h>
 #include <sys/stat.h>
diff --git a/src/TimeRollingFileAppender.cpp b/src/TimeRollingFileAppender.cpp
new file mode 100644
index 0000000..40d54dc
--- /dev/null
+++ b/src/TimeRollingFileAppender.cpp
@@ -0,0 +1,190 @@
+/*
+ * TimeRollingFileAppender.cpp
+ *
+ * Copyright 2009, Thomas Zhang. All rights reserved.
+ *
+ * See the COPYING file for the terms of usage and distribution.
+ */
+
+#include "PortabilityImpl.hh"
+#ifdef LOG4CPP_HAVE_IO_H
+#    include <io.h>
+#endif
+#ifdef LOG4CPP_HAVE_UNISTD_H
+#    include <unistd.h>
+#endif
+
+#include <memory>
+#include <stdio.h>
+#include <log4cpp/Category.hh>
+#include <log4cpp/FactoryParams.hh>
+
+#include <sys/types.h>
+#include <time.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <log4cpp/TimeRollingFileAppender.hh>
+#ifdef LOG4CPP_HAVE_SSTREAM
+#include <sstream>
+#endif
+
+#ifdef LOG4CPP_HAVE_GETTIMEOFDAY
+#include <sys/time.h>
+#else
+#ifdef LOG4CPP_HAVE_FTIME
+#include <sys/timeb.h>
+#else
+#include <time.h>
+#endif
+#endif
+namespace log4cpp {
+
+    TimeRollingFileAppender::TimeRollingFileAppender(const std::string& name, 
+                               const std::string& fileName,
+                               time_t maxFileAge, 
+                               std::string backupPattern,
+                               bool append,
+                               mode_t mode) : 
+            LayoutAppender(name),
+            _flags(O_CREAT | O_APPEND | O_WRONLY),
+            _mode(mode),
+            _backupPattern(backupPattern),
+            _maxFileAge(maxFileAge),
+            _fileNamePrefix(fileName)
+    {
+        if (!append)
+            _flags |= O_TRUNC;
+
+	time_t _seconds;
+	#ifdef LOG4CPP_HAVE_GETTIMEOFDAY
+		struct timeval tv;
+		::gettimeofday(&tv, NULL);
+		_seconds = tv.tv_sec;
+	#else
+	#ifdef LOG4CPP_HAVE_FTIME
+		struct timeb tb;
+		::ftime(&tb);
+		_seconds = tb.time;
+	#else
+		_seconds = ::time(NULL);
+	#endif
+	#endif
+	char buff[257];                         
+	struct tm result;                       
+	localtime_r(&_seconds,&result);
+	result.tm_sec=0,result.tm_min=0,result.tm_hour=0;
+	time_t today = mktime(&result);
+	_fileCreateTime = ( (_seconds - today) / _maxFileAge) * _maxFileAge + today;
+	strftime(buff,257,_backupPattern.c_str(),localtime_r(&_fileCreateTime,&result));
+	_fileName.assign(_fileNamePrefix);
+        _fileName.append(buff);
+
+        _fd = ::open(_fileName.c_str(), _flags, _mode);
+    }
+    
+    TimeRollingFileAppender::~TimeRollingFileAppender() {
+        close();
+    }
+
+    void TimeRollingFileAppender::setBackupPattern(std::string backupPattern) {
+        _backupPattern = backupPattern;
+    }
+
+    std::string TimeRollingFileAppender::getBackupPattern() const {
+        return _backupPattern;
+    }
+
+    void TimeRollingFileAppender::close() {
+        if (_fd!=-1) {
+            ::close(_fd);
+            _fd=-1;
+        }
+    }
+
+    void TimeRollingFileAppender::setAppend(bool append) {
+        if (append) {
+            _flags &= ~O_TRUNC;
+        } else {
+            _flags |= O_TRUNC;
+        }
+    }
+
+    bool TimeRollingFileAppender::getAppend() const {
+        return (_flags & O_TRUNC) == 0;
+    }
+
+    void TimeRollingFileAppender::setMode(mode_t mode) {
+        _mode = mode;
+    }
+
+    mode_t TimeRollingFileAppender::getMode() const {
+        return _mode;
+    }
+
+    void TimeRollingFileAppender::_append(const LoggingEvent& event) 
+    {
+	time_t elapse = event.timeStamp.getSeconds() - _fileCreateTime;
+        if(  elapse >= _maxFileAge )
+        {
+        	//_fileName = TimeRollingFileAppender::concatLogfileName(now, _maxFileAge, _fileNamePrefix, _fileCreateTime);
+		char buff[257];                         
+		struct tm result;                       
+		_fileCreateTime = (elapse / _maxFileAge) * _maxFileAge + _fileCreateTime;
+		strftime(buff,257,_backupPattern.c_str(),localtime_r(&_fileCreateTime,&result));
+		_fileName.assign(_fileNamePrefix);
+		_fileName.append(buff);
+
+		reopen();
+        }
+
+	//append
+        std::string message(_getLayout().format(event));
+        if (!::write(_fd, message.data(), message.length())) {
+            // XXX help! help!
+        }
+    }
+
+    bool TimeRollingFileAppender::reopen() {
+        if (_fileName != "") {
+            int fd = ::open(_fileName.c_str(), _flags, _mode);
+            if (fd < 0)
+                return false;
+            else {
+	        if (_fd != -1)
+                    ::close(_fd);
+                _fd = fd;
+                return true;
+            }
+        } else {
+            return true;
+        }      
+    }
+/*
+    std::string TimeRollingFileAppender::concatLogfileName(const time_t now, 
+                                                           const time_t maxFileAge,
+                                                           const std::string& fileNamePrefix,
+                                                           time_t& fileCreateTime)
+    {
+	time_t fileCreateTime = (now / maxFileAge) * maxFileAge;
+	char buff[257];                         
+	struct tm result;                       
+	std::string fileName(fileNamePrefix);
+	strftime(buff,257,_backupPattern.c_str(),localtime_r(&fileCreateTime,&result));
+        fileName.append(buff);
+	return fileName;
+    } 
+*/
+   std::auto_ptr<Appender> create_time_roll_file_appender(const FactoryParams& params)
+   {
+      std::string name, filename;
+      bool append = true;
+      mode_t mode = 664;
+      time_t max_file_age = 86400;
+      std::string backup_pattern("%Y%m%d-%H%M%S");
+
+      params.get_for("time roll file appender").required("name", name)("filename", filename)("max_file_age",max_file_age)("backup_pattern",backup_pattern)
+                                     .optional("append", append)("mode", mode);
+
+      return std::auto_ptr<Appender>(new TimeRollingFileAppender(name, filename, max_file_age, backup_pattern, append, mode));
+   }
+}
-- 
1.7.10.4

