-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from BastianBlokland/feature/remove-logging-de…
…pendency Remove Microsoft.Extensions.Logging dependency from Core
- Loading branch information
Showing
14 changed files
with
104 additions
and
19 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
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
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,48 @@ | ||
using System; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace TypedTree.Generator.Cli | ||
{ | ||
/// <summary> | ||
/// Adapt a <see cref="Microsoft.Extensions.Logging.ILogger"/> to a <see cref="Core.ILogger"/>. | ||
/// </summary> | ||
public sealed class LoggerAdapter : Core.ILogger | ||
{ | ||
private readonly Microsoft.Extensions.Logging.ILogger sink; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="LoggerAdapter"/> class. | ||
/// </summary> | ||
/// <param name="sink">Logger to output to.</param> | ||
public LoggerAdapter(Microsoft.Extensions.Logging.ILogger sink) | ||
{ | ||
this.sink = sink ?? throw new ArgumentNullException(nameof(sink)); | ||
} | ||
|
||
/// <summary> | ||
/// Check if a certain log-level of the underlying sink enabled. | ||
/// </summary> | ||
/// <param name="level">Level to check for.</param> | ||
/// <returns>True if enabled otherwise False.</returns> | ||
public bool IsEnabled(Microsoft.Extensions.Logging.LogLevel level) => | ||
this.sink.IsEnabled(level); | ||
|
||
/// <inheritdoc/> | ||
public void LogTrace(string message) => this.sink.LogTrace(message); | ||
|
||
/// <inheritdoc/> | ||
public void LogDebug(string message) => this.sink.LogDebug(message); | ||
|
||
/// <inheritdoc/> | ||
public void LogInformation(string message) => this.sink.LogInformation(message); | ||
|
||
/// <inheritdoc/> | ||
public void LogWarning(string message) => this.sink.LogWarning(message); | ||
|
||
/// <inheritdoc/> | ||
public void LogError(string message) => this.sink.LogError(message); | ||
|
||
/// <inheritdoc/> | ||
public void LogCritical(string message) => this.sink.LogCritical(message); | ||
} | ||
} |
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
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,44 @@ | ||
namespace TypedTree.Generator.Core | ||
{ | ||
/// <summary> | ||
/// Interface for a sink of diagnostic information. | ||
/// </summary> | ||
public interface ILogger | ||
{ | ||
/// <summary> | ||
/// Log a trace-level event. | ||
/// </summary> | ||
/// <param name="message">Message to log.</param> | ||
void LogTrace(string message); | ||
|
||
/// <summary> | ||
/// Log a debug-level event. | ||
/// </summary> | ||
/// <param name="message">Message to log.</param> | ||
void LogDebug(string message); | ||
|
||
/// <summary> | ||
/// Log a information-level event. | ||
/// </summary> | ||
/// <param name="message">Message to log.</param> | ||
void LogInformation(string message); | ||
|
||
/// <summary> | ||
/// Log a warning-level event. | ||
/// </summary> | ||
/// <param name="message">Message to log.</param> | ||
void LogWarning(string message); | ||
|
||
/// <summary> | ||
/// Log a error-level event. | ||
/// </summary> | ||
/// <param name="message">Message to log.</param> | ||
void LogError(string message); | ||
|
||
/// <summary> | ||
/// Log a critical-level event. | ||
/// </summary> | ||
/// <param name="message">Message to log.</param> | ||
void LogCritical(string message); | ||
} | ||
} |
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
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
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
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