Thread: [Kronos2-developer] [Kronos 2] Virtual mashine for Kronos branch master updated. 3a5c92ae7625086515
Status: Pre-Alpha
Brought to you by:
moskvin
From: Dmitrii K. <sst...@us...> - 2012-05-09 14:11:01
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Virtual mashine for Kronos". The branch, master has been updated via 3a5c92ae76250865159cb275e8754d215576ad7f (commit) from e72507e87468b0372f0c53d40e1cfdbf66700af0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 3a5c92ae76250865159cb275e8754d215576ad7f Author: Dmitriy Kuragin <sstepashka@MacBook-Pro-Dmirtrij.local> Date: Wed May 9 21:09:02 2012 +0700 new logger diff --git a/src/vm/libs/log4cplus.lib b/src/vm/libs/log4cplus.lib new file mode 100644 index 0000000..cb8a42f Binary files /dev/null and b/src/vm/libs/log4cplus.lib differ diff --git a/src/vm/log4cplus/appender.h b/src/vm/log4cplus/appender.h new file mode 100644 index 0000000..591ec63 --- /dev/null +++ b/src/vm/log4cplus/appender.h @@ -0,0 +1,212 @@ +// Module: Log4CPLUS +// File: appender.h +// Created: 6/2001 +// Author: Tad E. Smith +// +// +// Copyright 2001-2010 Tad E. Smith +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** @file */ + +#ifndef _LOG4CPLUS_APPENDER_HEADER_ +#define _LOG4CPLUS_APPENDER_HEADER_ + +#include <log4cplus/config.hxx> +#include <log4cplus/layout.h> +#include <log4cplus/loglevel.h> +#include <log4cplus/tstring.h> +#include <log4cplus/helpers/logloguser.h> +#include <log4cplus/helpers/pointer.h> +#include <log4cplus/helpers/property.h> +#include <log4cplus/spi/filter.h> + +#include <memory> + + +namespace log4cplus { + + /** + * This class is used to "handle" errors encountered in an {@link + * log4cplus::Appender}. + */ + class LOG4CPLUS_EXPORT ErrorHandler { + public: + virtual ~ErrorHandler(); + virtual void error(const log4cplus::tstring& err) = 0; + virtual void reset() = 0; + }; + + + + class LOG4CPLUS_EXPORT OnlyOnceErrorHandler : public ErrorHandler, + protected log4cplus::helpers::LogLogUser + { + public: + // Ctor + OnlyOnceErrorHandler() : firstTime(true){} + + virtual void error(const log4cplus::tstring& err); + virtual void reset(); + + private: + bool firstTime; + }; + + + /** + * Extend this class for implementing your own strategies for printing log + * statements. + */ + class LOG4CPLUS_EXPORT Appender + : public virtual log4cplus::helpers::SharedObject + , protected log4cplus::helpers::LogLogUser + + { + public: + // Ctor + Appender(); + Appender(const log4cplus::helpers::Properties properties); + + // Dtor + virtual ~Appender(); + + void destructorImpl(); + + // Methods + /** + * Release any resources allocated within the appender such as file + * handles, network connections, etc. + * + * It is a programming error to append to a closed appender. + */ + virtual void close() = 0; + + /** + * This method performs threshold checks and invokes filters before + * delegating actual logging to the subclasses specific {@link + * #append} method. + */ + void doAppend(const log4cplus::spi::InternalLoggingEvent& event); + + /** + * Get the name of this appender. The name uniquely identifies the + * appender. + */ + virtual log4cplus::tstring getName(); + + /** + * Set the name of this appender. The name is used by other + * components to identify this appender. + */ + virtual void setName(const log4cplus::tstring& name); + + /** + * Set the {@link ErrorHandler} for this Appender. + */ + virtual void setErrorHandler(std::auto_ptr<ErrorHandler> eh); + + /** + * Return the currently set {@link ErrorHandler} for this + * Appender. + */ + virtual ErrorHandler* getErrorHandler(); + + /** + * Set the layout for this appender. Note that some appenders have + * their own (fixed) layouts or do not use one. For example, the + * SocketAppender ignores the layout set here. + */ + virtual void setLayout(std::auto_ptr<Layout> layout); + + /** + * Returns the layout of this appender. The value may be NULL. + * + * This class owns the returned pointer. + */ + virtual Layout* getLayout(); + + /** + * Set the filter chain on this Appender. + */ + void setFilter(log4cplus::spi::FilterPtr f) { filter = f; } + + /** + * Get the filter chain on this Appender. + */ + log4cplus::spi::FilterPtr getFilter() const { return filter; } + + /** + * Returns this appenders threshold LogLevel. See the {@link + * #setThreshold} method for the meaning of this option. + */ + LogLevel getThreshold() const { return threshold; } + + /** + * Set the threshold LogLevel. All log events with lower LogLevel + * than the threshold LogLevel are ignored by the appender. + * + * In configuration files this option is specified by setting the + * value of the <b>Threshold</b> option to a LogLevel + * string, such as "DEBUG", "INFO" and so on. + */ + void setThreshold(LogLevel th) { threshold = th; } + + /** + * Check whether the message LogLevel is below the appender's + * threshold. If there is no threshold set, then the return value is + * always <code>true</code>. + */ + bool isAsSevereAsThreshold(LogLevel ll) const { + return ((ll != NOT_SET_LOG_LEVEL) && (ll >= threshold)); + } + + protected: + // Methods + /** + * Subclasses of <code>Appender</code> should implement this + * method to perform actual logging. + * @see doAppend method. + */ + virtual void append(const log4cplus::spi::InternalLoggingEvent& event) = 0; + + // Data + /** The layout variable does not need to be set if the appender + * implementation has its own layout. */ + std::auto_ptr<Layout> layout; + + /** Appenders are named. */ + log4cplus::tstring name; + + /** There is no LogLevel threshold filtering by default. */ + LogLevel threshold; + + /** The first filter in the filter chain. Set to <code>null</code> + * initially. */ + log4cplus::spi::FilterPtr filter; + + /** It is assumed and enforced that errorHandler is never null. */ + std::auto_ptr<ErrorHandler> errorHandler; + + /** Is this appender closed? */ + bool closed; + }; + + /** This is a pointer to an Appender. */ + typedef helpers::SharedObjectPtr<Appender> SharedAppenderPtr; + +} // end namespace log4cplus + +#endif // _LOG4CPLUS_APPENDER_HEADER_ + diff --git a/src/vm/log4cplus/config.h.in b/src/vm/log4cplus/config.h.in new file mode 100644 index 0000000..e492cd6 --- /dev/null +++ b/src/vm/log4cplus/config.h.in @@ -0,0 +1,233 @@ +/* include/log4cplus/config.h.in. Generated from configure.in by autoheader. */ + +#ifndef LOG4CPLUS_CONFIG_H + +#define LOG4CPLUS_CONFIG_H + +/* Define to 1 if you have the `clock_gettime' function. */ +#undef HAVE_CLOCK_GETTIME + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the `ftime' function. */ +#undef HAVE_FTIME + +/* */ +#undef HAVE_GETADDRINFO + +/* */ +#undef HAVE_GETHOSTBYNAME_R + +/* Define to 1 if you have the `getpid' function. */ +#undef HAVE_GETPID + +/* Define to 1 if you have the `gettimeofday' function. */ +#undef HAVE_GETTIMEOFDAY + +/* Define to 1 if you have the `gmtime_r' function. */ +#undef HAVE_GMTIME_R + +/* Define to 1 if you have the `htonl' function. */ +#undef HAVE_HTONL + +/* Define to 1 if you have the `htons' function. */ +#undef HAVE_HTONS + +/* Define to 1 if you have the <inttypes.h> header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `advapi32' library (-ladvapi32). */ +#undef HAVE_LIBADVAPI32 + +/* Define to 1 if you have the `kernel32' library (-lkernel32). */ +#undef HAVE_LIBKERNEL32 + +/* Define to 1 if you have the `ws2_32' library (-lws2_32). */ +#undef HAVE_LIBWS2_32 + +/* Define to 1 if you have the `localtime_r' function. */ +#undef HAVE_LOCALTIME_R + +/* Define to 1 if you have the `lstat' function. */ +#undef HAVE_LSTAT + +/* Define to 1 if you have the <memory.h> header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `ntohl' function. */ +#undef HAVE_NTOHL + +/* Define to 1 if you have the `ntohs' function. */ +#undef HAVE_NTOHS + +/* Define if you have POSIX threads libraries and header files. */ +#undef HAVE_PTHREAD + +/* Have PTHREAD_PRIO_INHERIT. */ +#undef HAVE_PTHREAD_PRIO_INHERIT + +/* Define to 1 if you have the `stat' function. */ +#undef HAVE_STAT + +/* Define to 1 if you have the <stdint.h> header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the <string.h> header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the <sys/types.h> header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +/* Defined for --enable-debugging builds. */ +#undef LOG4CPLUS_DEBUGGING + +/* Defined if the compiler understands __declspec(dllimport) or + __attribute__((visibility("default"))) construct. */ +#undef LOG4CPLUS_DECLSPEC_EXPORT + +/* Defined if the compiler understands __declspec(dllexport) or construct. */ +#undef LOG4CPLUS_DECLSPEC_IMPORT + +/* */ +#undef LOG4CPLUS_HAVE_CLOCK_GETTIME + +/* */ +#undef LOG4CPLUS_HAVE_ENAMETOOLONG + +/* */ +#undef LOG4CPLUS_HAVE_ERRNO_H + +/* */ +#undef LOG4CPLUS_HAVE_FTIME + +/* */ +#undef LOG4CPLUS_HAVE_GETADDRINFO + +/* */ +#undef LOG4CPLUS_HAVE_GETHOSTBYNAME_R + +/* */ +#undef LOG4CPLUS_HAVE_GETPID + +/* */ +#undef LOG4CPLUS_HAVE_GETTIMEOFDAY + +/* */ +#undef LOG4CPLUS_HAVE_GMTIME_R + +/* */ +#undef LOG4CPLUS_HAVE_HTONL + +/* */ +#undef LOG4CPLUS_HAVE_HTONS + +/* */ +#undef LOG4CPLUS_HAVE_LOCALTIME_R + +/* */ +#undef LOG4CPLUS_HAVE_LSTAT + +/* */ +#undef LOG4CPLUS_HAVE_NETDB_H + +/* */ +#undef LOG4CPLUS_HAVE_NETINET_IN_H + +/* */ +#undef LOG4CPLUS_HAVE_NTOHL + +/* */ +#undef LOG4CPLUS_HAVE_NTOHS + +/* */ +#undef LOG4CPLUS_HAVE_STAT + +/* */ +#undef LOG4CPLUS_HAVE_STDARG_H + +/* */ +#undef LOG4CPLUS_HAVE_STDIO_H + +/* */ +#undef LOG4CPLUS_HAVE_SYSLOG_H + +/* */ +#undef LOG4CPLUS_HAVE_SYS_SOCKET_H + +/* */ +#undef LOG4CPLUS_HAVE_SYS_STAT_H + +/* */ +#undef LOG4CPLUS_HAVE_SYS_TIMEB_H + +/* */ +#undef LOG4CPLUS_HAVE_SYS_TIME_H + +/* */ +#undef LOG4CPLUS_HAVE_SYS_TYPES_H + +/* */ +#undef LOG4CPLUS_HAVE_TIME_H + +/* */ +#undef LOG4CPLUS_HAVE_UNISTD_H + +/* */ +#undef LOG4CPLUS_HAVE_WCHAR_H + +/* Define if this is a single-threaded library. */ +#undef LOG4CPLUS_SINGLE_THREADED + +/* */ +#undef LOG4CPLUS_USE_PTHREADS + +/* Define for compilers/standard libraries that support more than just the "C" + locale. */ +#undef LOG4CPLUS_WORKING_LOCALE + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#undef LT_OBJDIR + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to necessary symbol if this constant uses a non-standard name on + your system. */ +#undef PTHREAD_CREATE_JOINABLE + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Substitute for socklen_t */ +#undef socklen_t + +#endif // LOG4CPLUS_CONFIG_H diff --git a/src/vm/log4cplus/config.hxx b/src/vm/log4cplus/config.hxx new file mode 100644 index 0000000..85f1649 --- /dev/null +++ b/src/vm/log4cplus/config.hxx @@ -0,0 +1,50 @@ +// Copyright (C) 2009, Vaclav Haisman. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modifica- +// tion, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, +// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- +// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef LOG4CPLUS_CONFIG_HXX +#define LOG4CPLUS_CONFIG_HXX + + +#if defined (_WIN32) +# include <log4cplus/config/win32.h> +#elif (defined(__MWERKS__) && defined(__MACOS__)) +# include <log4cplus/config/macosx.h> +#else +# include <log4cplus/config/defines.hxx> +#endif + +#if !defined(_WIN32) +# if !defined(LOG4CPLUS_SINGLE_THREADED) +# define LOG4CPLUS_USE_PTHREADS +# endif +# if defined (INSIDE_LOG4CPLUS) +# define LOG4CPLUS_EXPORT LOG4CPLUS_DECLSPEC_EXPORT +# else +# define LOG4CPLUS_EXPORT LOG4CPLUS_DECLSPEC_IMPORT +# endif // defined (INSIDE_LOG4CPLUS) +#endif // !_WIN32 + +#include <log4cplus/helpers/thread-config.h> + + +#endif // LOG4CPLUS_CONFIG_HXX diff --git a/src/vm/log4cplus/config/defines.hxx.in b/src/vm/log4cplus/config/defines.hxx.in new file mode 100644 index 0000000..5bd9538 --- /dev/null +++ b/src/vm/log4cplus/config/defines.hxx.in @@ -0,0 +1,113 @@ +#ifndef LOG4CPLUS_CONFIG_DEFINES_HXX +#define LOG4CPLUS_CONFIG_DEFINES_HXX + +/* */ +#undef LOG4CPLUS_HAVE_SYSLOG_H + +/* */ +#undef LOG4CPLUS_HAVE_NETINET_IN_H + +/* */ +#undef LOG4CPLUS_HAVE_SYS_TYPES_H + +/* */ +#undef LOG4CPLUS_HAVE_SYS_SOCKET_H + +/* */ +#undef LOG4CPLUS_HAVE_SYS_STAT_H + +/* */ +#undef LOG4CPLUS_HAVE_SYS_TIMEB_H + +/* */ +#undef LOG4CPLUS_HAVE_SYS_TIME_H + +/* */ +#undef LOG4CPLUS_HAVE_TIME_H + +/* */ +#undef LOG4CPLUS_HAVE_NETDB_H + +/* */ +#undef LOG4CPLUS_HAVE_UNISTD_H + +/* */ +#undef LOG4CPLUS_HAVE_ERRNO_H + +/* */ +#undef LOG4CPLUS_HAVE_STDARG_H + +/* */ +#undef LOG4CPLUS_HAVE_STDIO_H + +/* */ +#undef LOG4CPLUS_HAVE_WCHAR_H + +/* */ +#undef LOG4CPLUS_HAVE_FTIME + +/* */ +#undef LOG4CPLUS_HAVE_GETADDRINFO + +/* */ +#undef LOG4CPLUS_HAVE_GETHOSTBYNAME_R + +/* */ +#undef LOG4CPLUS_HAVE_GETPID + +/* */ +#undef LOG4CPLUS_HAVE_GETTIMEOFDAY + +/* */ +#undef LOG4CPLUS_HAVE_GMTIME_R + +/* */ +#undef LOG4CPLUS_HAVE_HTONL + +/* */ +#undef LOG4CPLUS_HAVE_HTONS + +/* */ +#undef LOG4CPLUS_HAVE_LOCALTIME_R + +/* */ +#undef LOG4CPLUS_HAVE_LSTAT + +/* */ +#undef LOG4CPLUS_HAVE_NTOHL + +/* */ +#undef LOG4CPLUS_HAVE_NTOHS + +/* */ +#undef LOG4CPLUS_HAVE_STAT + +/* Define if this is a single-threaded library. */ +#undef LOG4CPLUS_SINGLE_THREADED + +/* */ +#undef LOG4CPLUS_USE_PTHREADS + +/* Define for compilers/standard libraries that support more than just the "C" + locale. */ +#undef LOG4CPLUS_WORKING_LOCALE + +/* Define to int if undefined. */ +#undef socklen_t + +/* Defined for --enable-debugging builds. */ +#undef LOG4CPLUS_DEBUGGING + +/* Defined if the compiler understands __declspec(export) or __attribute__((export)) construct. */ +#undef LOG4CPLUS_DECLSPEC_EXPORT + +/* Defined if the compiler understands __declspec(import) or __attribute__((import)) construct. */ +#undef LOG4CPLUS_DECLSPEC_IMPORT + +/* Defined if the host OS provides ENAMETOOLONG errno value. */ +#undef LOG4CPLUS_HAVE_ENAMETOOLONG + +/* Define to 1 if you have the `clock_gettime' function. */ +#undef LOG4CPLUS_HAVE_CLOCK_GETTIME + +#endif // LOG4CPLUS_CONFIG_DEFINES_HXX diff --git a/src/vm/log4cplus/config/macosx.h b/src/vm/log4cplus/config/macosx.h new file mode 100644 index 0000000..e526ab5 --- /dev/null +++ b/src/vm/log4cplus/config/macosx.h @@ -0,0 +1,25 @@ +// Module: Log4CPLUS +// File: config-macosx.h +// Created: 7/2003 +// Author: Christopher R. Bailey +// +// +// Copyright (C) Tad E. Smith All rights reserved. +// +// This software is published under the terms of the Apache Software +// License version 1.1, a copy of which has been included with this +// distribution in the LICENSE.APL file. +// + +/** @file */ + +#ifndef LOG4CPLUS_CONFIG_MACOSX_HEADER_ +#define LOG4CPLUS_CONFIG_MACOSX_HEADER_ + +#if (defined(__APPLE__) || (defined(__MWERKS__) && defined(__MACOS__))) + +#define LOG4CPLUS_HAVE_GETTIMEOFDAY 1 +#define socklen_t int + +#endif // MACOSX +#endif // LOG4CPLUS_CONFIG_MACOSX_HEADER_ diff --git a/src/vm/log4cplus/config/win32.h b/src/vm/log4cplus/config/win32.h new file mode 100644 index 0000000..f15de86 --- /dev/null +++ b/src/vm/log4cplus/config/win32.h @@ -0,0 +1,96 @@ +// Module: Log4CPLUS +// File: config-win32.h +// Created: 4/2003 +// Author: Tad E. Smith +// +// +// Copyright 2003-2010 Tad E. Smith +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** @file */ + +#ifndef LOG4CPLUS_CONFIG_WIN32_HEADER_ +#define LOG4CPLUS_CONFIG_WIN32_HEADER_ + +#ifdef _WIN32 +#include <windows.h> + +#if ! defined (_WIN32_WCE) +/* Define if you have the ftime function. */ +#define LOG4CPLUS_HAVE_FTIME 1 +#define LOG4CPLUS_HAVE_ERRNO_H +#define LOG4CPLUS_HAVE_SYS_STAT_H +#endif +#define LOG4CPLUS_HAVE_TIME_H +#define LOG4CPLUS_HAVE_STDLIB_H + +#if defined (_WIN32_WCE) +# define LOG4CPLUS_DLLMAIN_HINSTANCE HANDLE +# undef LOG4CPLUS_HAVE_NT_EVENT_LOG +#else +# define LOG4CPLUS_DLLMAIN_HINSTANCE HINSTANCE +# define LOG4CPLUS_HAVE_NT_EVENT_LOG +# define LOG4CPLUS_HAVE_WIN32_CONSOLE +#endif + +// Enable Win32DebugAppender +#define LOG4CPLUS_HAVE_OUTPUTDEBUGSTRING + +// log4cplus_EXPORTS is used by the CMake build system. DLL_EXPORT is +// used by the autotools build system. +#if (defined (log4cplus_EXPORTS) || defined (DLL_EXPORT)) \ + && ! defined (LOG4CPLUS_STATIC) +# undef LOG4CPLUS_BUILD_DLL +# define LOG4CPLUS_BUILD_DLL +#endif + +#if ! defined (LOG4CPLUS_BUILD_DLL) +# undef LOG4CPLUS_STATIC +# define LOG4CPLUS_STATIC +#endif + +#if defined (LOG4CPLUS_STATIC) && defined (LOG4CPLUS_BUILD_DLL) +# error LOG4CPLUS_STATIC and LOG4CPLUS_BUILD_DLL cannot be defined both. +#endif + +#if defined (LOG4CPLUS_BUILD_DLL) +# if defined (INSIDE_LOG4CPLUS) +# define LOG4CPLUS_EXPORT __declspec(dllexport) +# else +# define LOG4CPLUS_EXPORT __declspec(dllimport) +# endif +#else +# define LOG4CPLUS_EXPORT +#endif + +#ifndef LOG4CPLUS_SINGLE_THREADED +# define LOG4CPLUS_USE_WIN32_THREADS +#endif + +#if defined(_MSC_VER) + // Warning about: identifier was truncated to '255' characters in the debug information +# pragma warning( disable : 4786 ) + // Warning about: <type1> needs to have dll-interface to be used by clients of class <type2> +# pragma warning( disable : 4251 ) + +# if _MSC_VER >= 1400 && ! defined (_WIN32_WCE) +# define LOG4CPLUS_WORKING_LOCALE +# endif + +#endif + + +#endif // _WIN32 +#endif // LOG4CPLUS_CONFIG_WIN32_HEADER_ + diff --git a/src/vm/log4cplus/configurator.h b/src/vm/log4cplus/configurator.h new file mode 100644 index 0000000..62de401 --- /dev/null +++ b/src/vm/log4cplus/configurator.h @@ -0,0 +1,340 @@ +// Module: Log4CPLUS +// File: configurator.h +// Created: 3/2003 +// Author: Tad E. Smith +// +// +// Copyright 2003-2010 Tad E. Smith +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** @file */ + +#ifndef _CONFIGURATOR_HEADER_ +#define _CONFIGURATOR_HEADER_ + +#include <log4cplus/config.hxx> +#include <log4cplus/appender.h> +#include <log4cplus/hierarchy.h> +#include <log4cplus/logger.h> +#include <log4cplus/helpers/logloguser.h> +#include <log4cplus/helpers/pointer.h> +#include <log4cplus/helpers/property.h> + +#include <map> + + +namespace log4cplus +{ + + /** + * Provides configuration from an external file. See configure() for + * the expected format. + * + * <em>All option values admit variable substitution.</em> For + * example, if <code>userhome</code> environment property is set to + * <code>/home/xyz</code> and the File option is set to the string + * <code>${userhome}/test.log</code>, then File option will be + * interpreted as the string <code>/home/xyz/test.log</code>. + * + * The syntax of variable substitution is similar to that of UNIX + * shells. The string between an opening <b>"${"</b> and + * closing <b>"}"</b> is interpreted as a key. Its value is + * searched in the environment properties. The corresponding value replaces + * the ${variableName} sequence. + */ + class LOG4CPLUS_EXPORT PropertyConfigurator + : protected log4cplus::helpers::LogLogUser + { + public: + enum PCFlags + { + fRecursiveExpansion = 0x0001, + fShadowEnvironment = 0x0002, + fAllowEmptyVars = 0x0004 + }; + + // ctor and dtor + PropertyConfigurator(const log4cplus::tstring& propertyFile, + Hierarchy& h = Logger::getDefaultHierarchy(), unsigned flags = 0); + PropertyConfigurator(const log4cplus::helpers::Properties& props, + Hierarchy& h = Logger::getDefaultHierarchy(), unsigned flags = 0); + PropertyConfigurator(log4cplus::tistream& propertyStream, + Hierarchy& h = Logger::getDefaultHierarchy(), unsigned flags = 0); + virtual ~PropertyConfigurator(); + + /** + * This method eliminates the need to create a temporary + * <code>PropertyConfigurator</code> to configure log4cplus. + * It is equivalent to the following:<br> + * <code> + * PropertyConfigurator config("filename"); + * config.configure(); + * </code> + */ + static void doConfigure(const log4cplus::tstring& configFilename, + Hierarchy& h = Logger::getDefaultHierarchy(), unsigned flags = 0); + + /** + * Read configuration from a file. <b>The existing configuration is + * not cleared nor reset.</b> If you require a different behavior, + * then call {@link Hierarchy::resetConfiguration + * resetConfiguration} method before calling + * <code>doConfigure</code>. + * + * The configuration file consists of statements in the format + * <code>key=value</code>. The syntax of different configuration + * elements are discussed below. + * + * <h3>Appender configuration</h3> + * + * Appender configuration syntax is: + * <pre> + * # For appender named <i>appenderName</i>, set its class. + * # Note: The appender name can contain dots. + * log4cplus.appender.appenderName=fully.qualified.name.of.appender.class + * + * # Set appender specific options. + * log4cplus.appender.appenderName.option1=value1 + * ... + * log4cplus.appender.appenderName.optionN=valueN + * </pre> + * + * For each named appender you can configure its {@link Layout}. The + * syntax for configuring an appender's layout is: + * <pre> + * log4cplus.appender.appenderName.layout=fully.qualified.name.of.layout.class + * log4cplus.appender.appenderName.layout.option1=value1 + * .... + * log4cplus.appender.appenderName.layout.optionN=valueN + * </pre> + * + * <h3>Configuring loggers</h3> + * + * The syntax for configuring the root logger is: + * <pre> + * log4cplus.rootLogger=[LogLevel], appenderName, appenderName, ... + * </pre> + * + * This syntax means that an optional <em>LogLevel value</em> can + * be supplied followed by appender names separated by commas. + * + * The LogLevel value can consist of the string values FATAL, + * ERROR, WARN, INFO, DEBUG or a <em>custom LogLevel</em> value. + * + * If a LogLevel value is specified, then the root LogLevel is set + * to the corresponding LogLevel. If no LogLevel value is specified, + * then the root LogLevel remains untouched. + * + * The root logger can be assigned multiple appenders. + * + * Each <i>appenderName</i> (separated by commas) will be added to + * the root logger. The named appender is defined using the + * appender syntax defined above. + * + * For non-root loggers the syntax is almost the same: + * <pre> + * log4cplus.logger.logger_name=[LogLevel|INHERITED], appenderName, appenderName, ... + * </pre> + * + * The meaning of the optional LogLevel value is discussed above + * in relation to the root logger. In addition however, the value + * INHERITED can be specified meaning that the named logger should + * inherit its LogLevel from the logger hierarchy. + * + * By default loggers inherit their LogLevel from the + * hierarchy. However, if you set the LogLevel of a logger and + * later decide that that logger should inherit its LogLevel, then + * you should specify INHERITED as the value for the LogLevel value. + * + * Similar to the root logger syntax, each <i>appenderName</i> + * (separated by commas) will be attached to the named logger. + * + * See the <a href="../../../../manual.html#additivity">appender + * additivity rule</a> in the user manual for the meaning of the + * <code>additivity</code> flag. + * + * The user can override any of the {@link + * Hierarchy#disable} family of methods by setting the a key + * "log4cplus.disableOverride" to <code>true</code> or any value other + * than false. As in <pre>log4cplus.disableOverride=true </pre> + * + * <h3>Example</h3> + * + * An example configuration is given below. + * + * <pre> + * + * # Set options for appender named "A1". + * # Appender "A1" will be a SyslogAppender + * log4cplus.appender.A1=log4cplus::SyslogAppender + * + * # The syslog daemon resides on www.abc.net + * log4cplus.appender.A1.SyslogHost=www.abc.net + * + * # A1's layout is a PatternLayout, using the conversion pattern + * # <b>%r %-5p %c{2} %M.%L %x - %m\n</b>. Thus, the log output will + * # include # the relative time since the start of the application in + * # milliseconds, followed by the LogLevel of the log request, + * # followed by the two rightmost components of the logger name, + * # followed by the callers method name, followed by the line number, + * # the nested disgnostic context and finally the message itself. + * # Refer to the documentation of {@link PatternLayout} for further information + * # on the syntax of the ConversionPattern key. + * log4cplus.appender.A1.layout=log4cplus::PatternLayout + * log4cplus.appender.A1.layout.ConversionPattern=%-4r %-5p %c{2} %M.%L %x - %m\n + * + * # Set options for appender named "A2" + * # A2 should be a RollingFileAppender, with maximum file size of 10 MB + * # using at most one backup file. A2's layout is TTCC, using the + * # ISO8061 date format with context printing enabled. + * log4cplus.appender.A2=log4cplus::RollingFileAppender + * log4cplus.appender.A2.MaxFileSize=10MB + * log4cplus.appender.A2.MaxBackupIndex=1 + * log4cplus.appender.A2.layout=log4cplus::TTCCLayout + * log4cplus.appender.A2.layout.ContextPrinting=enabled + * log4cplus.appender.A2.layout.DateFormat=ISO8601 + * + * # Root logger set to DEBUG using the A2 appender defined above. + * log4cplus.rootLogger=DEBUG, A2 + * + * # Logger definitions: + * # The SECURITY logger inherits is LogLevel from root. However, it's output + * # will go to A1 appender defined above. It's additivity is non-cumulative. + * log4cplus.logger.SECURITY=INHERIT, A1 + * log4cplus.additivity.SECURITY=false + * + * # Only warnings or above will be logged for the logger "SECURITY.access". + * # Output will go to A1. + * log4cplus.logger.SECURITY.access=WARN + * + * + * # The logger "class.of.the.day" inherits its LogLevel from the + * # logger hierarchy. Output will go to the appender's of the root + * # logger, A2 in this case. + * log4cplus.logger.class.of.the.day=INHERIT + * </pre> + * + * Refer to the <b>setOption</b> method in each Appender and + * Layout for class specific options. + * + * Use the <code>#</code> character at the beginning of a line + * for comments. + */ + virtual void configure(); + + /** + * \return The return value is reference to Properties + * container of properties with the <code>"log4cplus."</code> + * prefix removed and references to other properties and/or + * environment variables expanded. + */ + log4cplus::helpers::Properties const & getProperties () const; + + /** + * \return The return value is a reference to log4cplus::tstring + * containing filename of properties source file. It will be + * string "UNAVAILABLE" if the PropertyConfigurator instance has been + * constructed using one of the other constructors that do not take + * filename as parameter. + */ + log4cplus::tstring const & getPropertyFilename () const; + + protected: + // Methods + void init(); // called by the ctor + void reconfigure(); + void replaceEnvironVariables(); + void configureLoggers(); + void configureLogger(log4cplus::Logger logger, const log4cplus::tstring& config); + void configureAppenders(); + void configureAdditivity(); + + virtual Logger getLogger(const log4cplus::tstring& name); + virtual void addAppender(Logger &logger, log4cplus::SharedAppenderPtr& appender); + + // Types + typedef std::map<log4cplus::tstring, log4cplus::SharedAppenderPtr> AppenderMap; + + // Data + Hierarchy& h; + log4cplus::tstring propertyFilename; + log4cplus::helpers::Properties properties; + AppenderMap appenders; + unsigned flags; + + private: + // Disable copy + PropertyConfigurator(const PropertyConfigurator&); + PropertyConfigurator& operator=(PropertyConfigurator&); + }; + + + + /** + * Use this class to quickly configure the package. For file based + * configuration see PropertyConfigurator. BasicConfigurator + * automatically attaches ConsoleAppender to + * <code>rootLogger</code>, with output going to standard output, + * using DEBUG LogLevel value. + */ + class LOG4CPLUS_EXPORT BasicConfigurator : public PropertyConfigurator { + public: + // ctor and dtor + BasicConfigurator(Hierarchy& h = Logger::getDefaultHierarchy()); + virtual ~BasicConfigurator(); + + /** + * This method eliminates the need to create a temporary + * <code>BasicConfigurator</code> object to configure log4cplus. + * It is equivalent to the following:<br> + * <code><pre> + * BasicConfigurator config; + * config.configure(); + * </pre></code> + */ + static void doConfigure(Hierarchy& h = Logger::getDefaultHierarchy()); + + private: + // Disable copy + BasicConfigurator(const BasicConfigurator&); + BasicConfigurator& operator=(BasicConfigurator&); + }; + + +#if !defined(LOG4CPLUS_SINGLE_THREADED) + // Forward Declarations + class ConfigurationWatchDogThread; + + + class LOG4CPLUS_EXPORT ConfigureAndWatchThread { + public: + // ctor and dtor + ConfigureAndWatchThread(const log4cplus::tstring& propertyFile, + unsigned int millis = 60 * 1000); + virtual ~ConfigureAndWatchThread(); + + private: + // Disallow copying of instances of this class + ConfigureAndWatchThread(const ConfigureAndWatchThread&); + ConfigureAndWatchThread& operator=(const ConfigureAndWatchThread&); + + // Data + ConfigurationWatchDogThread * watchDogThread; + }; +#endif + +} // end namespace log4cplus + +#endif // _CONFIGURATOR_HEADER_ + diff --git a/src/vm/log4cplus/consoleappender.h b/src/vm/log4cplus/consoleappender.h new file mode 100644 index 0000000..b76ad95 --- /dev/null +++ b/src/vm/log4cplus/consoleappender.h @@ -0,0 +1,74 @@ +// Module: Log4CPLUS +// File: consoleappender.h +// Created: 6/2001 +// Author: Tad E. Smith +// +// +// Copyright 2001-2009 Tad E. Smith +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** @file */ + +#ifndef _LOG4CPLUS_CONSOLE_APPENDER_HEADER_ +#define _LOG4CPLUS_CONSOLE_APPENDER_HEADER_ + +#include <log4cplus/config.hxx> +#include <log4cplus/appender.h> + +namespace log4cplus { + /** + * ConsoleAppender appends log events to <code>std::cout</code> or + * <code>std::cerr</code> using a layout specified by the + * user. The default target is <code>std::cout</code>. + * + * <h3>Properties</h3> + * <dl> + * <dt><tt>logToStdErr</tt></dt> + * <dd>When it is set true, the output stream will be + * <code>std::cerr</code> instead of <code>std::cout</code>.</dd> + * + * <dt><tt>ImmediateFlush</tt></dt> + * <dd>When it is set true, output stream will be flushed after + * each appended event.</dd> + * + * </dl> + */ + class LOG4CPLUS_EXPORT ConsoleAppender : public Appender { + public: + // Ctors + ConsoleAppender(bool logToStdErr = false, bool immediateFlush = false); + ConsoleAppender(const log4cplus::helpers::Properties properties); + + // Dtor + ~ConsoleAppender(); + + // Methods + virtual void close(); + + protected: + virtual void append(const spi::InternalLoggingEvent& event); + + // Data + bool logToStdErr; + /** + * Immediate flush means that the underlying output stream + * will be flushed at the end of each append operation. + */ + bool immediateFlush; + }; + +} // end namespace log4cplus + +#endif // _LOG4CPLUS_CONSOLE_APPENDER_HEADER_ + diff --git a/src/vm/log4cplus/fileappender.h b/src/vm/log4cplus/fileappender.h new file mode 100644 index 0000000..785f0b0 --- /dev/null +++ b/src/vm/log4cplus/fileappender.h @@ -0,0 +1,237 @@ +// Module: Log4CPLUS +// File: fileappender.h +// Created: 6/2001 +// Author: Tad E. Smith +// +// +// Copyright 2001-2010 Tad E. Smith +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** @file */ + +#ifndef _LOG4CPLUS_FILE_APPENDER_HEADER_ +#define _LOG4CPLUS_FILE_APPENDER_HEADER_ + +#include <log4cplus/config.hxx> +#include <log4cplus/appender.h> +#include <log4cplus/fstreams.h> +#include <log4cplus/helpers/property.h> +#include <log4cplus/helpers/timehelper.h> + +#if defined(__DECCXX) +# define LOG4CPLUS_OPEN_MODE_TYPE LOG4CPLUS_FSTREAM_NAMESPACE::ios::open_mode +#else +# define LOG4CPLUS_OPEN_MODE_TYPE LOG4CPLUS_FSTREAM_NAMESPACE::ios::openmode +#endif + +namespace log4cplus { + + /** + * Appends log events to a file. + * + * <h3>Properties</h3> + * <dl> + * <dt><tt>File</tt></dt> + * <dd>This property specifies output file name.</dd> + * + * <dt><tt>ImmediateFlush</tt></dt> + * <dd>When it is set true, output stream will be flushed after + * each appended event.</dd> + * + * <dt><tt>Append</tt></dt> + * <dd>When it is set true, output file will be appended to + * instead of being truncated at opening.</dd> + * + * <dt><tt>ReopenDelay</tt></dt> + * <dd>This property sets a delay after which the appender will + * try to reopen log file again, after last logging failure. The + * default value is 1 second. Setting the delay to 0 makes the + * appender not to try reopening the stream. + * </dd> + * + * <dt><tt>BufferSize</tt></dt> + * <dd>Non-zero value of this property sets up buffering of output + * stream using a buffer of given size. + * </dd> + * </dl> + */ + class LOG4CPLUS_EXPORT FileAppender : public Appender { + public: + // Ctors + FileAppender(const log4cplus::tstring& filename, + LOG4CPLUS_OPEN_MODE_TYPE mode = LOG4CPLUS_FSTREAM_NAMESPACE::ios::trunc, + bool immediateFlush = true); + FileAppender(const log4cplus::helpers::Properties& properties, + LOG4CPLUS_OPEN_MODE_TYPE mode = LOG4CPLUS_FSTREAM_NAMESPACE::ios::trunc); + + // Dtor + virtual ~FileAppender(); + + // Methods + virtual void close(); + + protected: + virtual void append(const spi::InternalLoggingEvent& event); + + void open(LOG4CPLUS_OPEN_MODE_TYPE mode); + bool reopen(); + + // Data + /** + * Immediate flush means that the underlying writer or output stream + * will be flushed at the end of each append operation. Immediate + * flush is slower but ensures that each append request is actually + * written. If <code>immediateFlush</code> is set to + * <code>false</code>, then there is a good chance that the last few + * logs events are not actually written to persistent media if and + * when the application crashes. + * + * The <code>immediateFlush</code> variable is set to + * <code>true</code> by default. + */ + bool immediateFlush; + + /** + * When any append operation fails, <code>reopenDelay</code> says + * for how many seconds the next attempt to re-open the log file and + * resume logging will be delayed. If <code>reopenDelay</code> is zero, + * each failed append operation will cause log file to be re-opened. + * By default, <code>reopenDelay</code> is 1 second. + */ + int reopenDelay; + + unsigned long bufferSize; + log4cplus::tchar * buffer; + + log4cplus::tofstream out; + log4cplus::tstring filename; + + log4cplus::helpers::Time reopen_time; + + private: + void init(const log4cplus::tstring& filename, + LOG4CPLUS_OPEN_MODE_TYPE mode); + + // Disallow copying of instances of this class + FileAppender(const FileAppender&); + FileAppender& operator=(const FileAppender&); + }; + + + + /** + * RollingFileAppender extends FileAppender to backup the log + * files when they reach a certain size. + * + * <h3>Properties</h3> + * <p>Properties additional to {@link FileAppender}'s properties: + * + * <dl> + * <dt><tt>MaxFileSize</tt></dt> + * <dd>This property specifies maximal size of output file. The + * value is in bytes. It is possible to use <tt>MB</tt> and + * <tt>KB</tt> suffixes to specify the value in megabytes or + * kilobytes instead.</dd> + * + * <dt><tt>MaxBackupIndex</tt></dt> + * <dd>This property limits the number of backup output + * files; e.g. how many <tt>log.1</tt>, <tt>log.2</tt> etc. files + * will be kept.</dd> + * </dl> + */ + class LOG4CPLUS_EXPORT RollingFileAppender : public FileAppender { + public: + // Ctors + RollingFileAppender(const log4cplus::tstring& filename, + long maxFileSize = 10*1024*1024, // 10 MB + int maxBackupIndex = 1, + bool immediateFlush = true); + RollingFileAppender(const log4cplus::helpers::Properties& properties); + + // Dtor + virtual ~RollingFileAppender(); + + protected: + virtual void append(const spi::InternalLoggingEvent& event); + void rollover(); + + // Data + long maxFileSize; + int maxBackupIndex; + + private: + void init(long maxFileSize, int maxBackupIndex); + }; + + + + enum DailyRollingFileSchedule { MONTHLY, WEEKLY, DAILY, + TWICE_DAILY, HOURLY, MINUTELY}; + + /** + * DailyRollingFileAppender extends {@link FileAppender} so that the + * underlying file is rolled over at a user chosen frequency. + * + * <h3>Properties</h3> + * <p>Properties additional to {@link FileAppender}'s properties: + * + * <dl> + * <dt><tt>Schedule</tt></dt> + * <dd>This property specifies rollover schedule. The possible + * values are <tt>MONTHLY</tt>, <tt>WEEKLY</tt>, <tt>DAILY</tt>, + * <tt>TWICE_DAILY</tt>, <tt>HOURLY</tt> and + * <tt>MINUTELY</tt>.</dd> + * + * <dt><tt>MaxBackupIndex</tt></dt> + * <dd>This property limits how many backup files are kept per + * single logging period; e.g. how many <tt>log.2009-11-07.1</tt>, + * <tt>log.2009-11-07.2</tt> etc. files are kept.</dd> + * + * </dl> + */ + class LOG4CPLUS_EXPORT DailyRollingFileAppender : public FileAppender { + public: + // Ctors + DailyRollingFileAppender(const log4cplus::tstring& filename, + DailyRollingFileSchedule schedule = DAILY, + bool immediateFlush = true, + int maxBackupIndex = 10); + DailyRollingFileAppender(const log4cplus::helpers::Properties& properties); + + // Dtor + virtual ~DailyRollingFileAppender(); + + // Methods + virtual void close(); + + protected: + virtual void append(const spi::InternalLoggingEvent& event); + void rollover(); + log4cplus::helpers::Time calculateNextRolloverTime(const log4cplus::helpers::Time& t) const; + log4cplus::tstring getFilename(const log4cplus::helpers::Time& t) const; + + // Data + DailyRollingFileSchedule schedule; + log4cplus::tstring scheduledFilename; + log4cplus::helpers::Time nextRolloverTime; + int maxBackupIndex; + + private: + void init(DailyRollingFileSchedule schedule); + }; + +} // end namespace log4cplus + +#endif // _LOG4CPLUS_FILE_APPENDER_HEADER_ + diff --git a/src/vm/log4cplus/fstreams.h b/src/vm/log4cplus/fstreams.h new file mode 100644 index 0000000..5a25790 --- /dev/null +++ b/src/vm/log4cplus/fstreams.h @@ -0,0 +1,50 @@ +// Module: Log4CPLUS +// File: fstreams.h +// Created: 4/2003 +// Author: Tad E. Smith +// +// +// Copyright 2003-2009 Tad E. Smith +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** @file */ + +#ifndef LOG4CPLUS_FSTREAMS_HEADER_ +#define LOG4CPLUS_FSTREAMS_HEADER_ + +#include <log4cplus/config.hxx> + +#include <fstream> + +#if defined(__DECCXX) && !defined(__USE_STD_IOSTREAM) +# define LOG4CPLUS_FSTREAM_NAMESPACE +#else +# define LOG4CPLUS_FSTREAM_NAMESPACE std +#endif + + +#ifdef UNICODE + namespace log4cplus { + typedef LOG4CPLUS_FSTREAM_NAMESPACE::wofstream tofstream; + typedef LOG4CPLUS_FSTREAM_NAMESPACE::wifstream tifstream; + } +#else + namespace log4cplus { + typedef LOG4CPLUS_FSTREAM_NAMESPACE::ofstream tofstream; + typedef LOG4CPLUS_FSTREAM_NAMESPACE::ifstream tifstream; + } +#endif // UNICODE + +#endif // LOG4CPLUS_FSTREAMS_HEADER_ + diff --git a/src/vm/log4cplus/helpers/appenderattachableimpl.h b/src/vm/log4cplus/helpers/appenderattachableimpl.h new file mode 100644 index 0000000..710232e --- /dev/null +++ b/src/vm/log4cplus/helpers/appenderattachableimpl.h @@ -0,0 +1,112 @@ +// Module: Log4CPLUS +// File: appenderattachableimpl.h +// Created: 6/2001 +// Author: Tad E. Smith +// +// +// Copyright 2001-2009 Tad E. Smith +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** @file */ + +#ifndef _LOG4CPLUS_HELPERS_APPENDER_ATTACHABLE_IMPL_HEADER_ +#define _LOG4CPLUS_HELPERS_APPENDER_ATTACHABLE_IMPL_HEADER_ + +#include <log4cplus/config.hxx> +#include <log4cplus/layout.h> +#include <log4cplus/tstring.h> +#include <log4cplus/helpers/logloguser.h> +#include <log4cplus/helpers/pointer.h> +#include <log4cplus/helpers/threads.h> +#include <log4cplus/spi/appenderattachable.h> + +#include <memory> +#include <vector> + + +namespace log4cplus { + namespace helpers { + + /** + * This Interface is for attaching Appenders to objects. + */ + class LOG4CPLUS_EXPORT AppenderAttachableImpl + : public log4cplus::spi::AppenderAttachable, + protected log4cplus::helpers::LogLogUser + { + public: + // Data + LOG4CPLUS_MUTEX_PTR_DECLARE appender_list_mutex; + + // Ctors + AppenderAttachableImpl(); + + // Dtor + virtual ~AppenderAttachableImpl(); + + // Methods + /** + * Add an appender. If the appender is already in the list in + * won't be added again. + */ + virtual void addAppender(SharedAppenderPtr newAppender); + + /** + * Get all previously added appenders as an vectory. + */ + virtual SharedAppenderPtrList getAllAppenders(); + + /** + * Look for an attached appender named as <code>name</code>. + * + * Return the appender with that name if in the list. Return null + * otherwise. + */ + virtual SharedAppenderPtr getAppender(const log4cplus::tstring& name); + + /** + * Remove all previously added appenders. + */ + virtual void removeAllAppenders(); + + /** + * Remove the appender passed as parameter from the list of appenders. + */ + virtual void removeAppender(SharedAppenderPtr appender); + + /** + * Remove the appender with the name passed as parameter from the + * list of appenders. + */ + virtual void removeAppender(const log4cplus::tstring& name); + + /** + * Call the <code>doAppend</code> method on all attached appenders. + */ + int appendLoopOnAppenders(const spi::InternalLoggingEvent& event) const; + + protected: + // Types + typedef std::vector<SharedAppenderPtr> ListType; + + // Data + /** Array of appenders. */ + ListType appenderList; + }; // end class AppenderAttachableImpl + + } // end namespace helpers +} // end namespace log4cplus + +#endif // _LOG4CPLUS_HELPERS_APPENDER_ATTACHABLE_IMPL_HEADER_ + diff --git a/src/vm/log4cplus/helpers/loglog.h b/src/vm/log4cplus/helpers/loglog.h new file mode 100644 index 0000000..595ab9a --- /dev/null +++ b/src/vm/log4cplus/helpers/loglog.h @@ -0,0 +1,113 @@ +// Module: Log4CPLUS +// File: loglog.h +// Created: 6/2001 +// Author: Tad E. Smith +// +// +// Copyright 2001-2009 Tad E. Smith +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** @file */ + +#ifndef _LOG4CPLUS_HELPERS_LOGLOG +#define _LOG4CPLUS_HELPERS_LOGLOG + +#include <log4cplus/config.hxx> +#include <log4cplus/tstring.h> +#include <log4cplus/helpers/pointer.h> +#include <log4cplus/helpers/threads.h> + + +namespace log4cplus { + namespace helpers { + + /** + * This class used to output log statements from within the log4cplus package. + * + * Log4cplus components cannot make log4cplus logging calls. However, it is + * sometimes useful for the user to learn about what log4cplus is + * doing. You can enable log4cplus internal logging by defining the + * <b>log4cplus.configDebug</b> variable. + * + * All log4cplus internal debug calls go to <code>cout</code> + * where as internal error messages are sent to + * <code>cerr</code>. All internal messages are prepended with + * the string "log4clus: ". + */ + class LOG4CPLUS_EXPORT LogLog + : public virtual log4cplus::helpers::SharedObject + { + public: + // Static methods + /** + * Returns a reference to the <code>LogLog</code> singleton. + */ + static log4cplus::helpers::SharedObjectPtr<LogLog> getLogLog(); + + + /** + * Allows to enable/disable log4cplus internal logging. + */ + void setInternalDebugging(bool enabled); + + /** + * In quite mode no LogLog generates strictly no output, not even + * for errors. + * + * @param quietMode A true for not + */ + void setQuietMode(bool quietMode); + + /** + * This method is used to output log4cplus internal debug + * statements. Output goes to <code>std::cout</code>. + */ + void debug(const log4cplus::tstring& msg); + + /** + * This method is used to output log4cplus internal error + * statements. There is no way to disable error statements. + * Output goes to <code>std::cerr</code>. + */ + void error(const log4cplus::tstring& msg); + + /** + * This method is used to output log4cplus internal warning + * statements. There is no way to disable warning statements. + * Output goes to <code>std::cerr</code>. + */ + void warn(const log4cplus::tstring& msg); + + // Dtor + virtual ~LogLog(); + + // Data + LOG4CPLUS_MUTEX_PTR_DECLARE mutex; + + private: + // Data + bool debugEnabled; + bool quietMode; + + // Ctors + LogLog(); + LogLog(const LogLog&); + }; + + } // end namespace helpers +} // end namespace log4cplus + + +#endif // _LOG4CPLUS_HELPERS_LOGLOG + diff --git a/src/vm/log4cplus/helpers/logloguser.h b/src/vm/log4cplus/helpers/logloguser.h new file mode 100644 index 0000000..2cbcb15 --- /dev/null +++ b/src/vm/log4cplus/helpers/logloguser.h @@ -0,0 +1,62 @@ +// Module: Log4CPLUS +// File: logloguser.h +// Created: 6/2003 +// Author: Tad E. Smith +// +// +// Copyright 2003-2009 Tad E. Smith +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** @file */ + +#ifndef _LOG4CPLUS_HELPERS_LOGLOG_USER +#define _LOG4CPLUS_HELPERS_LOGLOG_USER + +#include <log4cplus/config.hxx> + + +namespace log4cplus { + namespace helpers { + // forward declarations + class LogLog; + + /** + * This class used to simplify the use of the LogLog class. Any class + * that uses the LogLog class should extend this class and retrieve + * their reference to LogLog using the method provided. + */ + class LOG4CPLUS_EXPORT LogLogUser { + public: + // ctor and dtor + LogLogUser(); + LogLogUser(const LogLogUser&); + virtual ~LogLogUser(); + + // public methods + LogLog& getLogLog() const; + + // operators + LogLogUser& operator=(const LogLogUser& rhs); + + private: + // Data + void* loglogRef; + }; + + } // end namespace helpers +} // end namespace log4cplus + + +#endif // _LOG4CPLUS_HELPERS_LOGLOG_USER + diff --git a/src/vm/log4cplus/helpers/pointer.h b/src/vm/log4cplus/helpers/pointer.h new file mode 100644 index 0000000..52c1989 --- /dev/null +++ b/src/vm/log4cplus/helpers/pointer.h @@ -0,0 +1,160 @@ +// Module: Log4CPLUS +// File: pointer.h +// Created: 6/2001 +// Author: Tad E. Smith +// +// +// Copyright 2001-2009 Tad E. Smith +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +// Note: Some of this code uses ideas from "More Effective C++" by Scott +// Myers, Addison Wesley Longmain, Inc., (c) 1996, Chapter 29, pp. 183-213 +// + +/** @file */ + +#ifndef _LOG4CPLUS_HELPERS_POINTERS_HEADER_ +#define _LOG4CPLUS_HELPERS_POINTERS_HEADER_ + +#include <log4cplus/config.hxx> +#include <memory> +#include <stdexcept> +#include <string> +#include <algorithm> +#include <cassert> + + +namespace log4cplus { + namespace helpers { + + /****************************************************************************** + * Class SharedObject (from pp. 204-205) * + ******************************************************************************/ + + class LOG4CPLUS_EXPORT SharedObject + { + public: + void addReference() const; + void removeReference() const; + + protected: + // Ctor + SharedObject() + : access_mutex(LOG4CPLUS_MUTEX_CREATE) + , count(0) + { } + + SharedObject(const SharedObject&) + : access_mutex(LOG4CPLUS_MUTEX_CREATE) + , count(0) + { } + + // Dtor + virtual ~SharedObject(); + + // Operators + SharedObject& operator=(const SharedObject&) { return *this; } + + public: + LOG4CPLUS_MUTEX_PTR_DECLARE access_mutex; + + private: + mutable int count; + }; + + + /****************************************************************************** + * Template Class SharedObjectPtr (from pp. 203, 206) * + ******************************************************************************/ + template<class T> + class SharedObjectPtr + { + public: + ... [truncated message content] |