-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature][DevTools] Logging of HTTP Exchange operations (#217) +semve…
…r: feature * [Feature][DevTools] Logging of HTTP Exchange operations * Update .NET version and NuGet package versions Add pl and uk localizations * Update pipeline to use .NET 6
- Loading branch information
Showing
16 changed files
with
620 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
Aquality.Selenium/src/Aquality.Selenium/Logging/HttpExchangeLoggingOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
namespace Aquality.Selenium.Logging | ||
{ | ||
/// <summary> | ||
/// HTTP Request/Response logging options. | ||
/// </summary> | ||
public class HttpExchangeLoggingOptions | ||
{ | ||
/// <summary> | ||
/// Controls logging of general request info: Method, URL, Request ID. | ||
/// </summary> | ||
public LoggingParameters RequestInfo { get; set; } = new LoggingParameters { Enabled = true, LogLevel = LogLevel.Info }; | ||
|
||
/// <summary> | ||
/// Controls logging of request headers. | ||
/// </summary> | ||
public LoggingParameters RequestHeaders { get; set; } = new LoggingParameters { Enabled = true, LogLevel = LogLevel.Debug }; | ||
|
||
/// <summary> | ||
/// Controls logging of request POST data. | ||
/// </summary> | ||
public LoggingParameters RequestPostData { get; set; } = new LoggingParameters { Enabled = false, LogLevel = LogLevel.Debug }; | ||
|
||
/// <summary> | ||
/// Controls logging of general response info: Status code, URL, Resource type, Request ID. | ||
/// </summary> | ||
public LoggingParameters ResponseInfo { get; set; } = new LoggingParameters { Enabled = true, LogLevel = LogLevel.Info }; | ||
|
||
/// <summary> | ||
/// Controls logging of response headers. | ||
/// </summary> | ||
public LoggingParameters ResponseHeaders { get; set; } = new LoggingParameters { Enabled = true, LogLevel = LogLevel.Debug }; | ||
|
||
/// <summary> | ||
/// Controls logging of response body. | ||
/// </summary> | ||
public LoggingParameters ResponseBody { get; set; } = new LoggingParameters { Enabled = false, LogLevel = LogLevel.Debug }; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
Aquality.Selenium/src/Aquality.Selenium/Logging/LocalizedLoggerExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Aquality.Selenium.Core.Localization; | ||
using System; | ||
|
||
namespace Aquality.Selenium.Logging | ||
{ | ||
/// <summary> | ||
/// Extensions for localized logger. | ||
/// </summary> | ||
public static class LocalizedLoggerExtensions | ||
{ | ||
/// <summary> | ||
/// Logging of localized messages with a specific log level. | ||
/// </summary> | ||
/// <param name="logger">Current instance of logger.</param> | ||
/// <param name="logLevel">Logging level.</param> | ||
/// <param name="messageKey">Localized message key.</param> | ||
/// <param name="args">Arguments for the localized message.</param> | ||
/// <exception cref="NotSupportedException">Thrown when specified log level is not supported.</exception> | ||
public static void LogByLevel(this ILocalizedLogger logger, LogLevel logLevel, string messageKey, params object[] args) | ||
{ | ||
switch (logLevel) | ||
{ | ||
case LogLevel.Debug: | ||
logger.Debug(messageKey, args: args); | ||
break; | ||
case LogLevel.Info: | ||
logger.Info(messageKey, args); | ||
break; | ||
case LogLevel.Warn: | ||
logger.Warn(messageKey, args); | ||
break; | ||
case LogLevel.Error: | ||
logger.Error(messageKey, args); | ||
break; | ||
case LogLevel.Fatal: | ||
logger.Fatal(messageKey, args: args); | ||
break; | ||
default: | ||
throw new NotSupportedException($"Localized logging at level [{logLevel}] is not supported."); | ||
} | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Aquality.Selenium/src/Aquality.Selenium/Logging/LogLevel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Aquality.Selenium.Logging | ||
{ | ||
/// <summary> | ||
/// Logging level for specific features, such as HTTP Exchange. | ||
/// </summary> | ||
public enum LogLevel | ||
{ | ||
Debug, | ||
Info, | ||
Warn, | ||
Error, | ||
Fatal | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Aquality.Selenium/src/Aquality.Selenium/Logging/LoggingParameters.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace Aquality.Selenium.Logging | ||
{ | ||
/// <summary> | ||
/// Logging parameters for specific features, such as HTTP Exchange. | ||
/// </summary> | ||
public struct LoggingParameters | ||
{ | ||
/// <summary> | ||
/// Whether feature logging should be enabled or not. | ||
/// </summary> | ||
public bool Enabled { get; set; } | ||
|
||
/// <summary> | ||
/// Logging level for the specific feature. | ||
/// </summary> | ||
public LogLevel LogLevel { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.