Permalink
Browse files

BUG 6545: LogReceiverForwardingService does not parse parameters corr…

…ectly
  • Loading branch information...
1 parent 079dadd commit 853e37a715aff2e72cbdbca729945a24faba3e50 @jkowalski committed Nov 1, 2011
@@ -31,7 +31,7 @@
// THE POSSIBILITY OF SUCH DAMAGE.
//
-#if WCF_SUPPORTED
+#if WCF_SUPPORTED && !SILVERLIGHT && !NET_CF
namespace NLog.LogReceiverService
{
@@ -31,7 +31,7 @@
// THE POSSIBILITY OF SUCH DAMAGE.
//
-#if WCF_SUPPORTED
+#if WCF_SUPPORTED && !SILVERLIGHT && !NET_CF
namespace NLog.LogReceiverService
{
@@ -86,7 +86,7 @@ public void ProcessLogMessages(NLogEvents events)
logEventInfo.Properties.Add("ClientName", events.ClientName);
for (int i = 0; i < events.LayoutNames.Count; ++i)
{
- logEventInfo.Properties.Add(events.LayoutNames[i], ev.Values[i]);
+ logEventInfo.Properties.Add(events.LayoutNames[i], events.Strings[ev.ValueIndexes[i]]);
}
logEvents[j] = logEventInfo;
@@ -0,0 +1,110 @@
+//
+// Copyright (c) 2004-2011 Jaroslaw Kowalski <jaak@jkowalski.net>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * 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.
+//
+// * Neither the name of Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS 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 COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, 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.
+//
+
+#if WCF_SUPPORTED && !SILVERLIGHT && !NET_CF
+
+namespace NLog.UnitTests.LogReceiverService
+{
+ using System;
+ using NUnit.Framework;
+
+#if !NUNIT
+ using SetUp = Microsoft.VisualStudio.TestTools.UnitTesting.TestInitializeAttribute;
+ using TestFixture = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
+ using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
+ using TearDown = Microsoft.VisualStudio.TestTools.UnitTesting.TestCleanupAttribute;
+#endif
+ using NLog.LogReceiverService;
+
+ [TestFixture]
+ public class LogReceiverForwardingServiceTests : NLogTestBase
+ {
+ [Test]
+ public void ToLogEventInfoTest()
+ {
+ LogManager.Configuration = CreateConfigurationFromString(@"
+ <nlog>
+ <targets>
+ <target name='debug1' type='Debug' layout='${message} ${event-context:foo} ${event-context:bar} ${event-context:baz}' />
+ <target name='debug2' type='Debug' layout='${message} ${event-context:foo} ${event-context:bar} ${event-context:baz}' />
+ <target name='debug3' type='Debug' layout='${message} ${event-context:foo} ${event-context:bar} ${event-context:baz}' />
+ </targets>
+ <rules>
+ <logger name='logger1' minlevel='Trace' writeTo='debug1' />
+ <logger name='logger2' minlevel='Trace' writeTo='debug2' />
+ <logger name='logger3' minlevel='Trace' writeTo='debug3' />
+ </rules>
+ </nlog>");
+
+ var service = new LogReceiverForwardingService();
+ var events = new NLogEvents
+ {
+ BaseTimeUtc = new DateTime(2010, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).Ticks,
+ ClientName = "foo",
+ LayoutNames = new StringCollection { "foo", "bar", "baz" },
+ Strings = new StringCollection { "logger1", "logger2", "logger3", "zzz", "message1" },
+ Events =
+ new[]
+ {
+ new NLogEvent
+ {
+ Id = 1,
+ LevelOrdinal = 2,
+ LoggerOrdinal = 0,
+ TimeDelta = 30000000,
+ MessageOrdinal = 4,
+ Values = "0|1|2"
+ },
+ new NLogEvent
+ {
+ Id = 2,
+ LevelOrdinal = 3,
+ LoggerOrdinal = 2,
+ MessageOrdinal = 4,
+ TimeDelta = 30050000,
+ Values = "0|1|3",
+ }
+ }
+ };
+
+ service.ProcessLogMessages(events);
+ this.AssertDebugCounter("debug1", 1);
+ this.AssertDebugCounter("debug2", 0);
+ this.AssertDebugCounter("debug3", 1);
+ this.AssertDebugLastMessage("debug1", "message1 logger1 logger2 logger3");
+ this.AssertDebugLastMessage("debug3", "message1 logger1 logger2 zzz");
+ }
+ }
+}
+
+#endif
@@ -128,6 +128,7 @@
<Compile Include="LoggerTests.cs" />
<Compile Include="LogLevelTests.cs" />
<Compile Include="LogManagerTests.cs" />
+ <Compile Include="LogReceiverService\LogReceiverForwardingServiceTests.cs" />
<Compile Include="LogReceiverService\LogReceiverServiceTests.cs" />
<Compile Include="NLogTestBase.cs" />
<Compile Include="NLogTraceListenerTests.cs" />
@@ -131,6 +131,7 @@
<Compile Include="LoggerTests.cs" />
<Compile Include="LogLevelTests.cs" />
<Compile Include="LogManagerTests.cs" />
+ <Compile Include="LogReceiverService\LogReceiverForwardingServiceTests.cs" />
<Compile Include="LogReceiverService\LogReceiverServiceTests.cs" />
<Compile Include="NLogTestBase.cs" />
<Compile Include="NLogTraceListenerTests.cs" />
@@ -129,6 +129,7 @@
<Compile Include="LoggerTests.cs" />
<Compile Include="LogLevelTests.cs" />
<Compile Include="LogManagerTests.cs" />
+ <Compile Include="LogReceiverService\LogReceiverForwardingServiceTests.cs" />
<Compile Include="LogReceiverService\LogReceiverServiceTests.cs" />
<Compile Include="NLogTestBase.cs" />
<Compile Include="NLogTraceListenerTests.cs" />
@@ -129,6 +129,7 @@
<Compile Include="LoggerTests.cs" />
<Compile Include="LogLevelTests.cs" />
<Compile Include="LogManagerTests.cs" />
+ <Compile Include="LogReceiverService\LogReceiverForwardingServiceTests.cs" />
<Compile Include="LogReceiverService\LogReceiverServiceTests.cs" />
<Compile Include="NLogTestBase.cs" />
<Compile Include="NLogTraceListenerTests.cs" />
@@ -131,6 +131,7 @@
<Compile Include="LoggerTests.cs" />
<Compile Include="LogLevelTests.cs" />
<Compile Include="LogManagerTests.cs" />
+ <Compile Include="LogReceiverService\LogReceiverForwardingServiceTests.cs" />
<Compile Include="LogReceiverService\LogReceiverServiceTests.cs" />
<Compile Include="NLogTestBase.cs" />
<Compile Include="NLogTraceListenerTests.cs" />
@@ -9,8 +9,10 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <ApplicationIcon></ApplicationIcon>
- <AssemblyKeyContainerName></AssemblyKeyContainerName>
+ <ApplicationIcon>
+ </ApplicationIcon>
+ <AssemblyKeyContainerName>
+ </AssemblyKeyContainerName>
<AssemblyName>NLog.UnitTests</AssemblyName>
<AssemblyOriginatorKeyFile>NLogTests.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
@@ -128,6 +130,7 @@
<Compile Include="LoggerTests.cs" />
<Compile Include="LogLevelTests.cs" />
<Compile Include="LogManagerTests.cs" />
+ <Compile Include="LogReceiverService\LogReceiverForwardingServiceTests.cs" />
<Compile Include="LogReceiverService\LogReceiverServiceTests.cs" />
<Compile Include="NLogTestBase.cs" />
<Compile Include="NLogTraceListenerTests.cs" />
@@ -159,6 +159,7 @@
<Compile Include="LoggerTests.cs" />
<Compile Include="LogLevelTests.cs" />
<Compile Include="LogManagerTests.cs" />
+ <Compile Include="LogReceiverService\LogReceiverForwardingServiceTests.cs" />
<Compile Include="LogReceiverService\LogReceiverServiceTests.cs" />
<Compile Include="NLogTestBase.cs" />
<Compile Include="NLogTraceListenerTests.cs" />
@@ -145,6 +145,7 @@
<Compile Include="LoggerTests.cs" />
<Compile Include="LogLevelTests.cs" />
<Compile Include="LogManagerTests.cs" />
+ <Compile Include="LogReceiverService\LogReceiverForwardingServiceTests.cs" />
<Compile Include="LogReceiverService\LogReceiverServiceTests.cs" />
<Compile Include="NLogTestBase.cs" />
<Compile Include="NLogTraceListenerTests.cs" />
@@ -146,6 +146,7 @@
<Compile Include="LoggerTests.cs" />
<Compile Include="LogLevelTests.cs" />
<Compile Include="LogManagerTests.cs" />
+ <Compile Include="LogReceiverService\LogReceiverForwardingServiceTests.cs" />
<Compile Include="LogReceiverService\LogReceiverServiceTests.cs" />
<Compile Include="NLogTestBase.cs" />
<Compile Include="NLogTraceListenerTests.cs" />
@@ -138,6 +138,7 @@
<Compile Include="LoggerTests.cs" />
<Compile Include="LogLevelTests.cs" />
<Compile Include="LogManagerTests.cs" />
+ <Compile Include="LogReceiverService\LogReceiverForwardingServiceTests.cs" />
<Compile Include="LogReceiverService\LogReceiverServiceTests.cs" />
<Compile Include="NLogTestBase.cs" />
<Compile Include="NLogTraceListenerTests.cs" />
@@ -138,6 +138,7 @@
<Compile Include="LoggerTests.cs" />
<Compile Include="LogLevelTests.cs" />
<Compile Include="LogManagerTests.cs" />
+ <Compile Include="LogReceiverService\LogReceiverForwardingServiceTests.cs" />
<Compile Include="LogReceiverService\LogReceiverServiceTests.cs" />
<Compile Include="NLogTestBase.cs" />
<Compile Include="NLogTraceListenerTests.cs" />

0 comments on commit 853e37a

Please sign in to comment.