public void LayoutRendererThrows() { ConfigurationItemFactory configurationItemFactory = new ConfigurationItemFactory(); configurationItemFactory.LayoutRenderers.RegisterDefinition("throwsException", typeof(ThrowsExceptionRenderer)); var cfg = new LoggingConfiguration(configurationItemFactory); SimpleLayout l = new SimpleLayout("xx${throwsException}yy", cfg); l.Initialize(cfg); string output = l.Render(LogEventInfo.CreateNullEvent()); Assert.AreEqual("xxyy", output); }
/// <summary> /// Get the headers with the column names. /// </summary> /// <returns></returns> private void RenderHeader(StringBuilder sb) { LogEventInfo logEvent = LogEventInfo.CreateNullEvent(); //Memory profiling pointed out that using a foreach-loop was allocating //an Enumerator. Switching to a for-loop avoids the memory allocation. for (int i = 0; i < Columns.Count; i++) { CsvColumn col = Columns[i]; var columnLayout = new SimpleLayout(new LayoutRenderers.LayoutRenderer[] { new LayoutRenderers.LiteralLayoutRenderer(col.Name) }, col.Name, ConfigurationItemFactory.Default); columnLayout.Initialize(LoggingConfiguration); RenderColumnLayout(logEvent, columnLayout, col._quoting ?? Quoting, sb, i); } }
public void WrapperOverAgnostic() { Layout l = new SimpleLayout("${rot13:${message}}"); l.Initialize(null); Assert.True(l.IsThreadAgnostic); }
public void AgnosticPlusAgnostic() { Layout l = new SimpleLayout("${message}${level}${logger}"); l.Initialize(null); Assert.True(l.IsThreadAgnostic); }
public void AgnosticPlusNonAgnostic() { Layout l = new SimpleLayout("${message}${threadname}"); l.Initialize(null); Assert.False(l.IsThreadAgnostic); }
public void NonThreadAgnosticTest() { Layout l = new SimpleLayout("${threadname}"); l.Initialize(null); Assert.False(l.IsThreadAgnostic); }
public void ThreadAgnosticTest() { Layout l = new SimpleLayout("${message}"); l.Initialize(null); Assert.True(l.IsThreadAgnostic); }
public void CustomAgnosticTests() { var cif = new ConfigurationItemFactory(); cif.RegisterType(typeof(CustomRendererAgnostic), string.Empty); Layout l = new SimpleLayout("${customAgnostic}", cif); l.Initialize(null); Assert.True(l.IsThreadAgnostic); }
public void TripleWrapperOverNonAgnostic() { Layout l = new SimpleLayout("${uppercase:${lowercase:${rot13:${message}${threadname}}}}"); l.Initialize(null); Assert.False(l.IsThreadAgnostic); }
public void SimpleLayoutCachingTest() { var l = new SimpleLayout("xx${level}yy"); var ev = LogEventInfo.CreateNullEvent(); l.Initialize(CommonCfg); string output1 = l.Render(ev); string output2 = l.Render(ev); Assert.AreSame(output1, output2); }
public void LayoutRendererThrows2() { string internalLogOutput = RunAndCaptureInternalLog( () => { ConfigurationItemFactory configurationItemFactory = new ConfigurationItemFactory(); configurationItemFactory.LayoutRenderers.RegisterDefinition("throwsException", typeof(ThrowsExceptionRenderer)); SimpleLayout l = new SimpleLayout("xx${throwsException:msg1}yy${throwsException:msg2}zz", new LoggingConfiguration(configurationItemFactory)); l.Initialize(CommonCfg); string output = l.Render(LogEventInfo.CreateNullEvent()); Assert.AreEqual("xxyyzz", output); }, LogLevel.Warn); Assert.IsTrue(internalLogOutput.IndexOf("msg1") >= 0, internalLogOutput); Assert.IsTrue(internalLogOutput.IndexOf("msg2") >= 0, internalLogOutput); }
public void TripleWrapperOverAgnostic() { Layout l = new SimpleLayout("${uppercase:${lowercase:${rot13:${message}}}}"); l.Initialize(CommonCfg); Assert.IsTrue(l.IsThreadAgnostic); }
public void CustomNotAgnosticTests() { var cif = new ConfigurationItemFactory(); cif.RegisterType(typeof(CustomRendererNonAgnostic), string.Empty); var cfg = new LoggingConfiguration(cif); Layout l = new SimpleLayout("${customNotAgnostic}", cfg); l.Initialize(cfg); Assert.IsFalse(l.IsThreadAgnostic); }