You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by ca...@apache.org on 2004/12/13 06:05:14 UTC
cvs commit: logging-log4cxx/src hierarchy.cpp logger.cpp logmanager.cpp nteventlogappender.cpp relativetimedateformat.cpp simpledateformat.cpp socketinputstream.cpp stringhelper.cpp transcoder.cpp writerappender.cpp
carnold 2004/12/12 21:05:14
Modified: include/log4cxx file.h level.h logger.h portability.h
include/log4cxx/helpers aprinitializer.h cacheddateformat.h
condition.h dateformat.h mutex.h pool.h
relativetimedateformat.h simpledateformat.h
strftimedateformat.h stringhelper.h thread.h
timezone.h transcoder.h
include/log4cxx/nt nteventlogappender.h
include/log4cxx/spi loggingevent.h
performance main.cpp
src hierarchy.cpp logger.cpp logmanager.cpp
nteventlogappender.cpp relativetimedateformat.cpp
simpledateformat.cpp socketinputstream.cpp
stringhelper.cpp transcoder.cpp writerappender.cpp
Log:
LOGCXX-10: tchar.h conflict: use log4cxx_time_t in place of apr_time_t
Revision Changes Path
1.3 +2 -2 logging-log4cxx/include/log4cxx/file.h
Index: file.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/file.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- file.h 12 Dec 2004 05:53:56 -0000 1.2
+++ file.h 13 Dec 2004 05:05:12 -0000 1.3
@@ -47,7 +47,7 @@
bool exists() const;
size_t length() const;
- apr_time_t lastModified() const;
+ log4cxx_time_t lastModified() const;
inline const LogString& getName() const {
return internalName;
}
@@ -58,7 +58,7 @@
LogString read(apr_pool_t* pool) const;
- apr_status_t write(const LogString& src, apr_pool_t* p) const;
+ log4cxx_status_t write(const LogString& src, apr_pool_t* p) const;
private:
LogString internalName;
1.17 +18 -3 logging-log4cxx/include/log4cxx/level.h
Index: level.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/level.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- level.h 12 Dec 2004 05:53:57 -0000 1.16
+++ level.h 13 Dec 2004 05:05:13 -0000 1.17
@@ -23,11 +23,17 @@
#define _LOG4CXX_LEVEL_H
//
-// ERROR may be defined by windows.h and will conflict
-// with the defintion of log4cxx::Level::ERROR below.
+// ERROR and DEBUG may be defined by Microsoft Platform headers and will conflict
+// with the defintion of log4cxx::Level::ERROR and log4cxx::Level::DEBUG below.
// log4cxx::level::getError() can be used in place of log4cxx::Level::ERROR.
#if defined(ERROR)
-#error Preprocessor macro ERROR defined (likely by windows.h). Include windows.h later or #undef ERROR.
+#define LOGCXX_PLATFORM_ERROR ERROR
+#undef ERROR
+#endif
+
+#if defined(DEBUG)
+#define LOGCXX_PLATFORM_DEBUG DEBUG
+#undef DEBUG
#endif
@@ -233,5 +239,14 @@
#define IMPLEMENT_LOG4CXX_LEVEL(level) \
IMPLEMENT_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(level, Class##level)
+#if defined(LOG4CXX_PLATFORM_ERROR)
+#define ERROR LOGCXX_PLATFORM_ERROR
+#undef LOG4CXX_PLATFORM_ERROR
+#endif
+
+#if defined(LOG4CXX_PLATFORM_DEBUG)
+#define DEBUG LOGCXX_PLATFORM_DEBUG
+#undef LOG4CXX_PLATFORM_DEBUG
+#endif
#endif //_LOG4CXX_LEVEL_H
1.29 +8 -6 logging-log4cxx/include/log4cxx/logger.h
Index: logger.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/logger.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- logger.h 11 Dec 2004 05:42:26 -0000 1.28
+++ logger.h 13 Dec 2004 05:05:13 -0000 1.29
@@ -167,15 +167,15 @@
*/
template<class STR>
void debug(const STR& msg, const log4cxx::spi::location::LocationInfo& location) {
- if (isEnabledFor(log4cxx::Level::DEBUG)) {
- forcedLog(log4cxx::Level::DEBUG, msg, location);
+ if (isEnabledFor(log4cxx::Level::getDebug())) {
+ forcedLog(log4cxx::Level::getDebug(), msg, location);
}
}
template<class STR>
void debug(const STR& msg) {
- if (isEnabledFor(log4cxx::Level::DEBUG)) {
- forcedLog(log4cxx::Level::DEBUG, msg);
+ if (isEnabledFor(log4cxx::Level::getDebug())) {
+ forcedLog(log4cxx::Level::getDebug(), msg);
}
}
@@ -294,6 +294,8 @@
Return the logger name. */
inline const LogString& getName() const
{ return name; }
+ void getName(std::string& name) const;
+ void getName(std::wstring& name) const;
/**
@@ -567,7 +569,7 @@
<code>Level#FATAL</code> as a parameter, you need to case them as
Level.
- <p>As in <pre> logger->setLevel(Level::DEBUG); </pre>
+ <p>As in <pre> logger->setLevel(Level::getDebug()); </pre>
<p>Null values are admitted. */
@@ -667,7 +669,7 @@
*/
#define LOG4CXX_DEBUG(logger, message) { \
if (LOG4CXX_UNLIKELY(logger->isDebugEnabled())) {\
- logger->forcedLog(::log4cxx::Level::DEBUG, message, LOG4CXX_LOCATION); }}
+ logger->forcedLog(::log4cxx::Level::getDebug(), message, LOG4CXX_LOCATION); }}
/**
Logs a message to a specified logger with the INFO level.
1.7 +5 -6 logging-log4cxx/include/log4cxx/portability.h
Index: portability.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/portability.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- portability.h 11 Dec 2004 04:53:21 -0000 1.6
+++ portability.h 13 Dec 2004 05:05:13 -0000 1.7
@@ -18,22 +18,21 @@
#if defined(_MSC_VER) && _MSC_VER >= 1200
-typedef __int64 apr_int64_t;
+typedef __int64 log4cxx_int64_t;
#else
-typedef long long apr_int64_t;
+typedef long long log4cxx_int64_t;
#endif
#else
#define LOG4CXX_EXPORT
-typedef long long apr_int64_t;
+typedef long long log4cxx_int64_t;
#endif
-typedef apr_int64_t apr_time_t;
-typedef int apr_status_t;
-struct apr_time_exp_t;
+typedef log4cxx_int64_t log4cxx_time_t;
+typedef int log4cxx_status_t;
#endif //_LOG4CXX_PORTABILITY_H
1.2 +2 -1 logging-log4cxx/include/log4cxx/helpers/aprinitializer.h
Index: aprinitializer.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/aprinitializer.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- aprinitializer.h 26 Nov 2004 07:23:30 -0000 1.1
+++ aprinitializer.h 13 Dec 2004 05:05:13 -0000 1.2
@@ -30,8 +30,9 @@
private:
APRInitializer();
- ~APRInitializer();
apr_pool_t * p;
+ public:
+ ~APRInitializer();
};
} // namespace helpers
}; // namespace log4cxx
1.5 +3 -3 logging-log4cxx/include/log4cxx/helpers/cacheddateformat.h
Index: cacheddateformat.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/cacheddateformat.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- cacheddateformat.h 11 Dec 2004 04:53:22 -0000 1.4
+++ cacheddateformat.h 13 Dec 2004 05:05:13 -0000 1.5
@@ -29,7 +29,7 @@
CachedDateFormat(DateFormatPtr& baseFormatter);
virtual void format(LogString &s,
- apr_time_t date,
+ log4cxx_time_t date,
apr_pool_t* p) const;
virtual void setTimeZone(const TimeZonePtr& zone);
virtual void numberFormat(LogString& s,
@@ -48,7 +48,7 @@
* -1 indicates no millisecond field, -2 indicates unrecognized
* field (likely RelativeTimeDateFormat)
*/
- static int findMillisecondStart(const apr_time_t time,
+ static int findMillisecondStart(const log4cxx_time_t time,
const LogString& formatted,
const logchar zeroDigit,
const logchar nineDigit,
@@ -58,7 +58,7 @@
DateFormatPtr formatter;
mutable int millisecondStart;
mutable LogString cache;
- mutable apr_time_t previousTime;
+ mutable log4cxx_time_t previousTime;
logchar zeroDigit;
logchar nineDigit;
enum {
1.10 +11 -11 logging-log4cxx/include/log4cxx/helpers/condition.h
Index: condition.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/condition.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- condition.h 25 Nov 2004 05:18:57 -0000 1.9
+++ condition.h 13 Dec 2004 05:05:13 -0000 1.10
@@ -16,22 +16,22 @@
#ifndef _LOG4CXX_HELPERS_CONDITION_H
#define _LOG4CXX_HELPERS_CONDITION_H
-
+
#include <log4cxx/helpers/exception.h>
-
-
-struct apr_pool_t;
-struct apr_thread_cond_t;
-struct apr_thread_mutex_t;
+
+
+struct apr_pool_t;
+struct apr_thread_cond_t;
+struct apr_thread_mutex_t;
namespace log4cxx
{
namespace helpers
{
class LOG4CXX_EXPORT ConditionException : public Exception
- {
- public:
- ConditionException(apr_status_t stat) {}
+ {
+ public:
+ ConditionException(log4cxx_status_t stat) {}
};
class LOG4CXX_EXPORT Condition
@@ -42,8 +42,8 @@
void broadcast();
void wait();
- private:
- apr_thread_cond_t* condition;
+ private:
+ apr_thread_cond_t* condition;
apr_thread_mutex_t* mutex;
};
} // namespace helpers
1.18 +2 -2 logging-log4cxx/include/log4cxx/helpers/dateformat.h
Index: dateformat.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/dateformat.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- dateformat.h 11 Dec 2004 04:53:22 -0000 1.17
+++ dateformat.h 13 Dec 2004 05:05:13 -0000 1.18
@@ -43,12 +43,12 @@
virtual ~DateFormat();
/**
- * Formats an apr_time_t into a date/time string.
+ * Formats an log4cxx_time_t into a date/time string.
* @param s string to which the date/time string is appended.
* @param date date to be formatted.
* @param p memory pool used during formatting.
*/
- virtual void format(LogString &s, apr_time_t date, apr_pool_t* p) const = 0;
+ virtual void format(LogString &s, log4cxx_time_t date, apr_pool_t* p) const = 0;
/**
* Sets the time zone.
1.10 +9 -9 logging-log4cxx/include/log4cxx/helpers/mutex.h
Index: mutex.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/mutex.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- mutex.h 25 Nov 2004 05:18:57 -0000 1.9
+++ mutex.h 13 Dec 2004 05:05:13 -0000 1.10
@@ -19,8 +19,8 @@
#include <log4cxx/portability.h>
#include <log4cxx/helpers/exception.h>
-
-struct apr_thread_mutex_t;
+
+struct apr_thread_mutex_t;
struct apr_pool_t;
namespace log4cxx
@@ -28,21 +28,21 @@
namespace helpers
{
class LOG4CXX_EXPORT MutexException : public Exception
- {
- public:
- MutexException(apr_status_t stat) {}
+ {
+ public:
+ MutexException(log4cxx_status_t stat) {}
};
class LOG4CXX_EXPORT Mutex
{
- public:
+ public:
Mutex(apr_pool_t* p);
- ~Mutex();
-
+ ~Mutex();
+
inline operator apr_thread_mutex_t*() const { return mutex; }
private:
- apr_thread_mutex_t* mutex;
+ apr_thread_mutex_t* mutex;
};
} // namespace helpers
};// namespace log4cxx
1.2 +8 -8 logging-log4cxx/include/log4cxx/helpers/pool.h
Index: pool.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/pool.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- pool.h 25 Nov 2004 05:18:57 -0000 1.1
+++ pool.h 13 Dec 2004 05:05:13 -0000 1.2
@@ -19,7 +19,7 @@
#include <log4cxx/portability.h>
#include <log4cxx/helpers/exception.h>
-
+
struct apr_pool_t;
namespace log4cxx
@@ -27,17 +27,17 @@
namespace helpers
{
class LOG4CXX_EXPORT PoolException : public Exception
- {
- public:
- PoolException(apr_status_t stat) {}
+ {
+ public:
+ PoolException(log4cxx_status_t stat) {}
};
class LOG4CXX_EXPORT Pool
{
- public:
- Pool();
- ~Pool();
-
+ public:
+ Pool();
+ ~Pool();
+
inline operator apr_pool_t*() { return pool; }
protected:
1.15 +2 -2 logging-log4cxx/include/log4cxx/helpers/relativetimedateformat.h
Index: relativetimedateformat.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/relativetimedateformat.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- relativetimedateformat.h 11 Dec 2004 04:53:22 -0000 1.14
+++ relativetimedateformat.h 13 Dec 2004 05:05:13 -0000 1.15
@@ -33,11 +33,11 @@
public:
RelativeTimeDateFormat();
virtual void format(LogString &s,
- apr_time_t tm,
+ log4cxx_time_t tm,
apr_pool_t* p) const;
private:
- apr_time_t startTime;
+ log4cxx_time_t startTime;
};
} // namespace helpers
1.4 +1 -1 logging-log4cxx/include/log4cxx/helpers/simpledateformat.h
Index: simpledateformat.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/simpledateformat.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- simpledateformat.h 11 Dec 2004 04:53:22 -0000 1.3
+++ simpledateformat.h 13 Dec 2004 05:05:13 -0000 1.4
@@ -45,7 +45,7 @@
~SimpleDateFormat();
virtual void format(LogString& s,
- apr_time_t time,
+ log4cxx_time_t time,
apr_pool_t* p) const;
/**
1.3 +1 -1 logging-log4cxx/include/log4cxx/helpers/strftimedateformat.h
Index: strftimedateformat.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/strftimedateformat.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- strftimedateformat.h 11 Dec 2004 04:53:22 -0000 1.2
+++ strftimedateformat.h 13 Dec 2004 05:05:13 -0000 1.3
@@ -42,7 +42,7 @@
~StrftimeDateFormat();
virtual void format(LogString& s,
- apr_time_t time,
+ log4cxx_time_t time,
apr_pool_t* p) const;
/**
1.13 +2 -2 logging-log4cxx/include/log4cxx/helpers/stringhelper.h
Index: stringhelper.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/stringhelper.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- stringhelper.h 12 Dec 2004 05:53:57 -0000 1.12
+++ stringhelper.h 13 Dec 2004 05:05:13 -0000 1.13
@@ -42,8 +42,8 @@
static int toInt(const std::string& s);
static int toInt(const std::wstring& s);
- static apr_int64_t toInt64(const std::string& s);
- static apr_int64_t toInt64(const std::wstring& s);
+ static log4cxx_int64_t toInt64(const std::string& s);
+ static log4cxx_int64_t toInt64(const std::wstring& s);
static LogString toString(int s, apr_pool_t* pool);
static LogString toString(int s);
1.21 +37 -37 logging-log4cxx/include/log4cxx/helpers/thread.h
Index: thread.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/thread.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- thread.h 25 Nov 2004 05:18:57 -0000 1.20
+++ thread.h 13 Dec 2004 05:05:13 -0000 1.21
@@ -18,22 +18,22 @@
#define _LOG4CXX_HELPERS_THREAD_H
#include <log4cxx/portability.h>
-#include <log4cxx/helpers/exception.h>
-
-#if !defined(LOG4CXX_THREAD_FUNC)
-#if defined(APR_THREAD_FUNC)
-#define LOG4CXX_THREAD_FUNC APR_THREAD_FUNC
-#else
-#if defined(_WIN32)
-#define LOG4CXX_THREAD_FUNC __stdcall
-#else
-#define LOG4CXX_THREAD_FUNC
-#endif
-#endif
-#endif
+#include <log4cxx/helpers/exception.h>
-
-struct apr_thread_t;
+#if !defined(LOG4CXX_THREAD_FUNC)
+#if defined(APR_THREAD_FUNC)
+#define LOG4CXX_THREAD_FUNC APR_THREAD_FUNC
+#else
+#if defined(_WIN32)
+#define LOG4CXX_THREAD_FUNC __stdcall
+#else
+#define LOG4CXX_THREAD_FUNC
+#endif
+#endif
+#endif
+
+
+struct apr_thread_t;
struct apr_pool_t;
namespace log4cxx
@@ -41,34 +41,34 @@
namespace helpers
{
class LOG4CXX_EXPORT ThreadException : public Exception
- {
- public:
- ThreadException(apr_status_t stat) {}
+ {
+ public:
+ ThreadException(log4cxx_status_t stat) {}
};
class LOG4CXX_EXPORT Thread
{
- public:
- Thread();
- ~Thread();
-
- void run(apr_pool_t* pool,
- void* (LOG4CXX_THREAD_FUNC *start)(apr_thread_t* thread, void* data),
- void* data);
- void stop();
- void join();
- //
- // called on the worker thread to indicate
- // immediate exit from the start method
- void ending();
-
- inline bool isActive() { return thread != NULL; }
+ public:
+ Thread();
+ ~Thread();
+
+ void run(apr_pool_t* pool,
+ void* (LOG4CXX_THREAD_FUNC *start)(apr_thread_t* thread, void* data),
+ void* data);
+ void stop();
+ void join();
+ //
+ // called on the worker thread to indicate
+ // immediate exit from the start method
+ void ending();
+
+ inline bool isActive() { return thread != NULL; }
private:
- apr_thread_t* thread;
- volatile bool finished;
- Thread(const Thread&);
- Thread& operator=(const Thread&);
+ apr_thread_t* thread;
+ volatile bool finished;
+ Thread(const Thread&);
+ Thread& operator=(const Thread&);
};
} // namespace helpers
};// namespace log4cxx
1.9 +15 -13 logging-log4cxx/include/log4cxx/helpers/timezone.h
Index: timezone.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/timezone.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- timezone.h 12 Dec 2004 05:53:57 -0000 1.8
+++ timezone.h 13 Dec 2004 05:05:13 -0000 1.9
@@ -22,6 +22,8 @@
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/objectptr.h>
+struct apr_time_exp_t;
+
namespace log4cxx
{
namespace helpers
@@ -38,27 +40,27 @@
END_LOG4CXX_CAST_MAP()
static const TimeZonePtr& getDefault();
- static const TimeZonePtr& getGMT();
+ static const TimeZonePtr& getGMT();
static const TimeZonePtr getTimeZone(const LogString& ID);
- const LogString getID() const {
- return id;
- }
+ const LogString getID() const {
+ return id;
+ }
- /**
- * Expand an APR time into the human readable
- * components for this timezone.
- */
- virtual apr_status_t explode(apr_time_exp_t* result,
- apr_time_t input) const = 0;
+ /**
+ * Expand an APR time into the human readable
+ * components for this timezone.
+ */
+ virtual log4cxx_status_t explode(apr_time_exp_t* result,
+ log4cxx_time_t input) const = 0;
protected:
- TimeZone(const LogString& ID);
- virtual ~TimeZone();
+ TimeZone(const LogString& ID);
+ virtual ~TimeZone();
- const LogString id;
+ const LogString id;
};
1.3 +8 -0 logging-log4cxx/include/log4cxx/helpers/transcoder.h
Index: transcoder.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/transcoder.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- transcoder.h 12 Dec 2004 05:53:57 -0000 1.2
+++ transcoder.h 13 Dec 2004 05:05:13 -0000 1.3
@@ -84,6 +84,14 @@
};
static const char SUBSTITUTION_CHAR = '?';
static const wchar_t SUBSTITUTION_WCHAR = L'?';
+
+#if !defined(_GCC_VER_)
+ struct mbstate_t {};
+ size_t mbsnrtowcs(wchar_t *dest, const char **src,
+ size_t nms, size_t len, mbstate_t *ps);
+ size_t wcsnrtombs(char *dest, const wchar_t **src, size_t nwc,
+ size_t len, mbstate_t *ps);
+#endif
}
};
1.14 +5 -5 logging-log4cxx/include/log4cxx/nt/nteventlogappender.h
Index: nteventlogappender.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/nt/nteventlogappender.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- nteventlogappender.h 11 Dec 2004 05:42:26 -0000 1.13
+++ nteventlogappender.h 13 Dec 2004 05:05:13 -0000 1.14
@@ -82,8 +82,8 @@
virtual void append(const spi::LoggingEventPtr& event, apr_pool_t* p);
static HKEY regGetKey(const std::wstring& subkey, unsigned long *disposition);
- static void regSetString(HKEY hkey, const std::wstring& name, const std::wstring& value);
- static void regSetDword(HKEY hkey, const std::wstring& name, unsigned long value);
+ static void regSetString(HKEY hkey, const wchar_t* name, const wchar_t* value);
+ static void regSetDword(HKEY hkey, const wchar_t* name, unsigned long value);
unsigned short getEventType(const spi::LoggingEventPtr& event);
unsigned short getEventCategory(const spi::LoggingEventPtr& event);
/*
@@ -92,9 +92,9 @@
void addRegistryInfo();
// Data
- LogString server;
- LogString log;
- LogString source;
+ LogString server;
+ LogString log;
+ LogString source;
HANDLE hEventLog;
SID * pCurrentUserSID;
}; // class NTEventLogAppender
1.22 +3 -3 logging-log4cxx/include/log4cxx/spi/loggingevent.h
Index: loggingevent.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/spi/loggingevent.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- loggingevent.h 12 Dec 2004 05:53:57 -0000 1.21
+++ loggingevent.h 13 Dec 2004 05:05:13 -0000 1.22
@@ -105,14 +105,14 @@
/**Returns the time when the application started,
in seconds elapsed since 01.01.1970.
*/
- static apr_time_t getStartTime();
+ static log4cxx_time_t getStartTime();
/** Return the #threadId of this event. */
inline unsigned long getThreadId() const
{ return threadId; }
/** Return the #timeStamp of this event. */
- inline apr_time_t getTimeStamp() const
+ inline log4cxx_time_t getTimeStamp() const
{ return timeStamp; }
/* Return the file where this log statement was written. */
@@ -234,7 +234,7 @@
/** The number of milliseconds elapsed from 1/1/1970 until logging event
was created. */
- apr_time_t timeStamp;
+ log4cxx_time_t timeStamp;
/** The is the location where this log statement was written. */
const log4cxx::spi::location::LocationInfo locationInfo;
1.12 +3 -3 logging-log4cxx/performance/main.cpp
Index: main.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/performance/main.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- main.cpp 11 Dec 2004 05:42:26 -0000 1.11
+++ main.cpp 13 Dec 2004 05:05:13 -0000 1.12
@@ -82,19 +82,19 @@
double NoDelayLoop(LoggerPtr logger, const String& msg)
{
- apr_time_t before = apr_time_now();
+ log4cxx_time_t before = apr_time_now();
for(int i = 0; i < runLength; i++)
{
logger->info(msg, __FILE__, __LINE__);
}
- apr_time_t after = apr_time_now();
+ log4cxx_time_t after = apr_time_now();
return (after - before)/(runLength*1000);
}
double DelayedLoop(LoggerPtr logger, const String& msg)
{
- apr_time_t before = apr_time_now();
+ log4cxx_time_t before = apr_time_now();
int j = 0;
for(int i = 0; i < runLength; i++)
{
1.17 +2 -1 logging-log4cxx/src/hierarchy.cpp
Index: hierarchy.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/hierarchy.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- hierarchy.cpp 12 Dec 2004 05:53:58 -0000 1.16
+++ hierarchy.cpp 13 Dec 2004 05:05:13 -0000 1.17
@@ -25,6 +25,7 @@
#include <log4cxx/appender.h>
#include <log4cxx/helpers/synchronized.h>
#include <apr_thread_mutex.h>
+#include <log4cxx/logstring.h>
using namespace log4cxx;
using namespace log4cxx::spi;
@@ -280,7 +281,7 @@
void Hierarchy::updateParents(LoggerPtr& logger)
{
- const LogString& name(logger->name);
+ const LogString& name = logger->getName();
int length = name.size();
bool parentFound = false;
1.20 +8 -0 logging-log4cxx/src/logger.cpp
Index: logger.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/logger.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- logger.cpp 11 Dec 2004 04:53:25 -0000 1.19
+++ logger.cpp 13 Dec 2004 05:05:13 -0000 1.20
@@ -482,3 +482,11 @@
{
return LogManager::getLogger(name, factory);
}
+
+void Logger::getName(std::string& rv) const {
+ Transcoder::encode(name, rv);
+}
+
+void Logger::getName(std::wstring& rv) const {
+ Transcoder::encode(name, rv);
+}
1.16 +1 -1 logging-log4cxx/src/logmanager.cpp
Index: logmanager.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/logmanager.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- logmanager.cpp 11 Dec 2004 04:53:25 -0000 1.15
+++ logmanager.cpp 13 Dec 2004 05:05:13 -0000 1.16
@@ -46,7 +46,7 @@
//
// call to initialize APR and trigger "start" of logging clock
//
- static apr_time_t tm(LoggingEvent::getStartTime());
+ static log4cxx_time_t tm = LoggingEvent::getStartTime();
static spi::RepositorySelectorPtr selector;
return selector;
}
1.10 +44 -32 logging-log4cxx/src/nteventlogappender.cpp
Index: nteventlogappender.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/nteventlogappender.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- nteventlogappender.cpp 10 Aug 2004 22:39:01 -0000 1.9
+++ nteventlogappender.cpp 13 Dec 2004 05:05:13 -0000 1.10
@@ -23,6 +23,7 @@
#include <log4cxx/helpers/loglog.h>
#include <log4cxx/level.h>
#include <log4cxx/helpers/stringhelper.h>
+#include <log4cxx/helpers/transcoder.h>
using namespace log4cxx;
using namespace log4cxx::spi;
@@ -90,11 +91,11 @@
{
}
-NTEventLogAppender::NTEventLogAppender(const String& server, const String& log, const String& source, const LayoutPtr& layout)
+NTEventLogAppender::NTEventLogAppender(const LogString& server, const LogString& log, const LogString& source, const LayoutPtr& layout)
: server(server), log(log), source(source), hEventLog(NULL), pCurrentUserSID(NULL)
{
this->layout = layout;
- activateOptions();
+ activateOptions(NULL);
}
NTEventLogAppender::~NTEventLogAppender()
@@ -118,17 +119,17 @@
}
}
-void NTEventLogAppender::setOption(const String& option, const String& value)
+void NTEventLogAppender::setOption(const LogString& option, const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option, _T("server")))
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SERVER"), LOG4CXX_STR("server")))
{
server = value;
}
- else if (StringHelper::equalsIgnoreCase(option, _T("log")))
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("LOG"), LOG4CXX_STR("log")))
{
log = value;
}
- else if (StringHelper::equalsIgnoreCase(option, _T("source")))
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SOURCE"), LOG4CXX_STR("source")))
{
source = value;
}
@@ -138,17 +139,19 @@
}
}
-void NTEventLogAppender::activateOptions()
+void NTEventLogAppender::activateOptions(apr_pool_t* p)
{
if (source.empty())
{
- LogLog::warn(_T("Source option not set for appender [")+name+_T("]."));
+ LogLog::warn(
+ ((LogString) LOG4CXX_STR("Source option not set for appender ["))
+ + name + LOG4CXX_STR("]."));
return;
}
if (log.empty())
{
- log = _T("Application");
+ log = LOG4CXX_STR("Application");
}
close();
@@ -158,23 +161,28 @@
addRegistryInfo();
- hEventLog = ::RegisterEventSource(server.c_str(), source.c_str());
+ std::wstring wserver;
+ Transcoder::encode(server, wserver);
+ std::wstring wsource;
+ Transcoder::encode(source, wsource);
+ hEventLog = ::RegisterEventSourceW(wserver.c_str(), wsource.c_str());
}
-void NTEventLogAppender::append(const LoggingEventPtr& event)
+void NTEventLogAppender::append(const LoggingEventPtr& event, apr_pool_t* p)
{
if (hEventLog == NULL)
{
- LogLog::warn(_T("NT EventLog not opened."));
+ LogLog::warn(LOG4CXX_STR("NT EventLog not opened."));
return;
}
- StringBuffer oss;
- layout->format(oss, event);
- String sz = oss.str();
- const TCHAR * s = sz.c_str();
-
- BOOL bSuccess = ::ReportEvent(
+ LogString oss;
+ layout->format(oss, event, p);
+ std::wstring s;
+ log4cxx::helpers::Transcoder::encode(oss, s);
+ const wchar_t* msgs[1];
+ msgs[0] = s.c_str() ;
+ BOOL bSuccess = ::ReportEventW(
hEventLog,
getEventType(event),
getEventCategory(event),
@@ -182,33 +190,35 @@
pCurrentUserSID,
1,
0,
- &s,
+ msgs,
NULL);
if (!bSuccess)
{
DWORD dwError = ::GetLastError();
- LogLog::error(_T("Cannot report event in NT EventLog."));
+ LogLog::error(LOG4CXX_STR("Cannot report event in NT EventLog."));
}
}
-NTEventLogAppender::HKEY NTEventLogAppender::regGetKey(const String& subkey, DWORD *disposition)
+NTEventLogAppender::HKEY NTEventLogAppender::regGetKey(const std::wstring& subkey, DWORD *disposition)
{
::HKEY hkey = 0;
- RegCreateKeyEx((::HKEY) HKEY_LOCAL_MACHINE, subkey.c_str(), 0, NULL,
+ RegCreateKeyExW((::HKEY) HKEY_LOCAL_MACHINE, subkey.c_str(), 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL,
&hkey, disposition);
return hkey;
}
-void NTEventLogAppender::regSetString(HKEY hkey, const String& name, const String& value)
+void NTEventLogAppender::regSetString(HKEY hkey, const wchar_t* name,
+ const wchar_t* value)
{
- RegSetValueEx((::HKEY) hkey, name.c_str(), 0, REG_SZ, (LPBYTE)value.c_str(), value.length()*sizeof(wchar_t));
+ RegSetValueExW((::HKEY) hkey, name, 0, REG_SZ, (LPBYTE) value,
+ wcslen(value)*sizeof(wchar_t));
}
-void NTEventLogAppender::regSetDword(HKEY hkey, const String& name, DWORD value)
+void NTEventLogAppender::regSetDword(HKEY hkey, const wchar_t* name, DWORD value)
{
- RegSetValueEx((::HKEY) hkey, name.c_str(), 0, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
+ RegSetValueExW((::HKEY) hkey, name, 0, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
}
/*
@@ -218,16 +228,18 @@
{
DWORD disposition;
::HKEY hkey = 0;
- String subkey = _T("SYSTEM\\CurrentControlSet\\Services\\EventLog\\")
- + log + _T("\\") + source;
+ std::wstring subkey(L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\");
+ Transcoder::encode(log, subkey);
+ subkey += L"\\";
+ Transcoder::encode(source, subkey);
hkey = (::HKEY) regGetKey(subkey, &disposition);
if (disposition == REG_CREATED_NEW_KEY)
{
- regSetString(hkey, _T("EventMessageFile"), _T("NTEventLogAppender.dll"));
- regSetString(hkey, _T("CategoryMessageFile"), _T("NTEventLogAppender.dll"));
- regSetDword(hkey, _T("TypesSupported"), (DWORD)7);
- regSetDword(hkey, _T("CategoryCount"), (DWORD)5);
+ regSetString(hkey, L"EventMessageFile", L"NTEventLogAppender.dll");
+ regSetString(hkey, L"CategoryMessageFile", L"NTEventLogAppender.dll");
+ regSetDword(hkey, L"TypesSupported", (DWORD)7);
+ regSetDword(hkey, L"CategoryCount", (DWORD)5);
}
RegCloseKey(hkey);
1.5 +1 -1 logging-log4cxx/src/relativetimedateformat.cpp
Index: relativetimedateformat.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/relativetimedateformat.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- relativetimedateformat.cpp 11 Dec 2004 04:53:25 -0000 1.4
+++ relativetimedateformat.cpp 13 Dec 2004 05:05:13 -0000 1.5
@@ -42,7 +42,7 @@
if (ms >= INT_MIN && ms <= INT_MAX) {
s.append(StringHelper::toString(ms, p));
} else {
- const apr_int64_t BILLION = APR_INT64_C(1000000000);
+ const log4cxx_int64_t BILLION = APR_INT64_C(1000000000);
s.append(StringHelper::toString(ms / BILLION, p));
LogString lower(StringHelper::toString(ms % BILLION, p));
int fill = 9 - lower.length();
1.5 +2 -2 logging-log4cxx/src/simpledateformat.cpp
Index: simpledateformat.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/simpledateformat.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- simpledateformat.cpp 11 Dec 2004 04:53:25 -0000 1.4
+++ simpledateformat.cpp 13 Dec 2004 05:05:13 -0000 1.5
@@ -404,8 +404,8 @@
//
// assumes that point values for 0-9 are same between char and wchar_t
//
- for (size_t i = strlen(hours); i-- > 0;) {
- s[minPos--] = min[i];
+ for (size_t j = strlen(hours); j-- > 0;) {
+ s[minPos--] = min[j];
}
}
}
1.10 +1 -0 logging-log4cxx/src/socketinputstream.cpp
Index: socketinputstream.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/socketinputstream.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- socketinputstream.cpp 11 Dec 2004 04:53:25 -0000 1.9
+++ socketinputstream.cpp 13 Dec 2004 05:05:13 -0000 1.10
@@ -17,6 +17,7 @@
#include <log4cxx/helpers/socketinputstream.h>
#include <log4cxx/helpers/socket.h>
#include <log4cxx/helpers/loglog.h>
+#include <malloc.h>
using namespace log4cxx;
using namespace log4cxx::helpers ;
1.5 +8 -11 logging-log4cxx/src/stringhelper.cpp
Index: stringhelper.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/stringhelper.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- stringhelper.cpp 11 Dec 2004 04:53:25 -0000 1.4
+++ stringhelper.cpp 13 Dec 2004 05:05:13 -0000 1.5
@@ -142,26 +142,23 @@
}
int StringHelper::toInt(const std::wstring& s) {
- // ugly, transcode to ascii call atoi
- std::string ascii;
- log4cxx::helpers::Transcoder::encode(s, ascii);
- return atoi(ascii.c_str());
+ LOG4CXX_DECODE_WCHAR(logstr, s);
+ LOG4CXX_ENCODE_CHAR(charstr, logstr);
+ return atoi(charstr.c_str());
}
-apr_int64_t StringHelper::toInt64(const std::string& s) {
+log4cxx_int64_t StringHelper::toInt64(const std::string& s) {
return apr_atoi64(s.c_str());
}
-apr_int64_t StringHelper::toInt64(const std::wstring& s) {
- // ugly, transcode to ascii call atoi
- std::string ascii;
- log4cxx::helpers::Transcoder::encode(s, ascii);
- return apr_atoi64(ascii.c_str());
+log4cxx_int64_t StringHelper::toInt64(const std::wstring& s) {
+ LOG4CXX_DECODE_WCHAR(logstr, s);
+ LOG4CXX_ENCODE_CHAR(charstr, logstr);
+ return apr_atoi64(charstr.c_str());
}
LogString StringHelper::toString(int s, apr_pool_t* pool) {
char* fmt = apr_itoa(pool, s);
- size_t chars = 0;
LogString str;
log4cxx::helpers::Transcoder::decode(fmt, strlen(fmt), str);
return str;
1.2 +1 -1 logging-log4cxx/src/transcoder.cpp
Index: transcoder.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/transcoder.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- transcoder.cpp 11 Dec 2004 04:53:25 -0000 1.1
+++ transcoder.cpp 13 Dec 2004 05:05:13 -0000 1.2
@@ -16,8 +16,8 @@
#include <log4cxx/helpers/transcoder.h>
#include <log4cxx/helpers/pool.h>
-#include <string>
+using namespace log4cxx;
using namespace log4cxx::helpers;
1.11 +5 -1 logging-log4cxx/src/writerappender.cpp
Index: writerappender.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/writerappender.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- writerappender.cpp 11 Dec 2004 04:53:25 -0000 1.10
+++ writerappender.cpp 13 Dec 2004 05:05:13 -0000 1.11
@@ -18,9 +18,13 @@
#include <log4cxx/helpers/loglog.h>
#include <log4cxx/helpers/synchronized.h>
#include <log4cxx/helpers/transcoder.h>
-#include <apr_iconv.h>
+//
+// temporary hack until build is fixed to always have apr_iconv
#define HAS_APR_ICONV 0
+#if HAS_APR_ICONV
+#include <apr_iconv.h>
+#endif
using namespace log4cxx;
using namespace log4cxx::helpers;