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 mc...@apache.org on 2004/04/02 10:33:34 UTC
cvs commit: logging-log4cxx/src dailyrollingfileappender.cpp dateformat.cpp datelayout.cpp htmllayout.cpp patternconverter.cpp patternlayout.cpp patternparser.cpp
mcatan 2004/04/02 00:33:34
Modified: include/log4cxx/helpers absolutetimedateformat.h
dateformat.h datelayout.h datetimedateformat.h
iso8601dateformat.h patternconverter.h
relativetimedateformat.h
include/log4cxx dailyrollingfileappender.h
src dailyrollingfileappender.cpp dateformat.cpp
datelayout.cpp htmllayout.cpp patternconverter.cpp
patternlayout.cpp patternparser.cpp
Log:
added class TimeZone for optimization
Revision Changes Path
1.5 +1 -1 logging-log4cxx/include/log4cxx/helpers/absolutetimedateformat.h
Index: absolutetimedateformat.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/absolutetimedateformat.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- absolutetimedateformat.h 20 Jan 2004 22:16:12 -0000 1.4
+++ absolutetimedateformat.h 2 Apr 2004 08:33:34 -0000 1.5
@@ -50,7 +50,7 @@
*/
static String DATE_AND_TIME_DATE_FORMAT;
- AbsoluteTimeDateFormat(const String& timeZone = _T(""))
+ AbsoluteTimeDateFormat(const TimeZonePtr& timeZone)
: DateFormat(_T("%H:%M:%S,%Q"), timeZone) {}
};
}; // namespace helpers
1.11 +4 -4 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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- dateformat.h 1 Mar 2004 05:51:00 -0000 1.10
+++ dateformat.h 2 Apr 2004 08:33:34 -0000 1.11
@@ -18,7 +18,7 @@
#define _LOG4CXX_HELPERS_DATE_FORMAT_H
#include <log4cxx/helpers/tchar.h>
-#include <locale>
+#include <log4cxx/helpers/timezone.h>
namespace log4cxx
{
@@ -31,14 +31,14 @@
class LOG4CXX_EXPORT DateFormat
{
public:
- DateFormat(const String& dateFormat, const String& timeZone = _T(""));
+ DateFormat(const String& dateFormat);
+ DateFormat(const String& dateFormat, const TimeZonePtr& timeZone);
virtual void format(ostream& os, int64_t time) const;
String format(int64_t timeMillis) const;
protected:
- String timeZone;
+ TimeZonePtr timeZone;
String dateFormat;
- String timeZoneEnv;
};
}; // namespace helpers
}; // namespace log4cxx
1.7 +44 -37 logging-log4cxx/include/log4cxx/helpers/datelayout.h
Index: datelayout.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/datelayout.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- datelayout.h 28 Feb 2004 15:10:23 -0000 1.6
+++ datelayout.h 2 Apr 2004 08:33:34 -0000 1.7
@@ -24,7 +24,9 @@
namespace helpers
{
class DateFormat;
-
+ class TimeZone;
+ typedef helpers::ObjectPtrT<TimeZone> TimeZonePtr;
+
/**
This abstract layout takes care of all the date related options and
formatting work.
@@ -48,7 +50,7 @@
static String TIMEZONE_OPTION;
private:
- String timeZone;
+ String timeZoneID;
String dateFormatOption;
protected:
@@ -57,54 +59,59 @@
public:
DateLayout();
virtual ~DateLayout();
- /**
- Sets the DateFormat used to format date and time in the time zone
- determined by <code>timeZone</code> parameter. The
- helpers::DateFormat DateFormat used
- will depend on the <code>dateFormatType</code>.
-
- <p>The recognized types are #NULL_DATE_FORMAT,
- #RELATIVE_TIME_DATE_FORMAT,
- helpers::AbsoluteTimeDateFormat#ABS_TIME_DATE_FORMAT,
- helpers::AbsoluteTimeDateFormat#DATE_AND_TIME_DATE_FORMAT and
- helpers::AbsoluteTimeDateFormat#ISO8601_DATE_FORMAT. If the
- <code>dateFormatType</code> is not one of the above, then the
- argument is assumed to be a date pattern for
- helpers::DateFormat.
- */
- virtual void activateOptions();
-
+
+ virtual void activateOptions();
virtual void setOption(const String& option, const String& value);
- /**
- The value of the <b>DateFormat</b> option should be either an
- argument to the constructor of helpers::DateFormat or one of
- the srings <b>"NULL"</b>, <b>"RELATIVE"</b>, <b>"ABSOLUTE"</b>,
- <b>"DATE"</b> or <b>"ISO8601</b>.
- */
+ /**
+ The value of the <b>DateFormat</b> option should be either an
+ argument to the constructor of helpers::DateFormat or one of
+ the srings <b>"NULL"</b>, <b>"RELATIVE"</b>, <b>"ABSOLUTE"</b>,
+ <b>"DATE"</b> or <b>"ISO8601</b>.
+ */
inline void setDateFormat(const String& dateFormat)
{ this->dateFormatOption = dateFormat; }
- /**
- Returns value of the <b>DateFormat</b> option.
- */
+ /**
+ Returns value of the <b>DateFormat</b> option.
+ */
inline const String& getDateFormat() const
{ return dateFormatOption; }
- /**
- The <b>TimeZoneID</b> option is a time zone ID string in the format
- expected by the <code>locale</code> C++ standard class.
- */
+ /**
+ The <b>TimeZoneID</b> option is a time zone ID string in the format
+ expected by the <code>locale</code> C++ standard class.
+ */
inline void setTimeZone(const String& timeZone)
- { this->timeZone = timeZone; }
+ { this->timeZoneID = timeZone; }
- /**
- Returns value of the <b>TimeZone</b> option.
- */
+ /**
+ Returns value of the <b>TimeZone</b> option.
+ */
inline const String& getTimeZone() const
- { return timeZone; }
+ { return timeZoneID; }
void formatDate(ostream &os, const spi::LoggingEventPtr& event) const;
+
+ protected:
+ /**
+ Sets the DateFormat used to format date and time in the time zone
+ determined by <code>timeZone</code> parameter. The
+ helpers::DateFormat DateFormat used
+ will depend on the <code>dateFormatType</code>.
+
+ <p>The recognized types are #NULL_DATE_FORMAT,
+ #RELATIVE_TIME_DATE_FORMAT,
+ helpers::AbsoluteTimeDateFormat#ABS_TIME_DATE_FORMAT,
+ helpers::AbsoluteTimeDateFormat#DATE_AND_TIME_DATE_FORMAT and
+ helpers::AbsoluteTimeDateFormat#ISO8601_DATE_FORMAT. If the
+ <code>dateFormatType</code> is not one of the above, then the
+ argument is assumed to be a date pattern for
+ helpers::DateFormat.
+ */
+ void setDateFormat(const String& dateFormatType,
+ const TimeZonePtr& timeZone);
+
};
}; // namespace helpers
}; // namespace log4cxx
1.5 +1 -1 logging-log4cxx/include/log4cxx/helpers/datetimedateformat.h
Index: datetimedateformat.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/datetimedateformat.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- datetimedateformat.h 20 Jan 2004 22:16:12 -0000 1.4
+++ datetimedateformat.h 2 Apr 2004 08:33:34 -0000 1.5
@@ -30,7 +30,7 @@
class LOG4CXX_EXPORT DateTimeDateFormat : public DateFormat
{
public:
- DateTimeDateFormat(const String& timeZone = _T(""))
+ DateTimeDateFormat(const TimeZonePtr& timeZone)
: DateFormat(_T("%d %b %Y %H:%M:%S,%Q"), timeZone) {}
};
}; // namespace helpers
1.9 +1 -1 logging-log4cxx/include/log4cxx/helpers/iso8601dateformat.h
Index: iso8601dateformat.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/iso8601dateformat.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- iso8601dateformat.h 11 Feb 2004 02:47:37 -0000 1.8
+++ iso8601dateformat.h 2 Apr 2004 08:33:34 -0000 1.9
@@ -35,7 +35,7 @@
class LOG4CXX_EXPORT ISO8601DateFormat : public DateFormat
{
public:
- ISO8601DateFormat(const String& timeZone = _T(""))
+ ISO8601DateFormat(const TimeZonePtr& timeZone)
: DateFormat(_T("%Y-%m-%d %H:%M:%S,%Q"), timeZone) {}
};
}; // namespace helpers
1.10 +3 -2 logging-log4cxx/include/log4cxx/helpers/patternconverter.h
Index: patternconverter.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/patternconverter.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- patternconverter.h 28 Feb 2004 15:10:23 -0000 1.9
+++ patternconverter.h 2 Apr 2004 08:33:34 -0000 1.10
@@ -53,9 +53,10 @@
END_LOG4CXX_CAST_MAP()
PatternConverterPtr next;
- int min;
- int max;
+ int minChar;
+ int maxChar;
bool leftAlign;
+ mutable StringBuffer os;
protected:
PatternConverter();
1.8 +1 -1 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- relativetimedateformat.h 28 Feb 2004 15:10:23 -0000 1.7
+++ relativetimedateformat.h 2 Apr 2004 08:33:34 -0000 1.8
@@ -36,7 +36,7 @@
public:
RelativeTimeDateFormat()
- : DateFormat(_T(""), _T("")), startTime(System::currentTimeMillis())
+ : DateFormat(_T(""), 0), startTime(System::currentTimeMillis())
{
}
1.6 +18 -0 logging-log4cxx/include/log4cxx/dailyrollingfileappender.h
Index: dailyrollingfileappender.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/dailyrollingfileappender.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- dailyrollingfileappender.h 1 Mar 2004 05:51:00 -0000 1.5
+++ dailyrollingfileappender.h 2 Apr 2004 08:33:34 -0000 1.6
@@ -18,6 +18,7 @@
#define _LOG4CXX_DAILY_ROLLING_FILE_APPENDER_H
#include <log4cxx/fileappender.h>
+#include <log4cxx/helpers/timezone.h>
namespace log4cxx
{
@@ -48,6 +49,7 @@
};
RollingCalendar();
+ RollingCalendar(const helpers::TimeZonePtr& timeZone);
inline void setType(PeriodicityType type)
{ this->type = type; }
@@ -66,8 +68,24 @@
void printPeriodicity();
int64_t getNextCheckMillis(int64_t now);
+ /**
+ Gets the time zone.
+ @return the time zone object associated with this calendar.
+ */
+ inline const helpers::TimeZonePtr getTimeZone() const
+ { return timeZone; }
+
+ /**
+ Sets the time zone with the given time zone value.
+ @return value the given time zone.
+ */
+ inline void setTimeZone(const helpers::TimeZonePtr& timeZone)
+ { this->timeZone = timeZone; }
+
protected:
PeriodicityType type;
+ helpers::TimeZonePtr timeZone;
+ static helpers::TimeZonePtr GMT_TIMEZONE;
};
class DailyRollingFileAppender;
1.3 +29 -11 logging-log4cxx/src/dailyrollingfileappender.cpp
Index: dailyrollingfileappender.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/dailyrollingfileappender.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- dailyrollingfileappender.cpp 28 Feb 2004 15:07:50 -0000 1.2
+++ dailyrollingfileappender.cpp 2 Apr 2004 08:33:34 -0000 1.3
@@ -20,6 +20,8 @@
#include <log4cxx/helpers/dateformat.h>
#include <sys/stat.h>
#include <log4cxx/helpers/stringhelper.h>
+#include <time.h>
+#include <log4cxx/helpers/timezone.h>
#ifdef WIN32
#include <errno.h>
@@ -28,22 +30,33 @@
using namespace log4cxx;
using namespace log4cxx::helpers;
+TimeZonePtr RollingCalendar::GMT_TIMEZONE = TimeZone::getTimeZone(_T("GMT"));
+
RollingCalendar::RollingCalendar()
-: type(RollingCalendar::TOP_OF_TROUBLE)
+: type(RollingCalendar::TOP_OF_TROUBLE),
+timeZone(TimeZone::getDefault())
{
-}
+}
+
+RollingCalendar::RollingCalendar(const helpers::TimeZonePtr& timeZone)
+: type(RollingCalendar::TOP_OF_TROUBLE),
+timeZone(timeZone)
+{
+}
RollingCalendar::PeriodicityType
RollingCalendar::computeTriggeringPeriod(const String& datePattern)
{
- RollingCalendar rollingCalendar;
+ RollingCalendar rollingCalendar(GMT_TIMEZONE);
// set date to 1970-01-01 00:00:00 GMT
int64_t epoch = 0;
if(!datePattern.empty())
{
+ DateFormat dateFormat(datePattern, GMT_TIMEZONE);
+ putenv("TZ=GMT");
+ tzset();
for(int i = TOP_OF_MINUTE; i <= TOP_OF_MONTH; i++)
{
- DateFormat dateFormat(datePattern, _T("GMT"));
String r0 = dateFormat.format(epoch);
rollingCalendar.setType((PeriodicityType)i);
int64_t next = rollingCalendar.getNextCheckMillis(epoch);
@@ -97,25 +110,30 @@
now += 60 * 60 * 1000;
return now - (now % (60 * 60 * 1000));
case HALF_DAY:
- now += 12 * 60 * 60 * 1000;
- return now - (now % (12 * 60 * 60 * 1000));
+ now += 12 * 60 * 60 * 1000 + timeZone->getOffset(now);
+ now -= now % (12 * 60 * 60 * 1000);
+ return now - timeZone->getOffset(now);
case TOP_OF_DAY:
- now += 24 * 60 * 60 * 1000;
- return now - (now % (24 * 60 * 60 * 1000));
+ now += 24 * 60 * 60 * 1000 + timeZone->getOffset(now);
+ now -= now % (24 * 60 * 60 * 1000);
+ return now - timeZone->getOffset(now);
case TOP_OF_WEEK:
now += 7 * 24 * 60 * 60 * 1000;
return now - (now % (7 * 24 * 60 * 60 * 1000));
case TOP_OF_MONTH:
{
+ now += timeZone->getOffset(now);
time_t nowTime = (time_t)(now / 1000);
- struct tm * nextTime = localtime(&nowTime);
+ struct tm * nextTime = gmtime(&nowTime);
nextTime->tm_mday = 1;
nextTime->tm_hour = 0;
nextTime->tm_min = 0;
nextTime->tm_sec = 0;
nextTime->tm_mon += 1;
nextTime->tm_isdst = 0;
- return (int64_t)mktime(nextTime) * 1000;
+ now = (int64_t)mktime(nextTime) * 1000;
+ now -= timeZone->getOffset(now);
+ return now;
}
default:
throw RuntimeException(_T("Unknown periodicity type."));
@@ -155,7 +173,7 @@
if (!datePattern.empty() && !fileName.empty())
{
now = System::currentTimeMillis();
- df = new DateFormat(datePattern, _T("GMT"));
+ df = new DateFormat(datePattern);
rc.setType(rc.computeTriggeringPeriod(datePattern));
rc.printPeriodicity();
1.9 +22 -8 logging-log4cxx/src/dateformat.cpp
Index: dateformat.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/dateformat.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- dateformat.cpp 28 Feb 2004 15:07:50 -0000 1.8
+++ dateformat.cpp 2 Apr 2004 08:33:34 -0000 1.9
@@ -14,10 +14,12 @@
* distribution in the LICENSE.txt file. *
***************************************************************************/
+#include <log4cxx/helpers/exception.h>
#include <log4cxx/helpers/dateformat.h>
#include <log4cxx/helpers/loglog.h>
#include <log4cxx/helpers/absolutetimedateformat.h>
#include <iomanip> // for setw & setfill
+#include <time.h>
using namespace log4cxx;
using namespace log4cxx::helpers;
@@ -26,7 +28,18 @@
String AbsoluteTimeDateFormat::ABS_TIME_DATE_FORMAT = _T("ABSOLUTE");
String AbsoluteTimeDateFormat::DATE_AND_TIME_DATE_FORMAT = _T("DATE");
-DateFormat::DateFormat(const String& dateFormat, const String& timeZone)
+DateFormat::DateFormat(const String& dateFormat)
+ : dateFormat(dateFormat), timeZone(TimeZone::getDefault())
+{
+ size_t pos = this->dateFormat.find(_T("%Q"));
+ if (pos != String::npos)
+ {
+ this->dateFormat = this->dateFormat.substr(0, pos) +
+ _T("%") + this->dateFormat.substr(pos);
+ }
+}
+
+DateFormat::DateFormat(const String& dateFormat, const TimeZonePtr& timeZone)
: dateFormat(dateFormat), timeZone(timeZone)
{
size_t pos = this->dateFormat.find(_T("%Q"));
@@ -35,20 +48,21 @@
this->dateFormat = this->dateFormat.substr(0, pos) +
_T("%") + this->dateFormat.substr(pos);
}
-
- timeZoneEnv = _T("TZ=") + timeZone;
}
void DateFormat::format(ostream& os, int64_t timeMillis) const
{
TCHAR buffer[255];
- USES_CONVERSION;
- ::putenv((char *)T2A(timeZoneEnv.c_str()));
- tzset();
+ if (timeZone == 0)
+ {
+ throw NullPointerException(_T("timeZone is null"));
+ }
+
+ int64_t localTimeMillis = timeMillis + timeZone->getOffset(timeMillis);
- time_t time = (time_t)(timeMillis/1000);
- const tm * tm = ::localtime(&time);
+ time_t time = (time_t)(localTimeMillis/1000);
+ const tm * tm = ::gmtime(&time);
#ifdef UNICODE
size_t len = ::wcsftime(buffer, 255, dateFormat.c_str(), tm);
1.7 +18 -1 logging-log4cxx/src/datelayout.cpp
Index: datelayout.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/datelayout.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- datelayout.cpp 28 Feb 2004 15:07:50 -0000 1.6
+++ datelayout.cpp 2 Apr 2004 08:33:34 -0000 1.7
@@ -22,6 +22,7 @@
#include <log4cxx/helpers/absolutetimedateformat.h>
#include <log4cxx/helpers/datetimedateformat.h>
#include <log4cxx/helpers/iso8601dateformat.h>
+#include <log4cxx/helpers/timezone.h>
using namespace log4cxx;
using namespace log4cxx::helpers;
@@ -53,11 +54,27 @@
}
else if (StringHelper::equalsIgnoreCase(option, TIMEZONE_OPTION))
{
- timeZone = value;
+ timeZoneID = value;
}
}
void DateLayout::activateOptions()
+{
+ if(!dateFormatOption.empty())
+ {
+ if (timeZoneID.empty())
+ {
+ setDateFormat(dateFormatOption, TimeZone::getDefault());
+ }
+ else
+ {
+ setDateFormat(dateFormatOption, TimeZone::getTimeZone(timeZoneID));
+ }
+ }
+}
+
+void DateLayout::setDateFormat(const String& dateFormatType,
+ const TimeZonePtr& timeZone)
{
if (dateFormat != 0)
{
1.9 +4 -3 logging-log4cxx/src/htmllayout.cpp
Index: htmllayout.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/htmllayout.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- htmllayout.cpp 28 Feb 2004 15:07:50 -0000 1.8
+++ htmllayout.cpp 2 Apr 2004 08:33:34 -0000 1.9
@@ -33,7 +33,8 @@
String HTMLLayout::TITLE_OPTION = _T("Title");
HTMLLayout::HTMLLayout()
-: locationInfo(false), title(_T("Log4cxx Log Messages"))
+: locationInfo(false), title(_T("Log4cxx Log Messages")),
+dateFormat(TimeZone::getTimeZone(_T("GMT")))
{
}
@@ -55,7 +56,7 @@
output << std::endl << _T("<tr>") << std::endl;
output << _T("<td>");
- ISO8601DateFormat().format(output, event->getTimeStamp());
+ dateFormat.format(output, event->getTimeStamp());
output << _T("</td>") << std::endl;
output << _T("<td title=\"") << event->getThreadId() << _T(" thread\">");
@@ -134,7 +135,7 @@
output << _T("<body bgcolor=\"#FFFFFF\" topmargin=\"6\" leftmargin=\"6\">") << std::endl;
output << _T("<hr size=\"1\" noshade>") << std::endl;
output << _T("Log session start time ");
- ISO8601DateFormat().format(output, time(0));
+ dateFormat.format(output, time(0));
output << _T("<br>") << std::endl;
output << _T("<br>") << std::endl;
output << _T("<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" bordercolor=\"#224466\" width=\"100%\">") << std::endl;
1.8 +14 -14 logging-log4cxx/src/patternconverter.cpp
Index: patternconverter.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/patternconverter.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- patternconverter.cpp 28 Feb 2004 15:07:50 -0000 1.7
+++ patternconverter.cpp 2 Apr 2004 08:33:34 -0000 1.8
@@ -22,14 +22,14 @@
IMPLEMENT_LOG4CXX_OBJECT(PatternConverter)
-PatternConverter::PatternConverter() : min(-1), max(0x7FFFFFFF), leftAlign(false)
+PatternConverter::PatternConverter() : minChar(-1), maxChar(0x7FFFFFFF), leftAlign(false)
{
}
PatternConverter::PatternConverter(const FormattingInfo& fi)
{
- min = fi.min;
- max = fi.max;
+ minChar = fi.minChar;
+ maxChar = fi.maxChar;
leftAlign = fi.leftAlign;
}
@@ -38,39 +38,39 @@
*/
void PatternConverter::format(ostream& sbuf, const spi::LoggingEventPtr& e) const
{
- if (min == 0 && max == 0x7FFFFFFF)
+ if (minChar == -1 && maxChar == 0x7FFFFFFF)
{
convert(sbuf, e);
}
else
{
- StringBuffer os;
+ os.seekp(0);
convert(os, e);
String s = os.str();
- if(s.empty())
+ if (s.empty())
{
- if(0 < min)
- sbuf << String(min, _T(' '));
+ if(0 < minChar)
+ sbuf << String(minChar, _T(' '));
return;
}
int len = s.size();
- if(len > max)
+ if (len > maxChar)
{
- sbuf << (s.substr(len-max));
+ sbuf << (s.substr(len-maxChar));
}
- else if(len < min)
+ else if (len < minChar)
{
- if(leftAlign)
+ if (leftAlign)
{
sbuf << s;
- sbuf << String(min-len, _T(' '));
+ sbuf << String(minChar-len, _T(' '));
}
else
{
- sbuf << String(min-len, _T(' '));
+ sbuf << String(minChar-len, _T(' '));
sbuf << s;
}
}
1.8 +4 -0 logging-log4cxx/src/patternlayout.cpp
Index: patternlayout.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/patternlayout.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- patternlayout.cpp 28 Feb 2004 15:07:50 -0000 1.7
+++ patternlayout.cpp 2 Apr 2004 08:33:34 -0000 1.8
@@ -77,6 +77,10 @@
{
pattern = value;
}
+ else if (StringHelper::equalsIgnoreCase(option, _T("TimeZone")))
+ {
+ timeZone = value;
+ }
}
void PatternLayout::activateOptions()
1.12 +22 -22 logging-log4cxx/src/patternparser.cpp
Index: patternparser.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/patternparser.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- patternparser.cpp 28 Feb 2004 15:07:50 -0000 1.11
+++ patternparser.cpp 2 Apr 2004 08:33:34 -0000 1.12
@@ -145,7 +145,7 @@
//LogLog.debug("Parsed LITERAL converter: \""
// +currentLiteral+"\".");
}
- currentLiteral.str(_T(""));
+ currentLiteral.seekp(0);
currentLiteral.put(c); // append %
state = CONVERTER_STATE;
formattingInfo.reset();
@@ -169,7 +169,7 @@
default:
if(c >= _T('0') && c <= _T('9'))
{
- formattingInfo.min = c - _T('0');
+ formattingInfo.minChar = c - _T('0');
state = MIN_STATE;
}
else
@@ -179,7 +179,7 @@
case MIN_STATE:
currentLiteral.put(c);
if(c >= _T('0') && c <= _T('9'))
- formattingInfo.min = formattingInfo.min*10 + (c - _T('0'));
+ formattingInfo.minChar = formattingInfo.minChar*10 + (c - _T('0'));
else if(c == _T('.'))
state = DOT_STATE;
else
@@ -191,7 +191,7 @@
currentLiteral.put(c);
if(c >= _T('0') && c <= _T('9'))
{
- formattingInfo.max = c - _T('0');
+ formattingInfo.maxChar = c - _T('0');
state = MAX_STATE;
}
else {
@@ -204,7 +204,7 @@
case MAX_STATE:
currentLiteral.put(c);
if(c >= _T('0') && c <= _T('9'))
- formattingInfo.max = formattingInfo.max*10 + (c - _T('0'));
+ formattingInfo.maxChar = formattingInfo.maxChar*10 + (c - _T('0'));
else
{
finalizeConverter(c);
@@ -235,7 +235,7 @@
extractPrecisionOption());
//LogLog::debug(_T("CATEGORY converter."));
//formattingInfo.dump();
- currentLiteral.str(_T(""));
+ currentLiteral.seekp(0);
break;
case _T('d'):
{
@@ -253,21 +253,21 @@
if(StringHelper::equalsIgnoreCase(dateFormatStr,
AbsoluteTimeDateFormat::ISO8601_DATE_FORMAT))
- df = new ISO8601DateFormat(timeZone);
+ df = new ISO8601DateFormat(TimeZone::getTimeZone(timeZone));
else if(StringHelper::equalsIgnoreCase(dateFormatStr,
AbsoluteTimeDateFormat::ABS_TIME_DATE_FORMAT))
- df = new AbsoluteTimeDateFormat(timeZone);
+ df = new AbsoluteTimeDateFormat(TimeZone::getTimeZone(timeZone));
else if(StringHelper::equalsIgnoreCase(dateFormatStr,
AbsoluteTimeDateFormat::DATE_AND_TIME_DATE_FORMAT))
- df = new DateTimeDateFormat(timeZone);
+ df = new DateTimeDateFormat(TimeZone::getTimeZone(timeZone));
else
{
- df = new DateFormat(dateFormatStr, timeZone);
+ df = new DateFormat(dateFormatStr, TimeZone::getTimeZone(timeZone));
}
pc = new DatePatternConverter(formattingInfo, df);
//LogLog.debug("DATE converter {"+dateFormatStr+"}.");
//formattingInfo.dump();
- currentLiteral.str(_T(""));
+ currentLiteral.seekp(0);
break;
}
case _T('F'):
@@ -275,14 +275,14 @@
FILE_LOCATION_CONVERTER);
//LogLog.debug("File name converter.");
//formattingInfo.dump();
- currentLiteral.str(_T(""));
+ currentLiteral.seekp(0);
break;
case _T('l'):
pc = new LocationPatternConverter(formattingInfo,
FULL_LOCATION_CONVERTER);
//LogLog.debug("Location converter.");
//formattingInfo.dump();
- currentLiteral.str(_T(""));
+ currentLiteral.seekp(0);
break;
case _T('L'):
@@ -290,20 +290,20 @@
LINE_LOCATION_CONVERTER);
//LogLog.debug("LINE NUMBER converter.");
//formattingInfo.dump();
- currentLiteral.str(_T(""));
+ currentLiteral.seekp(0);
break;
case _T('m'):
pc = new BasicPatternConverter(formattingInfo, MESSAGE_CONVERTER);
//LogLog.debug("MESSAGE converter.");
//formattingInfo.dump();
- currentLiteral.str(_T(""));
+ currentLiteral.seekp(0);
break;
case _T('p'):
{
pc = new BasicPatternConverter(formattingInfo, LEVEL_CONVERTER);
//LogLog.debug("LEVEL converter.");
//formattingInfo.dump();
- currentLiteral.str(_T(""));
+ currentLiteral.seekp(0);
}
break;
case _T('r'):
@@ -311,13 +311,13 @@
RELATIVE_TIME_CONVERTER);
//LogLog.debug("RELATIVE time converter.");
//formattingInfo.dump();
- currentLiteral.str(_T(""));
+ currentLiteral.seekp(0);
break;
case _T('t'):
pc = new BasicPatternConverter(formattingInfo, THREAD_CONVERTER);
//LogLog.debug("THREAD converter.");
//formattingInfo.dump();
- currentLiteral.str(_T(""));
+ currentLiteral.seekp(0);
break;
/*case 'u':
if(i < patternLength) {
@@ -336,20 +336,20 @@
case _T('x'):
pc = new BasicPatternConverter(formattingInfo, NDC_CONVERTER);
//LogLog.debug("NDC converter.");
- currentLiteral.str(_T(""));
+ currentLiteral.seekp(0);
break;
case _T('X'):
{
String xOpt = extractOption();
pc = new MDCPatternConverter(formattingInfo, xOpt);
- currentLiteral.str(_T(""));
+ currentLiteral.seekp(0);
break;
}
default:
LOGLOG_ERROR(_T("Unexpected char [") << c << _T("] at position ") << i
<<_T(" in conversion pattern."));
pc = new LiteralPatternConverter(currentLiteral.str());
- currentLiteral.str(_T(""));
+ currentLiteral.seekp(0);
}
addConverter(pc);
@@ -357,7 +357,7 @@
void PatternParser::addConverter(PatternConverterPtr& pc)
{
- currentLiteral.str(_T(""));
+ currentLiteral.seekp(0);
// Add the pattern converter to the list.
addToList(pc);
// Next pattern is assumed to be a literal.