You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by ni...@apache.org on 2004/12/20 00:55:46 UTC
cvs commit: logging-log4net/src/Util/PatternStringConverters UtcDatePatternConverter.cs AppDomainPatternConverter.cs DatePatternConverter.cs EnvironmentPatternConverter.cs IdentityPatternConverter.cs LiteralPatternConverter.cs NewLinePatternConverter.cs ProcessIdPatternConverter.cs PropertyPatternConverter.cs RandomStringPatternConverter.cs UserNamePatternConverter.cs
nicko 2004/12/19 15:55:46
Modified: src/Util PatternString.cs
src/Util/PatternStringConverters
AppDomainPatternConverter.cs
DatePatternConverter.cs
EnvironmentPatternConverter.cs
IdentityPatternConverter.cs
LiteralPatternConverter.cs
NewLinePatternConverter.cs
ProcessIdPatternConverter.cs
PropertyPatternConverter.cs
RandomStringPatternConverter.cs
UserNamePatternConverter.cs
Added: src/Util/PatternStringConverters UtcDatePatternConverter.cs
Log:
Updated doc comments. Added UtcDatePatternConverter
Revision Changes Path
1.9 +4 -0 logging-log4net/src/Util/PatternString.cs
Index: PatternString.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Util/PatternString.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- PatternString.cs 13 Sep 2004 07:53:39 -0000 1.8
+++ PatternString.cs 19 Dec 2004 23:55:45 -0000 1.9
@@ -91,6 +91,10 @@
s_globalRulesRegistry.Add("random", typeof(RandomStringPatternConverter));
s_globalRulesRegistry.Add("username", typeof(UserNamePatternConverter));
s_globalRulesRegistry.Add("property", typeof(PropertyPatternConverter));
+
+ s_globalRulesRegistry.Add("utcdate", typeof(UtcDatePatternConverter));
+ s_globalRulesRegistry.Add("utcDate", typeof(UtcDatePatternConverter));
+ s_globalRulesRegistry.Add("UtcDate", typeof(UtcDatePatternConverter));
}
#endregion Static Constructor
1.3 +12 -2 logging-log4net/src/Util/PatternStringConverters/AppDomainPatternConverter.cs
Index: AppDomainPatternConverter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Util/PatternStringConverters/AppDomainPatternConverter.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AppDomainPatternConverter.cs 16 Feb 2004 02:10:55 -0000 1.2
+++ AppDomainPatternConverter.cs 19 Dec 2004 23:55:45 -0000 1.3
@@ -25,16 +25,26 @@
namespace log4net.Util.PatternStringConverters
{
/// <summary>
- /// Converter to format appdomain name
+ /// Write the name of the current AppDomain to the output
/// </summary>
+ /// <remarks>
+ /// <para>
+ /// Write the name of the current AppDomain to the output writer
+ /// </para>
+ /// </remarks>
/// <author>Nicko Cadell</author>
internal sealed class AppDomainPatternConverter : PatternConverter
{
/// <summary>
- /// Convert the pattern to the rendered message
+ /// Write the name of the current AppDomain to the output
/// </summary>
/// <param name="writer">the writer to write to</param>
/// <param name="state">null, state is not set</param>
+ /// <remarks>
+ /// <para>
+ /// Writes name of the current AppDomain to the output <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
override protected void Convert(TextWriter writer, object state)
{
writer.Write( SystemInfo.ApplicationFriendlyName );
1.6 +79 -12 logging-log4net/src/Util/PatternStringConverters/DatePatternConverter.cs
Index: DatePatternConverter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Util/PatternStringConverters/DatePatternConverter.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DatePatternConverter.cs 19 Aug 2004 22:27:04 -0000 1.5
+++ DatePatternConverter.cs 19 Dec 2004 23:55:45 -0000 1.6
@@ -27,13 +27,71 @@
namespace log4net.Util.PatternStringConverters
{
/// <summary>
- /// Date pattern converter, uses a <see cref="IDateFormatter"/> to
- /// format the current local date and time for this computer.
+ /// Write the current date to the output
/// </summary>
+ /// <remarks>
+ /// <para>
+ /// Date pattern converter, uses a <see cref="IDateFormatter"/> to format
+ /// the current date and time to the writer as a string.
+ /// </para>
+ /// <para>
+ /// The value of the <see cref="log4net.Util.PatternConverter.Option"/> determines
+ /// the formatting of the date. The following values are allowed:
+ /// <list type="definition">
+ /// <listheader>
+ /// <term>Option value</term>
+ /// <description>Output</description>
+ /// </listheader>
+ /// <item>
+ /// <term>ISO8601</term>
+ /// <description>
+ /// Uses the <see cref="Iso8601DateFormatter"/> formatter.
+ /// Formats using the <c>"YYYY-MM-dd HH:mm:ss,SSS"</c> pattern.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>DATE</term>
+ /// <description>
+ /// Uses the <see cref="DateTimeDateFormatter"/> formatter.
+ /// Formats using the <c>"dd MMM YYYY HH:mm:ss,SSS"</c> for example, <c>"06 Nov 1994 15:49:37,459"</c>.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>ABSOLUTE</term>
+ /// <description>
+ /// Uses the <see cref="AbsoluteTimeDateFormatter"/> formatter.
+ /// Formats using the <c>"HH:mm:ss,SSS"</c> for example, <c>"15:49:37,459"</c>.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>other</term>
+ /// <description>
+ /// Any other pattern string uses the <see cref="SimpleDateFormatter"/> formatter.
+ /// This formatter passes the pattern string to the <see cref="DateTime"/>
+ /// <see cref="DateTime.ToString(string)"/> method.
+ /// For details on valid patterns see
+ /// <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemglobalizationdatetimeformatinfoclasstopic.asp">DateTimeFormatInfo Class</a>.
+ /// </description>
+ /// </item>
+ /// </list>
+ /// </para>
+ /// <para>
+ /// The date and time is in the local time zone and is rendered in that zone.
+ /// To output the time in Universal time see <see cref="UtcDatePatternConverter"/>.
+ /// </para>
+ /// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class DatePatternConverter : PatternConverter, IOptionHandler
+ internal class DatePatternConverter : PatternConverter, IOptionHandler
{
- private IDateFormatter m_df;
+ /// <summary>
+ /// The <see cref="IDateFormatter"/> used to render the date to a string
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="IDateFormatter"/> used to render the date to a string
+ /// </para>
+ /// </remarks>
+ protected IDateFormatter m_dateFormatter;
#region Implementation of IOptionHandler
@@ -63,26 +121,26 @@
if (string.Compare(dateFormatStr, AbsoluteTimeDateFormatter.Iso8601TimeDateFormat, true, System.Globalization.CultureInfo.InvariantCulture) == 0)
{
- m_df = new Iso8601DateFormatter();
+ m_dateFormatter = new Iso8601DateFormatter();
}
else if (string.Compare(dateFormatStr, AbsoluteTimeDateFormatter.AbsoluteTimeDateFormat, true, System.Globalization.CultureInfo.InvariantCulture) == 0)
{
- m_df = new AbsoluteTimeDateFormatter();
+ m_dateFormatter = new AbsoluteTimeDateFormatter();
}
else if (string.Compare(dateFormatStr, AbsoluteTimeDateFormatter.DateAndTimeDateFormat, true, System.Globalization.CultureInfo.InvariantCulture) == 0)
{
- m_df = new DateTimeDateFormatter();
+ m_dateFormatter = new DateTimeDateFormatter();
}
else
{
try
{
- m_df = new SimpleDateFormatter(dateFormatStr);
+ m_dateFormatter = new SimpleDateFormatter(dateFormatStr);
}
catch (Exception e)
{
LogLog.Error("DatePatternConverter: Could not instantiate SimpleDateFormatter with ["+dateFormatStr+"]", e);
- m_df = new Iso8601DateFormatter();
+ m_dateFormatter = new Iso8601DateFormatter();
}
}
}
@@ -90,15 +148,24 @@
#endregion
/// <summary>
- /// Convert the pattern into the rendered message
+ /// Write the current date to the output
/// </summary>
- /// <param name="writer">the writer to write to</param>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
/// <param name="state">null, state is not set</param>
+ /// <remarks>
+ /// <para>
+ /// Pass the current date and time to the <see cref="IDateFormatter"/>
+ /// for it to render it to the writer.
+ /// </para>
+ /// <para>
+ /// The date and time passed is in the local time zone.
+ /// </para>
+ /// </remarks>
override protected void Convert(TextWriter writer, object state)
{
try
{
- m_df.FormatDate(DateTime.Now, writer);
+ m_dateFormatter.FormatDate(DateTime.Now, writer);
}
catch (Exception ex)
{
1.6 +17 -2 logging-log4net/src/Util/PatternStringConverters/EnvironmentPatternConverter.cs
Index: EnvironmentPatternConverter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Util/PatternStringConverters/EnvironmentPatternConverter.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- EnvironmentPatternConverter.cs 7 Jun 2004 00:59:29 -0000 1.5
+++ EnvironmentPatternConverter.cs 19 Dec 2004 23:55:45 -0000 1.6
@@ -30,16 +30,31 @@
namespace log4net.Util.PatternStringConverters
{
/// <summary>
- /// Environment pattern converter expands environment variables
+ /// Write an environment variable to the output
/// </summary>
+ /// <remarks>
+ /// <para>
+ /// Write an environment variable to the output writer.
+ /// The value of the <see cref="log4net.Util.PatternConverter.Option"/> determines
+ /// the name of the variable to output.
+ /// </para>
+ /// </remarks>
/// <author>Nicko Cadell</author>
internal sealed class EnvironmentPatternConverter : PatternConverter
{
/// <summary>
- /// Convert the pattern into the rendered message
+ /// Write an environment variable to the output
/// </summary>
/// <param name="writer">the writer to write to</param>
/// <param name="state">null, state is not set</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the environment variable to the output <paramref name="writer"/>.
+ /// The name of the environment variable to output must be set
+ /// using the <see cref="log4net.Util.PatternConverter.Option"/>
+ /// property.
+ /// </para>
+ /// </remarks>
override protected void Convert(TextWriter writer, object state)
{
try
1.4 +12 -2 logging-log4net/src/Util/PatternStringConverters/IdentityPatternConverter.cs
Index: IdentityPatternConverter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Util/PatternStringConverters/IdentityPatternConverter.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IdentityPatternConverter.cs 19 Dec 2004 19:49:14 -0000 1.3
+++ IdentityPatternConverter.cs 19 Dec 2004 23:55:45 -0000 1.4
@@ -25,16 +25,26 @@
namespace log4net.Util.PatternStringConverters
{
/// <summary>
- /// Converter to include event identity
+ /// Write the current thread identity to the output
/// </summary>
+ /// <remarks>
+ /// <para>
+ /// Write the current thread identity to the output writer
+ /// </para>
+ /// </remarks>
/// <author>Nicko Cadell</author>
internal sealed class IdentityPatternConverter : PatternConverter
{
/// <summary>
- /// Convert the pattern to the rendered message
+ /// Write the current thread identity to the output
/// </summary>
/// <param name="writer">the writer to write to</param>
/// <param name="state">null, state is not set</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the current thread identity to the output <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
override protected void Convert(TextWriter writer, object state)
{
#if (NETCF || SSCLI)
1.5 +41 -7 logging-log4net/src/Util/PatternStringConverters/LiteralPatternConverter.cs
Index: LiteralPatternConverter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Util/PatternStringConverters/LiteralPatternConverter.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- LiteralPatternConverter.cs 19 Dec 2004 19:24:30 -0000 1.4
+++ LiteralPatternConverter.cs 19 Dec 2004 23:55:45 -0000 1.5
@@ -25,14 +25,34 @@
namespace log4net.Util.PatternStringConverters
{
/// <summary>
- /// Pattern converter for literal instances in the pattern
+ /// Pattern converter for literal string instances in the pattern
/// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes the literal string value specified in the
+ /// <see cref="log4net.Util.PatternConverter.Option"/> property to
+ /// the output.
+ /// </para>
+ /// </remarks>
/// <author>Nicko Cadell</author>
internal class LiteralPatternConverter : PatternConverter
{
/// <summary>
- /// the next patter converter in the chain
+ /// Set the next converter in the chain
/// </summary>
+ /// <param name="pc">The next pattern converter in the chain</param>
+ /// <returns>The next pattern converter</returns>
+ /// <remarks>
+ /// <para>
+ /// Special case the building of the pattern converter chain
+ /// for <see cref="LiteralPatternConverter"/> instances. Two adjacent
+ /// literals in the pattern can be represented by a single combined
+ /// pattern converter. This implementation detects when a
+ /// <see cref="LiteralPatternConverter"/> is added to the chain
+ /// after this converter and combines its value with this converter's
+ /// literal value.
+ /// </para>
+ /// </remarks>
public override PatternConverter SetNext(PatternConverter pc)
{
LiteralPatternConverter literalPc = pc as LiteralPatternConverter;
@@ -49,11 +69,20 @@
}
/// <summary>
- /// Override the formatting behavior to ignore the FormattingInfo
- /// because we have a literal instead.
+ /// Write the literal to the output
/// </summary>
/// <param name="writer">the writer to write to</param>
- /// <param name="state">null, state is not set</param>
+ /// <param name="state">null, not set</param>
+ /// <remarks>
+ /// <para>
+ /// Override the formatting behavior to ignore the FormattingInfo
+ /// because we have a literal instead.
+ /// </para>
+ /// <para>
+ /// Writes the value of <see cref="log4net.Util.PatternConverter.Option"/>
+ /// to the output <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
override public void Format(TextWriter writer, object state)
{
writer.Write(Option);
@@ -62,8 +91,13 @@
/// <summary>
/// Convert this pattern into the rendered message
/// </summary>
- /// <param name="writer">the writer to write to</param>
- /// <param name="state">null, state is not set</param>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="state">null, not set</param>
+ /// <remarks>
+ /// <para>
+ /// This method is not used.
+ /// </para>
+ /// </remarks>
override protected void Convert(TextWriter writer, object state)
{
throw new InvalidOperationException("Should never get here because of the overridden Format method");
1.4 +22 -2 logging-log4net/src/Util/PatternStringConverters/NewLinePatternConverter.cs
Index: NewLinePatternConverter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Util/PatternStringConverters/NewLinePatternConverter.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NewLinePatternConverter.cs 30 May 2004 10:48:26 -0000 1.3
+++ NewLinePatternConverter.cs 19 Dec 2004 23:55:45 -0000 1.4
@@ -26,15 +26,35 @@
namespace log4net.Util.PatternStringConverters
{
/// <summary>
- /// Pattern converter for literal instances in the pattern
+ /// Writes a newline to the output
/// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes the system dependent line terminator to the output.
+ /// This behavior can be overridden by setting the <see cref="PatternConverter.Option"/>:
+ /// </para>
+ /// <list type="definition">
+ /// <listheader>
+ /// <term>Option Value</term>
+ /// <description>Output</description>
+ /// </listheader>
+ /// <item>
+ /// <term>DOS</term>
+ /// <description>DOS or Windows line terminator <c>"\r\n"</c></description>
+ /// </item>
+ /// <item>
+ /// <term>UNIX</term>
+ /// <description>UNIX line terminator <c>"\n"</c></description>
+ /// </item>
+ /// </list>
+ /// </remarks>
/// <author>Nicko Cadell</author>
internal sealed class NewLinePatternConverter : LiteralPatternConverter, IOptionHandler
{
#region Implementation of IOptionHandler
/// <summary>
- /// Initialize the converter options
+ /// Initialize the converter
/// </summary>
/// <remarks>
/// <para>
1.4 +12 -3 logging-log4net/src/Util/PatternStringConverters/ProcessIdPatternConverter.cs
Index: ProcessIdPatternConverter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Util/PatternStringConverters/ProcessIdPatternConverter.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ProcessIdPatternConverter.cs 19 Dec 2004 19:49:14 -0000 1.3
+++ ProcessIdPatternConverter.cs 19 Dec 2004 23:55:45 -0000 1.4
@@ -25,16 +25,26 @@
namespace log4net.Util.PatternStringConverters
{
/// <summary>
- /// Converter to format process id
+ /// Write the current process ID to the output
/// </summary>
+ /// <remarks>
+ /// <para>
+ /// Write the current process ID to the output writer
+ /// </para>
+ /// </remarks>
/// <author>Nicko Cadell</author>
internal sealed class ProcessIdPatternConverter : PatternConverter
{
/// <summary>
- /// Convert the pattern to the rendered message
+ /// Write the current process ID to the output
/// </summary>
/// <param name="writer">the writer to write to</param>
/// <param name="state">null, state is not set</param>
+ /// <remarks>
+ /// <para>
+ /// Write the current process ID to the output <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
override protected void Convert(TextWriter writer, object state)
{
#if (NETCF || SSCLI)
@@ -54,7 +64,6 @@
writer.Write( "NOT AVAILABLE" );
}
#endif
-
}
}
}
1.3 +13 -3 logging-log4net/src/Util/PatternStringConverters/PropertyPatternConverter.cs
Index: PropertyPatternConverter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Util/PatternStringConverters/PropertyPatternConverter.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PropertyPatternConverter.cs 26 Sep 2004 23:21:52 -0000 1.2
+++ PropertyPatternConverter.cs 19 Dec 2004 23:55:45 -0000 1.3
@@ -48,11 +48,21 @@
internal sealed class PropertyPatternConverter : PatternConverter
{
/// <summary>
- /// Write the property or specified properties as required
+ /// Write the property value to the output
/// </summary>
/// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="state">reserved</param>
- /// <returns>the result of converting the pattern</returns>
+ /// <param name="state">null, state is not set</param>
+ /// <remarks>
+ /// <para>
+ /// Writes out the value of a named property. The property name
+ /// should be set in the <see cref="log4net.Util.PatternConverter.Option"/>
+ /// property.
+ /// </para>
+ /// <para>
+ /// If the <see cref="log4net.Util.PatternConverter.Option"/> is set to <c>null</c>
+ /// then all the properties are written as key value pairs.
+ /// </para>
+ /// </remarks>
override protected void Convert(TextWriter writer, object state)
{
CompositeProperties compositeProperties = new CompositeProperties();
1.3 +6 -1 logging-log4net/src/Util/PatternStringConverters/RandomStringPatternConverter.cs
Index: RandomStringPatternConverter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Util/PatternStringConverters/RandomStringPatternConverter.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RandomStringPatternConverter.cs 1 Oct 2004 20:58:48 -0000 1.2
+++ RandomStringPatternConverter.cs 19 Dec 2004 23:55:45 -0000 1.3
@@ -93,10 +93,15 @@
#endregion
/// <summary>
- /// Convert the pattern into the rendered message
+ /// Write a randoim string to the output
/// </summary>
/// <param name="writer">the writer to write to</param>
/// <param name="state">null, state is not set</param>
+ /// <remarks>
+ /// <para>
+ /// Write a randoim string to the output <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
override protected void Convert(TextWriter writer, object state)
{
try
1.4 +12 -2 logging-log4net/src/Util/PatternStringConverters/UserNamePatternConverter.cs
Index: UserNamePatternConverter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Util/PatternStringConverters/UserNamePatternConverter.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- UserNamePatternConverter.cs 19 Dec 2004 19:49:14 -0000 1.3
+++ UserNamePatternConverter.cs 19 Dec 2004 23:55:45 -0000 1.4
@@ -25,16 +25,26 @@
namespace log4net.Util.PatternStringConverters
{
/// <summary>
- /// Converter to include event user name
+ /// Write the current threads username to the output
/// </summary>
+ /// <remarks>
+ /// <para>
+ /// Write the current threads username to the output writer
+ /// </para>
+ /// </remarks>
/// <author>Nicko Cadell</author>
internal sealed class UserNamePatternConverter : PatternConverter
{
/// <summary>
- /// Convert the pattern to the rendered message
+ /// Write the current threads username to the output
/// </summary>
/// <param name="writer">the writer to write to</param>
/// <param name="state">null, state is not set</param>
+ /// <remarks>
+ /// <para>
+ /// Write the current threads username to the output <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
override protected void Convert(TextWriter writer, object state)
{
#if (NETCF || SSCLI)
1.1 logging-log4net/src/Util/PatternStringConverters/UtcDatePatternConverter.cs
Index: UtcDatePatternConverter.cs
===================================================================
#region Copyright & License
//
// Copyright 2001-2004 The Apache Software Foundation
//
// 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.
//
#endregion
using System;
using System.Text;
using System.IO;
using log4net.Core;
using log4net.Util;
using log4net.DateFormatter;
namespace log4net.Util.PatternStringConverters
{
/// <summary>
/// Write the UTC date time to the output
/// </summary>
/// <remarks>
/// <para>
/// Date pattern converter, uses a <see cref="IDateFormatter"/> to format
/// the current date and time in Universal time.
/// </para>
/// <para>
/// See the <see cref="DatePatternConverter"/> for details on the date pattern syntax.
/// </para>
/// </remarks>
/// <seealso cref="DatePatternConverter"/>
/// <author>Nicko Cadell</author>
internal class UtcDatePatternConverter : DatePatternConverter
{
/// <summary>
/// Write the current date and time to the output
/// </summary>
/// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
/// <param name="state">null, state is not set</param>
/// <remarks>
/// <para>
/// Pass the current date and time to the <see cref="IDateFormatter"/>
/// for it to render it to the writer.
/// </para>
/// <para>
/// The date is in Universal time when it is rendered.
/// </para>
/// </remarks>
/// <seealso cref="DatePatternConverter"/>
override protected void Convert(TextWriter writer, object state)
{
try
{
m_dateFormatter.FormatDate(DateTime.UtcNow, writer);
}
catch (Exception ex)
{
LogLog.Error("UtcDatePatternConverter: Error occurred while converting date.", ex);
}
}
}
}