Return-Path: X-Original-To: apmail-logging-commits-archive@minotaur.apache.org Delivered-To: apmail-logging-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B124F96A3 for ; Tue, 6 Dec 2011 15:47:21 +0000 (UTC) Received: (qmail 55657 invoked by uid 500); 6 Dec 2011 15:47:21 -0000 Delivered-To: apmail-logging-commits-archive@logging.apache.org Received: (qmail 55633 invoked by uid 500); 6 Dec 2011 15:47:21 -0000 Mailing-List: contact commits-help@logging.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@logging.apache.org Delivered-To: mailing list commits@logging.apache.org Received: (qmail 55626 invoked by uid 99); 6 Dec 2011 15:47:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Dec 2011 15:47:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Dec 2011 15:47:17 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id AF18723888D2; Tue, 6 Dec 2011 15:46:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1210987 - in /logging/log4net/trunk: src/ src/Layout/ tests/src/ tests/src/Layout/ Date: Tue, 06 Dec 2011 15:46:54 -0000 To: commits@logging.apache.org From: bodewig@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111206154654.AF18723888D2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bodewig Date: Tue Dec 6 15:46:53 2011 New Revision: 1210987 URL: http://svn.apache.org/viewvc?rev=1210987&view=rev Log: a PaternLayout subclass that re-evaluates header and footer on each call. Submitted by Roy Chastain. LOG4NET-316 Added: logging/log4net/trunk/src/Layout/DynamicPatternLayout.cs (with props) logging/log4net/trunk/tests/src/Layout/DynamicPatternLayoutTest.cs (with props) Modified: logging/log4net/trunk/src/log4net.vs2008.csproj logging/log4net/trunk/src/log4net.vs2010.csproj logging/log4net/trunk/tests/src/Layout/PatternLayoutTest.cs logging/log4net/trunk/tests/src/log4net.Tests.vs2003.csproj logging/log4net/trunk/tests/src/log4net.Tests.vs2008.csproj logging/log4net/trunk/tests/src/log4net.Tests.vs2010.csproj Added: logging/log4net/trunk/src/Layout/DynamicPatternLayout.cs URL: http://svn.apache.org/viewvc/logging/log4net/trunk/src/Layout/DynamicPatternLayout.cs?rev=1210987&view=auto ============================================================================== --- logging/log4net/trunk/src/Layout/DynamicPatternLayout.cs (added) +++ logging/log4net/trunk/src/Layout/DynamicPatternLayout.cs Tue Dec 6 15:46:53 2011 @@ -0,0 +1,143 @@ +#region Apache License +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to you 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.Collections; +using System.IO; + +using log4net.Core; +using log4net.Layout.Pattern; +using log4net.Util; + +namespace log4net.Layout +{ + /// + /// A flexible layout configurable with pattern string that re-evaluates on each call. + /// + /// + /// This class is built on and provides all the + /// features and capabilities of PatternLayout. PatternLayout is a 'static' class + /// in that its layout is done once at configuration time. This class will recreate + /// the layout on each reference. + /// One important difference between PatternLayout and DynamicPatternLayout is the + /// treatment of the Header and Footer parameters in the configuration. The Header and Footer + /// parameters for DynamicPatternLayout must be syntactically in the form of a PatternString, + /// but should not be marked as type log4net.Util.PatternString. Doing so causes the + /// pattern to be statically converted at configuration time and causes DynamicPatternLayout + /// to perform the same as PatternLayout. + /// Please see for complete documentation. + /// + /// <layout type="log4net.Layout.DynamicPatternLayout"> + /// <param name="Header" value="%newline**** Trace Opened Local: %date{yyyy-MM-dd HH:mm:ss.fff} UTC: %utcdate{yyyy-MM-dd HH:mm:ss.fff} ****%newline" /> + /// <param name="Footer" value="**** Trace Closed %date{yyyy-MM-dd HH:mm:ss.fff} ****%newline" /> + /// </layout> + /// + /// + public class DynamicPatternLayout: PatternLayout + { + #region Member Variables + /// + /// The header PatternString + /// + private PatternString m_headerPatternString = new PatternString(""); + + /// + /// The footer PatternString + /// + private PatternString m_footerPatternString = new PatternString(""); + #endregion + + #region Constructors + /// + /// Constructs a DynamicPatternLayout using the DefaultConversionPattern + /// + /// + /// + /// The default pattern just produces the application supplied message. + /// + /// + public DynamicPatternLayout() + : base() + { + } + + /// + /// Constructs a DynamicPatternLayout using the supplied conversion pattern + /// + /// the pattern to use + /// + /// + public DynamicPatternLayout (string pattern) + : base(pattern) + { + } + #endregion + + #region Override implementation of LayoutSkeleton + /// + /// The header for the layout format. + /// + /// the layout header + /// + /// + /// The Header text will be appended before any logging events + /// are formatted and appended. + /// + /// The pattern will be formatted on each get operation. + /// + public override string Header + { + get + { + return m_headerPatternString.Format(); + } + set + { + base.Header = value; + m_headerPatternString = new PatternString(value); + } + } /* property DynamicPatternLayout Header */ + + /// + /// The footer for the layout format. + /// + /// the layout footer + /// + /// + /// The Footer text will be appended after all the logging events + /// have been formatted and appended. + /// + /// The pattern will be formatted on each get operation. + /// + public override string Footer + { + get + { + return m_footerPatternString.Format(); + } + set + { + base.Footer = value; + m_footerPatternString = new PatternString(value); + } + } /* property DynamicPatternLayout Footer */ + #endregion + } /* class DynamicPatternLayout */ +} /* namespace log4net.Layout */ Propchange: logging/log4net/trunk/src/Layout/DynamicPatternLayout.cs ------------------------------------------------------------------------------ svn:eol-style = native Modified: logging/log4net/trunk/src/log4net.vs2008.csproj URL: http://svn.apache.org/viewvc/logging/log4net/trunk/src/log4net.vs2008.csproj?rev=1210987&r1=1210986&r2=1210987&view=diff ============================================================================== --- logging/log4net/trunk/src/log4net.vs2008.csproj (original) +++ logging/log4net/trunk/src/log4net.vs2008.csproj Tue Dec 6 15:46:53 2011 @@ -365,6 +365,9 @@ Code + + Code + Code Modified: logging/log4net/trunk/src/log4net.vs2010.csproj URL: http://svn.apache.org/viewvc/logging/log4net/trunk/src/log4net.vs2010.csproj?rev=1210987&r1=1210986&r2=1210987&view=diff ============================================================================== --- logging/log4net/trunk/src/log4net.vs2010.csproj (original) +++ logging/log4net/trunk/src/log4net.vs2010.csproj Tue Dec 6 15:46:53 2011 @@ -1,4 +1,4 @@ - +