Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
some defaults for the MSMQ
Browse files Browse the repository at this point in the history
  • Loading branch information
jkowalski committed Jul 23, 2006
1 parent 59bbdd5 commit 2254c9d
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 21 deletions.
4 changes: 4 additions & 0 deletions NLog.build
Expand Up @@ -389,6 +389,10 @@
<exec program="${nlog.dir}/NLog.Benchmark-lab.exe" workingdir="${nlog.dir}" commandline="Benchmark-lab.xml ${benchmark.mode}" />
</target>

<target name="pfiles">
<property name="nlog.dir" value="${environment::get-folder-path('ProgramFiles')}\NLog\bin\${framework::get-target-framework()}" unless="${property::exists('nlog.dir')}" />
</target>

<target name="NLogC" depends="NLog, NLogC-${framework::get-target-framework()}">
<copy todir="${nlog.dir}/include">
<fileset basedir="tests/NLogC">
Expand Down
3 changes: 2 additions & 1 deletion src/NLog/Internal/CurrentTimeGetter.cs
Expand Up @@ -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);
}

Expand Down
4 changes: 0 additions & 4 deletions src/NLog/LogEventInfo.cs
Expand Up @@ -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;
}
}
}
6 changes: 4 additions & 2 deletions src/NLog/Win32/Targets/MSMQ.cs
Expand Up @@ -38,6 +38,7 @@
using System.Text;

using NLog.Config;
using System.ComponentModel;

namespace NLog.Win32.Targets
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -98,6 +99,7 @@ public string Queue
/// By default no label is associated.
/// </remarks>
[AcceptsLayout]
[DefaultValue("NLog")]
public string Label
{
get { return _label.Text; }
Expand Down
16 changes: 8 additions & 8 deletions tests/NLog.Benchmark/Benchmark.cs
Expand Up @@ -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();
Expand Down Expand Up @@ -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)
{
Expand All @@ -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);
Expand Down Expand Up @@ -373,4 +373,4 @@ private static void DoBenchmark(XmlTextWriter xtw, IBenchmark b)
}
}

}
}
13 changes: 9 additions & 4 deletions tests/NLog.Benchmark/Log4NetBenchmark.cs
Expand Up @@ -4,6 +4,11 @@ namespace NLog.Benchmark
{
class Log4NetBenchmark : IBenchmark
{
protected virtual string ConfigFile
{
get { return "log4net.config"; }
}

protected string Log4NetCommonHeader
{
get {
Expand All @@ -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)
Expand All @@ -26,8 +33,7 @@ public class NullAppenderWithLayout : AppenderSkeleton
{
override protected void Append(LoggingEvent loggingEvent)
{
string s = RenderLoggingEvent(loggingEvent);
// ignore s
RenderLoggingEvent(loggingEvent);
}
}
Expand Down Expand Up @@ -191,8 +197,7 @@ public IAppender RemoveAppender(string name)
public virtual string Header
{
get {
return Log4NetCommonHeader + @"
[assembly: XmlConfigurator(ConfigFile=""log4net.config"")]";
return Log4NetCommonHeader;
}
}

Expand Down
8 changes: 8 additions & 0 deletions tests/NLog.Benchmark/Log4NetWithFastLoggerBenchmark.cs
Expand Up @@ -4,6 +4,14 @@ namespace NLog.Benchmark
{
class Log4NetWithFastLoggerBenchmark : Log4NetBenchmark
{
protected override string ConfigFile
{
get
{
return "Log4NetWithFastLogger.config";
}
}

public override string Header
{
get
Expand Down
4 changes: 3 additions & 1 deletion tests/NLog.Test/App.config
Expand Up @@ -9,7 +9,9 @@
xmlns="http://www.nlog-project.org/schemas/NLog.xsd">

<targets>
<target name="n" xsi:type="Console" layout="${processinfo:property=MaxWorkingSet} ${gc:property=MaxGeneration}" />
<target name="n" xsi:type="MSMQ" queue=".\private$\NLogViewer">
<layout xsi:type="Log4JXmlEventLayout" />
</target>
</targets>

<rules>
Expand Down
2 changes: 1 addition & 1 deletion tests/NLog.Test/Test.cs
Expand Up @@ -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)
{
Expand Down

0 comments on commit 2254c9d

Please sign in to comment.