public void Configuring_With_Static_Log_Should_Write_Message() { var originalLocator = Locator.InternalLocator; try { Locator.InternalLocator = new InternalLocator(); var(seriLogger, target) = CreateSerilogger(LogLevel.Debug); Log.Logger = seriLogger; Locator.CurrentMutable.UseSerilogFullLogger(); Assert.Equal(0, target.Logs.Count); IEnableLogger logger = null; logger.Log().Debug <DummyObjectClass2>("This is a test."); Assert.Equal(1, target.Logs.Count); Assert.Equal("This is a test.", target.Logs.Last().message.Trim(NewLine).Trim()); } finally { Locator.InternalLocator = originalLocator; } }
public void Configuring_With_PreConfigured_Log_Should_Write_Message() { var serilogLoggerAndTarget = GetActualSerilogLoggerAndTarget(); var target = serilogLoggerAndTarget.Target; Locator.CurrentMutable.UseSerilogFullLogger(serilogLoggerAndTarget.Logger); Assert.Equal(0, target.Logs.Count); IEnableLogger logger = null; // Will Fail logger.Log().Debug <DummyObjectClass2>("This is a test."); Assert.Equal(1, target.Logs.Count); Assert.Equal($"{typeof(DummyObjectClass2).FullName}: This is a test.", target.Logs.First()); }
public static Task <T> ErrorIfThrows <T>(this IEnableLogger This, Func <Task <T> > block, string message = null) { return(This.Log().LogIfThrows(LogLevel.Error, message, block)); }
public static void ErrorIfThrows(this IEnableLogger This, Action block, string message = null) { This.Log().LogIfThrows(LogLevel.Error, message, block); }
public static Task WarnIfThrows(this IEnableLogger This, Func <Task> block, string message = null) { return(This.Log().LogIfThrows(LogLevel.Warn, message, block)); }