Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit ff8a120

Browse files
author
Victor Hurdugaci
committed
WIP
1 parent 8f5d146 commit ff8a120

File tree

5 files changed

+20
-23
lines changed

5 files changed

+20
-23
lines changed

src/Microsoft.Extensions.Logging.AzureWebAppDiagnostics/Internal/BackgroundSink.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,16 @@ public void Emit(LogEvent logEvent)
7474
/// </summary>
7575
public virtual void Dispose()
7676
{
77-
if (!_disposedTokenSource.IsCancellationRequested)
77+
lock (_disposedTokenSource)
7878
{
79-
lock (_disposedTokenSource)
79+
if (!_disposedTokenSource.IsCancellationRequested)
8080
{
81-
if (!_disposedTokenSource.IsCancellationRequested)
82-
{
83-
_disposedTokenSource.Cancel();
84-
}
85-
86-
// Wait for the thread to complete before disposing the resources
87-
_workerThread.Join();
88-
_messages.Dispose();
81+
_disposedTokenSource.Cancel();
8982
}
83+
84+
// Wait for the thread to complete before disposing the resources
85+
_workerThread.Join();
86+
_messages.Dispose();
9087
}
9188
}
9289

src/Microsoft.Extensions.Logging.AzureWebAppDiagnostics/Internal/WebAppLogConfigurationReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public WebAppLogConfigurationReader(IWebAppContext context)
3434
else
3535
{
3636
_fileLogFolder = Path.Combine(context.HomeFolder, "LogFiles", "Application");
37-
var settingsFolder = Path.Combine(context.HomeFolder, "Diagnostics");
37+
var settingsFolder = Path.Combine(context.HomeFolder, "site", "diagnostics");
3838
var settingsFile = Path.Combine(settingsFolder, "settings.json");
3939

4040
// TODO: This is a workaround because the file provider doesn't handle missing folders/files

test/Microsoft.Extensions.Logging.AzureWebAppDiagnostics.Test/BackgroundSinkTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void MessagesOrderIsMaintained()
2121
var testSink = new TestSink();
2222

2323
using (var allLogged = new ManualResetEvent(false))
24-
using (var backgroundSink = new BackgroundSink(testSink, BackgroundSink.DefaultQueueSize))
24+
using (var backgroundSink = new BackgroundSink(testSink, BackgroundSink.DefaultLogMessagesQueueSize))
2525
{
2626
testSink.Events.CollectionChanged += (sender, e) =>
2727
{

test/Microsoft.Extensions.Logging.AzureWebAppDiagnostics.Test/LogConfigurationReaderTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void OutsideOfWebAppTheConfigurationIsDisabled()
2323

2424
var configReader = new WebAppLogConfigurationReader(contextMock.Object);
2525

26-
Assert.Same(WebAppLogConfiguration.Disabled, configReader.Latest);
26+
Assert.Same(WebAppLogConfiguration.Disabled, configReader.Current);
2727
}
2828

2929
[Fact]
@@ -41,7 +41,7 @@ public void NoConfigFile()
4141

4242
using (var configReader = new WebAppLogConfigurationReader(contextMock.Object))
4343
{
44-
var config = configReader.Latest;
44+
var config = configReader.Current;
4545

4646
Assert.True(config.IsRunningInWebApp);
4747

@@ -64,7 +64,7 @@ public void ConfigurationDisabledInSettingsFile()
6464
{
6565
var logFolder = Path.Combine(tempFolder, "LogFiles", "Application");
6666

67-
var settingsFolder = Path.Combine(tempFolder, "Diagnostics");
67+
var settingsFolder = Path.Combine(tempFolder, "site", "diagnostics");
6868
var settingsFile = Path.Combine(settingsFolder, "settings.json");
6969

7070
if (!Directory.Exists(settingsFolder))
@@ -91,7 +91,7 @@ public void ConfigurationDisabledInSettingsFile()
9191

9292
using (var configReader = new WebAppLogConfigurationReader(contextMock.Object))
9393
{
94-
var config = configReader.Latest;
94+
var config = configReader.Current;
9595

9696
Assert.False(config.FileLoggingEnabled);
9797
Assert.Equal(LogLevel.Trace, config.FileLoggingLevel);
@@ -125,7 +125,7 @@ public void ConfigurationChange()
125125
{
126126
var logFolder = Path.Combine(tempFolder, "LogFiles", "Application");
127127

128-
var settingsFolder = Path.Combine(tempFolder, "Diagnostics");
128+
var settingsFolder = Path.Combine(tempFolder, "site", "diagnostics");
129129
var settingsFile = Path.Combine(settingsFolder, "settings.json");
130130

131131
if (!Directory.Exists(settingsFolder))
@@ -180,7 +180,7 @@ public void ConfigurationChange()
180180
var configChanged = configChangedEvent.WaitOne(DefaultTimeout);
181181

182182
Assert.True(configChanged);
183-
Assert.Same(config, configReader.Latest);
183+
Assert.Same(config, configReader.Current);
184184

185185
Assert.False(config.FileLoggingEnabled);
186186
Assert.Equal(LogLevel.Information, config.FileLoggingLevel);

test/Microsoft.Extensions.Logging.AzureWebAppDiagnostics.Test/SerilogLoggerProviderTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class SerilogLoggerProviderTests
1717
public void OnStartDisable()
1818
{
1919
var configReader = new Mock<IWebAppLogConfigurationReader>();
20-
configReader.SetupGet(m => m.Latest).Returns(WebAppLogConfiguration.Disabled);
20+
configReader.SetupGet(m => m.Current).Returns(WebAppLogConfiguration.Disabled);
2121

2222
// Nothing should be called on this object
2323
var testSink = new Mock<ILogEventSink>(MockBehavior.Strict);
@@ -33,7 +33,7 @@ public void OnStartDisable()
3333
public void OnStartLoggingLevel()
3434
{
3535
var configReader = new Mock<IWebAppLogConfigurationReader>();
36-
configReader.SetupGet(m => m.Latest)
36+
configReader.SetupGet(m => m.Current)
3737
.Returns(new WebAppLogConfiguration(fileLoggingEnabled: true, fileLoggingLevel: LogLevel.Information));
3838

3939
var testSink = new Mock<ILogEventSink>(MockBehavior.Strict);
@@ -54,7 +54,7 @@ public void DynamicDisable()
5454
var currentConfig = new WebAppLogConfiguration(fileLoggingEnabled: true, fileLoggingLevel: LogLevel.Information);
5555

5656
var configReader = new Mock<IWebAppLogConfigurationReader>();
57-
configReader.SetupGet(m => m.Latest)
57+
configReader.SetupGet(m => m.Current)
5858
.Returns(() => { return currentConfig; });
5959

6060
var testSink = new Mock<ILogEventSink>(MockBehavior.Strict);
@@ -82,7 +82,7 @@ public void DynamicLoggingLevel()
8282
var currentConfig = new WebAppLogConfiguration(fileLoggingEnabled: true, fileLoggingLevel: LogLevel.Critical);
8383

8484
var configReader = new Mock<IWebAppLogConfigurationReader>();
85-
configReader.SetupGet(m => m.Latest)
85+
configReader.SetupGet(m => m.Current)
8686
.Returns(() => { return currentConfig; });
8787

8888
var testSink = new Mock<ILogEventSink>(MockBehavior.Strict);
@@ -111,7 +111,7 @@ public void LevelMapping()
111111
var currentConfig = new WebAppLogConfiguration(fileLoggingEnabled: true);
112112

113113
var configReader = new Mock<IWebAppLogConfigurationReader>();
114-
configReader.SetupGet(m => m.Latest)
114+
configReader.SetupGet(m => m.Current)
115115
.Returns(() => { return currentConfig; });
116116

117117
var testSink = new Mock<ILogEventSink>(MockBehavior.Strict);

0 commit comments

Comments
 (0)