From 2254c9d4aa0e9ebbe66eb49c8636ce32ba5974d3 Mon Sep 17 00:00:00 2001 From: Jarek Kowalski Date: Sun, 23 Jul 2006 04:58:38 +0000 Subject: [PATCH] some defaults for the MSMQ --- NLog.build | 4 ++++ src/NLog/Internal/CurrentTimeGetter.cs | 3 ++- src/NLog/LogEventInfo.cs | 4 ---- src/NLog/Win32/Targets/MSMQ.cs | 6 ++++-- tests/NLog.Benchmark/Benchmark.cs | 16 ++++++++-------- tests/NLog.Benchmark/Log4NetBenchmark.cs | 13 +++++++++---- .../Log4NetWithFastLoggerBenchmark.cs | 8 ++++++++ tests/NLog.Test/App.config | 4 +++- tests/NLog.Test/Test.cs | 2 +- 9 files changed, 39 insertions(+), 21 deletions(-) diff --git a/NLog.build b/NLog.build index fbc00958..4273aa80 100644 --- a/NLog.build +++ b/NLog.build @@ -389,6 +389,10 @@ + + + + diff --git a/src/NLog/Internal/CurrentTimeGetter.cs b/src/NLog/Internal/CurrentTimeGetter.cs index b92b3721..a0fd1035 100644 --- a/src/NLog/Internal/CurrentTimeGetter.cs +++ b/src/NLog/Internal/CurrentTimeGetter.cs @@ -50,7 +50,8 @@ internal class CurrentTimeGetter static CurrentTimeGetter() { - // _getDelegate = new GetDelegate(NonOptimizedGet); + // this is to keep Mono compiler quiet + _getDelegate = new GetDelegate(NonOptimizedGet); _getDelegate = new GetDelegate(ThrottledGet); } diff --git a/src/NLog/LogEventInfo.cs b/src/NLog/LogEventInfo.cs index ca6d2588..59e7c85f 100644 --- a/src/NLog/LogEventInfo.cs +++ b/src/NLog/LogEventInfo.cs @@ -352,16 +352,12 @@ private bool NeedToPreformatMessage(object[] parameters) return false; } - private static Assembly _mscorlibAssembly = typeof(Object).Assembly; - private bool IsSafeToDeferFormatting(object value) { if (value == null) return true; return (value.GetType().IsPrimitive || value is string); - - //return value.GetType().Assembly == _mscorlibAssembly; } } } diff --git a/src/NLog/Win32/Targets/MSMQ.cs b/src/NLog/Win32/Targets/MSMQ.cs index aa8f6afd..0c466a26 100644 --- a/src/NLog/Win32/Targets/MSMQ.cs +++ b/src/NLog/Win32/Targets/MSMQ.cs @@ -38,6 +38,7 @@ using System.Text; using NLog.Config; +using System.ComponentModel; namespace NLog.Win32.Targets { @@ -67,9 +68,9 @@ namespace NLog.Win32.Targets [SupportedRuntime(Framework=RuntimeFramework.DotNetFramework)] [SupportedRuntime(Framework=RuntimeFramework.DotNetCompactFramework,MinRuntimeVersion="2.0")] public class MSMQTarget : TargetWithLayout - { + { private Layout _queue; - private Layout _label; + private Layout _label = new Layout("NLog"); private bool _createIfNotExists; private Encoding _encoding = System.Text.Encoding.UTF8; private bool _useXmlEncoding; @@ -98,6 +99,7 @@ public string Queue /// By default no label is associated. /// [AcceptsLayout] + [DefaultValue("NLog")] public string Label { get { return _label.Text; } diff --git a/tests/NLog.Benchmark/Benchmark.cs b/tests/NLog.Benchmark/Benchmark.cs index 624c709a..aadbbd72 100644 --- a/tests/NLog.Benchmark/Benchmark.cs +++ b/tests/NLog.Benchmark/Benchmark.cs @@ -281,9 +281,9 @@ public static int Main(string[] args) xtw.WriteProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"Graph.xsl\""); xtw.WriteStartElement("results"); - DoBenchmark(xtw, new NLogBenchmark()); + // DoBenchmark(xtw, new Log4NetWithFastLoggerBenchmark()); DoBenchmark(xtw, new Log4NetBenchmark()); - //DoBenchmark(xtw, new Log4NetWithFastLoggerBenchmark()); + DoBenchmark(xtw, new NLogBenchmark()); xtw.WriteStartElement("scale"); xtw.WriteAttributeString("max", Convert.ToInt32(_maxmax).ToString()); xtw.WriteEndElement(); @@ -318,6 +318,11 @@ private static void DoBenchmark(XmlTextWriter xtw, IBenchmark b) string sourceCode = GenerateTestSourceCode(b); + using (StreamWriter sw = File.CreateText("BenchmarkAssembly." + b.Name + ".cs")) + { + sw.Write(sourceCode); + } + CompilerResults results = provider.CreateCompiler().CompileAssemblyFromSource(options, sourceCode); foreach (CompilerError ce in results.Errors) { @@ -329,11 +334,6 @@ private static void DoBenchmark(XmlTextWriter xtw, IBenchmark b) return; } - using (StreamWriter sw = File.CreateText("BenchmarkAssembly." + b.Name + ".cs")) - { - sw.Write(sourceCode); - } - //Console.WriteLine("Compiled to assembly: {0}", results.CompiledAssembly.FullName); xtw.WriteStartElement("framework"); xtw.WriteAttributeString("name", b.Name); @@ -373,4 +373,4 @@ private static void DoBenchmark(XmlTextWriter xtw, IBenchmark b) } } -} \ No newline at end of file +} diff --git a/tests/NLog.Benchmark/Log4NetBenchmark.cs b/tests/NLog.Benchmark/Log4NetBenchmark.cs index d6bc56df..87baf322 100644 --- a/tests/NLog.Benchmark/Log4NetBenchmark.cs +++ b/tests/NLog.Benchmark/Log4NetBenchmark.cs @@ -4,6 +4,11 @@ namespace NLog.Benchmark { class Log4NetBenchmark : IBenchmark { + protected virtual string ConfigFile + { + get { return "log4net.config"; } + } + protected string Log4NetCommonHeader { get { @@ -15,6 +20,8 @@ protected string Log4NetCommonHeader using log4net.Util; using System.Threading; +[assembly: XmlConfigurator(ConfigFile=""" + ConfigFile + @""")] + public class NullAppender : AppenderSkeleton { override protected void Append(LoggingEvent loggingEvent) @@ -26,8 +33,7 @@ public class NullAppenderWithLayout : AppenderSkeleton { override protected void Append(LoggingEvent loggingEvent) { - string s = RenderLoggingEvent(loggingEvent); - // ignore s + RenderLoggingEvent(loggingEvent); } } @@ -191,8 +197,7 @@ public IAppender RemoveAppender(string name) public virtual string Header { get { - return Log4NetCommonHeader + @" -[assembly: XmlConfigurator(ConfigFile=""log4net.config"")]"; + return Log4NetCommonHeader; } } diff --git a/tests/NLog.Benchmark/Log4NetWithFastLoggerBenchmark.cs b/tests/NLog.Benchmark/Log4NetWithFastLoggerBenchmark.cs index 5f6b63d4..0ab4473c 100644 --- a/tests/NLog.Benchmark/Log4NetWithFastLoggerBenchmark.cs +++ b/tests/NLog.Benchmark/Log4NetWithFastLoggerBenchmark.cs @@ -4,6 +4,14 @@ namespace NLog.Benchmark { class Log4NetWithFastLoggerBenchmark : Log4NetBenchmark { + protected override string ConfigFile + { + get + { + return "Log4NetWithFastLogger.config"; + } + } + public override string Header { get diff --git a/tests/NLog.Test/App.config b/tests/NLog.Test/App.config index 27fbdb61..355c1492 100644 --- a/tests/NLog.Test/App.config +++ b/tests/NLog.Test/App.config @@ -9,7 +9,9 @@ xmlns="http://www.nlog-project.org/schemas/NLog.xsd"> - + + + diff --git a/tests/NLog.Test/Test.cs b/tests/NLog.Test/Test.cs index 82be7ff7..255b65ae 100644 --- a/tests/NLog.Test/Test.cs +++ b/tests/NLog.Test/Test.cs @@ -74,7 +74,7 @@ static void B(int a) static void Main(string[]args) { InternalLogger.LogToConsole = true; - InternalLogger.LogLevel = LogLevel.Info; + InternalLogger.LogLevel = LogLevel.Debug; for (int i = 0; i < 10000; ++i) {