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

Commit 9847000

Browse files
committed
Adress PR comments
1 parent 2de4588 commit 9847000

File tree

6 files changed

+75
-46
lines changed

6 files changed

+75
-46
lines changed

src/Microsoft.Extensions.Logging.AzureWebAppDiagnostics/AzureWebAppDiagnosticsFactoryExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static class AzureWebAppDiagnosticsFactoryExtensions
1717
/// <param name="factory">The extension method argument</param>
1818
public static ILoggerFactory AddAzureWebAppDiagnostics(this ILoggerFactory factory)
1919
{
20-
return AddAzureWebAppDiagnostics(factory, null);
20+
return AddAzureWebAppDiagnostics(factory, new AzureWebAppDiagnosticsSettings());
2121
}
2222

2323
/// <summary>

src/Microsoft.Extensions.Logging.AzureWebAppDiagnostics/AzureWebAppDiagnosticsSettings.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,32 @@ namespace Microsoft.Extensions.Logging.AzureWebAppDiagnostics
1111
public class AzureWebAppDiagnosticsSettings
1212
{
1313
/// <summary>
14-
/// A strictly positive value representing the maximum log size in bytes. Once the log is full, no more message will be appended
14+
/// Gets or sets a strictly positive value representing the maximum log size in bytes. Once the log is full, no more message will be appended
1515
/// </summary>
1616
public int FileSizeLimit { get; set; } = 10 * 1024 * 1024;
1717

1818
/// <summary>
19-
/// A strictly positive value representing the maximum retained file count
19+
/// Gets or sets a strictly positive value representing the maximum retained file count
2020
/// </summary>
2121
public int RetainedFileCountLimit { get; set; } = 2;
2222

2323
/// <summary>
24-
/// A message template describing the output messages
24+
/// Gets or sets a message template describing the output messages
2525
/// </summary>
2626
public string OutputTemplate { get; set; } = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}";
2727

2828
/// <summary>
29-
/// The maximum number of events to include in a single blob append batch.
29+
/// Gets or sets a maximum number of events to include in a single blob append batch.
3030
/// </summary>
3131
public int BlobBatchSize { get; set; } = 32;
3232

3333
/// <summary>
34-
/// The time to wait between checking for blob log batches
34+
/// Gets or sets a time to wait between checking for blob log batches
3535
/// </summary>
3636
public TimeSpan BlobCommitPeriod { get; set; } = TimeSpan.FromSeconds(5);
3737

3838
/// <summary>
39-
/// The last section of log blob name.
39+
/// Gets or sets the last section of log blob name.
4040
/// </summary>
4141
public string BlobName { get; set; } = "applicationLog.txt";
4242
}

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

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
namespace Microsoft.Extensions.Logging.AzureWebAppDiagnostics.Internal
1111
{
1212
/// <summary>
13-
/// The <see cref="SerilogLoggerProvider"/> implemenation that creates instances of <see cref="Serilog.Core.Logger"/> connected to <see cref="AzureBlobSink"/>.
13+
/// The implemenation of logger provider that creates instances of <see cref="Serilog.Core.Logger"/> connected to <see cref="AzureBlobSink"/>.
1414
/// </summary>
15-
public class AzureBlobLoggerProvider : SerilogLoggerProvider
15+
public class AzureBlobLoggerProvider
1616
{
1717
private readonly string _outputTemplate;
1818
private readonly string _appName;
@@ -23,13 +23,34 @@ public class AzureBlobLoggerProvider : SerilogLoggerProvider
2323
/// <summary>
2424
/// Creates a new instance of the <see cref="AzureBlobLoggerProvider"/> class.
2525
/// </summary>
26-
/// <param name="outputTemplate"></param>
27-
/// <param name="appName"></param>
28-
/// <param name="fileName"></param>
29-
/// <param name="batchSize"></param>
30-
/// <param name="period"></param>
26+
/// <param name="outputTemplate">A message template describing the output messages</param>
27+
/// <param name="appName">The application name to use in blob name</param>
28+
/// <param name="fileName">The last section in log blob name</param>
29+
/// <param name="batchSize">A maximum number of events to include in a single blob append batch</param>
30+
/// <param name="period">A time to wait between checking for blob log batches</param>
3131
public AzureBlobLoggerProvider(string outputTemplate, string appName, string fileName, int batchSize, TimeSpan period)
3232
{
33+
if (outputTemplate == null)
34+
{
35+
throw new ArgumentNullException(nameof(outputTemplate));
36+
}
37+
if (appName == null)
38+
{
39+
throw new ArgumentNullException(nameof(appName));
40+
}
41+
if (fileName == null)
42+
{
43+
throw new ArgumentNullException(nameof(fileName));
44+
}
45+
if (batchSize <= 0)
46+
{
47+
throw new ArgumentOutOfRangeException(nameof(batchSize), $"{nameof(batchSize)} should be a positive number.");
48+
}
49+
if (period <= TimeSpan.Zero)
50+
{
51+
throw new ArgumentOutOfRangeException(nameof(period), $"{nameof(period)} should be longer then zero.");
52+
}
53+
3354
_outputTemplate = outputTemplate;
3455
_appName = appName;
3556
_fileName = fileName;
@@ -38,7 +59,7 @@ public AzureBlobLoggerProvider(string outputTemplate, string appName, string fil
3859
}
3960

4061
/// <inheritdoc />
41-
public override Logger ConfigureLogger(IWebAppLogConfigurationReader reader)
62+
public Logger ConfigureLogger(IWebAppLogConfigurationReader reader)
4263
{
4364
var messageFormatter = new MessageTemplateTextFormatter(_outputTemplate, null);
4465
var container = new CloudBlobContainer(new Uri(reader.Current.BlobContainerUrl));

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,30 @@ public AzureBlobSink(CloudBlobContainer container,
4343
int batchSizeLimit,
4444
TimeSpan period) : base(batchSizeLimit, period)
4545
{
46+
if (appName == null)
47+
{
48+
throw new ArgumentNullException(nameof(appName));
49+
}
50+
if (fileName == null)
51+
{
52+
throw new ArgumentNullException(nameof(fileName));
53+
}
54+
if (formatter == null)
55+
{
56+
throw new ArgumentNullException(nameof(formatter));
57+
}
58+
if (batchSizeLimit <= 0)
59+
{
60+
throw new ArgumentOutOfRangeException(nameof(batchSizeLimit), $"{nameof(batchSizeLimit)} should be a positive number.");
61+
}
62+
if (period <= TimeSpan.Zero)
63+
{
64+
throw new ArgumentOutOfRangeException(nameof(period), $"{nameof(period)} should be longer then zero.");
65+
}
66+
4667
_appName = appName;
4768
_fileName = fileName;
4869
_formatter = formatter;
49-
if (batchSizeLimit < 1)
50-
{
51-
throw new ArgumentException(nameof(batchSizeLimit));
52-
}
5370
_container = container;
5471
}
5572

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
namespace Microsoft.Extensions.Logging.AzureWebAppDiagnostics.Internal
1212
{
1313
/// <summary>
14-
/// The <see cref="SerilogLoggerProvider"/> implemenation that creates instances of <see cref="Serilog.Core.Logger"/> connected to <see cref="RollingFileSink"/>.
14+
/// The logger provider that creates instances of <see cref="Serilog.Core.Logger"/> connected to <see cref="RollingFileSink"/>.
1515
/// </summary>
16-
public class FileLoggerProvider: SerilogLoggerProvider
16+
public class FileLoggerProvider
1717
{
1818
private readonly int _fileSizeLimit;
1919
private readonly int _retainedFileCountLimit;
@@ -25,17 +25,30 @@ public class FileLoggerProvider: SerilogLoggerProvider
2525
/// Creates a new instance of the <see cref="FileLoggerProvider"/> class.
2626
/// </summary>
2727
/// <param name="fileSizeLimit">A strictly positive value representing the maximum log size in megabytes. Once the log is full, no more message will be appended</param>
28-
/// <param name="retainedFileCountLimit"></param>
29-
/// <param name="outputTemplate"></param>
28+
/// <param name="retainedFileCountLimit">A strictly positive value representing the maximum retained file count</param>
29+
/// <param name="outputTemplate">A message template describing the output messages</param>
3030
public FileLoggerProvider(int fileSizeLimit, int retainedFileCountLimit, string outputTemplate)
3131
{
32+
if (outputTemplate == null)
33+
{
34+
throw new ArgumentNullException(nameof(outputTemplate));
35+
}
36+
if (fileSizeLimit <= 0)
37+
{
38+
throw new ArgumentOutOfRangeException(nameof(fileSizeLimit), $"{nameof(fileSizeLimit)} should be positive.");
39+
}
40+
if (retainedFileCountLimit <= 0)
41+
{
42+
throw new ArgumentOutOfRangeException(nameof(retainedFileCountLimit), $"{nameof(retainedFileCountLimit)} should be positive.");
43+
}
44+
3245
_fileSizeLimit = fileSizeLimit;
3346
_retainedFileCountLimit = retainedFileCountLimit;
3447
_outputTemplate = outputTemplate;
3548
}
3649

3750
/// <inheritdoc />
38-
public override Logger ConfigureLogger(IWebAppLogConfigurationReader reader)
51+
public Logger ConfigureLogger(IWebAppLogConfigurationReader reader)
3952
{
4053
var webAppConfiguration = reader.Current;
4154
if (string.IsNullOrEmpty(webAppConfiguration.FileLoggingFolder))

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

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)