mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-08 09:38:25 -05:00
Bug fix for https://github.com/Microsoft/azuredatastudio/issues/2923 and misc other fixes (#711)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
using Xunit;
|
||||
@@ -333,6 +334,33 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
TestTracingLevelChangeFromWarningToError(test);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests out AutoFlush funcitonality. The verification is two fold.
|
||||
/// 1st is to verify that the setting is persistent.
|
||||
/// 2nd that after a lot of log entries are written with AutoFlush on, explicitly flushing and closing the Tracing does not increase the file size
|
||||
/// thereby verifying that there was no leftover log entries being left behind to be flushed.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void LoggerAutolFlush()
|
||||
{
|
||||
// setup the test object
|
||||
TestLogger test = new TestLogger()
|
||||
{
|
||||
TraceSource = MethodInfo.GetCurrentMethod().Name,
|
||||
AutoFlush = true,
|
||||
TracingLevel = SourceLevels.All
|
||||
};
|
||||
test.Initialize();
|
||||
// Write 10000 lines of log
|
||||
Parallel.For(0, 100, (i) => test.Write($"Message Number:{i}, Message:{test.LogMessage}"));
|
||||
long logContentsSizeBeforeExplicitFlush = (new FileInfo(test.LogFileName)).Length;
|
||||
// Please note that Logger.Close() first flushes the logs before closing them out.
|
||||
Logger.Flush();
|
||||
long logContentsSizeAfterExplicitFlush = (new FileInfo(test.LogFileName)).Length;
|
||||
Assert.True(logContentsSizeBeforeExplicitFlush == logContentsSizeAfterExplicitFlush, "The length of log file with autoflush before and after explicit flush must be same");
|
||||
test.Cleanup();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When not use TraceSource, test to verify that upon changing TracingLevel from Error To Warning,
|
||||
/// after the change, messages of Warning as well as of Error type are present in the log.
|
||||
|
||||
Reference in New Issue
Block a user