private void SendBuffer( IEnumerable <LoggingEvent> buffer, long loggingEventsLost) { var xml = MakeBodyXml(Layout, buffer); LogLog.Debug(typeof(HtmlSmtpAppender), xml); var html = MakeBodyHtml(xml, loggingEventsLost); LogLog.Debug(typeof(HtmlSmtpAppender), html); SendEmail( StringFormatterUtil.Format(Subject, buffer, loggingEventsLost), html); }
public void TestEventsClass() { var loggingEvents = new[] { new LoggingEvent( Log.GetType(), LogManager.GetRepository(Assembly.GetCallingAssembly()), Log.Logger.Name, Level.Emergency, "An emergency", new ArgumentException("Sample exception")), new LoggingEvent( Log.GetType(), LogManager.GetRepository(Assembly.GetCallingAssembly()), Log.Logger.Name, Level.Info, "Some information", new ArgumentException("Sample exception")), new LoggingEvent( Log.GetType(), LogManager.GetRepository(Assembly.GetCallingAssembly()), Log.Logger.Name, Level.Debug, "Debug 1", new ArgumentException("Sample exception")), new LoggingEvent( Log.GetType(), LogManager.GetRepository(Assembly.GetCallingAssembly()), Log.Logger.Name, Level.Debug, "Debug 2", null), }; loggingEvents[0].Properties[HtmlSmtpAppender.IsTriggerLoggingEvent] = true; Assert.AreEqual( "total=4 u=1 r=0 i=1 d=2", StringFormatterUtil.Format( "total=%events{total} u=%events{class.unrecoverable} r=%events{class.recoverable} i=%events{class.information} d=%events{class.debug}", loggingEvents, 45)); }
public void TestEvents() { var loggingEvents = new[] { new LoggingEvent( Log.GetType(), LogManager.GetRepository(Assembly.GetCallingAssembly()), Log.Logger.Name, Level.Emergency, "An emergency", new ArgumentException("Sample exception")), new LoggingEvent( Log.GetType(), LogManager.GetRepository(Assembly.GetCallingAssembly()), Log.Logger.Name, Level.Info, "Some information", new ArgumentException("Sample exception")), new LoggingEvent( Log.GetType(), LogManager.GetRepository(Assembly.GetCallingAssembly()), Log.Logger.Name, Level.Debug, "Debug 1", new ArgumentException("Sample exception")), new LoggingEvent( Log.GetType(), LogManager.GetRepository(Assembly.GetCallingAssembly()), Log.Logger.Name, Level.Debug, "Debug 2", null), }; loggingEvents[0].Properties[HtmlSmtpAppender.IsTriggerLoggingEvent] = true; Assert.AreEqual( "total=4 trig=1 ~trig=3 f=0 f=1 i=1 d=2 lost=45 total=4", StringFormatterUtil.Format( "total=%events{total} trig=%events{triggering} ~trig=%events{nontriggering} f=%events{fatal} f=%events{emergency} i=%events{info} d=%events{debug} lost=%events{lost} total=%events", loggingEvents, 45)); }
public void TestPath() { Assert.AreEqual( string.Format("Path is {0}", Environment.GetEnvironmentVariable("Path")), StringFormatterUtil.Format("Path is %env{Path}", null, 0)); }
public void TestPercent() { Assert.AreEqual("single %, and two %%", StringFormatterUtil.Format("single %%, and two %%%%", null, 0)); }
public void TestEmpty() { Assert.AreEqual("", StringFormatterUtil.Format("", null, 0)); }