-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* #97 - rename logging -> dumping * #97 - refactoring of writer entity * #97 - реализация вывода с помощью логгера * #97 - реализация форматтера для эквивалентного вывода * #97 - работа с логгером в тестах
- Loading branch information
Showing
18 changed files
with
124 additions
and
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace HydraScript.Domain.BackEnd; | ||
|
||
public interface IOutputWriter | ||
{ | ||
public void WriteLine(object? obj); | ||
|
||
public void WriteError(Exception e, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
namespace HydraScript.Domain.BackEnd.Impl; | ||
|
||
public class ExecuteParams(TextWriter textWriter) : IExecuteParams | ||
public class ExecuteParams(IOutputWriter textWriter) : IExecuteParams | ||
{ | ||
public Stack<Call> CallStack { get; } = new(); | ||
public Stack<Frame> Frames { get; } = new(); | ||
public Queue<object?> Arguments { get; } = new(); | ||
public TextWriter Writer { get; } = textWriter; | ||
public IOutputWriter Writer { get; } = textWriter; | ||
} |
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,28 @@ | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Extensions.Logging.Abstractions; | ||
using Microsoft.Extensions.Logging.Console; | ||
|
||
namespace HydraScript; | ||
|
||
internal class SimplestConsoleFormatter() : ConsoleFormatter(nameof(SimplestConsoleFormatter)) | ||
{ | ||
public override void Write<TState>( | ||
in LogEntry<TState> logEntry, | ||
IExternalScopeProvider scopeProvider, | ||
TextWriter textWriter) | ||
{ | ||
if (logEntry.LogLevel is LogLevel.Error) | ||
{ | ||
var message = logEntry.Formatter.Invoke(logEntry.State, logEntry.Exception); | ||
textWriter.WriteLine($"{message}: {logEntry.Exception?.Message}"); | ||
#if DEBUG | ||
textWriter.WriteLine($"{logEntry.Exception?.StackTrace}"); | ||
#endif | ||
return; | ||
} | ||
|
||
if (logEntry.LogLevel is not LogLevel.Information) | ||
return; | ||
textWriter.WriteLine(logEntry.State); | ||
} | ||
} |
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
4 changes: 2 additions & 2 deletions
4
...t.Infrastructure/Logging/LoggingParser.cs → ...t.Infrastructure/Dumping/DumpingParser.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
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
13 changes: 13 additions & 0 deletions
13
src/Infrastructure/HydraScript.Infrastructure/LoggingWriter.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,13 @@ | ||
using HydraScript.Domain.BackEnd; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace HydraScript.Infrastructure; | ||
|
||
internal class LoggingWriter(ILogger<LoggingWriter> logger) : IOutputWriter | ||
{ | ||
public void WriteLine(object? obj) => | ||
logger.LogInformation("{Object}", obj); | ||
|
||
public void WriteError(Exception e, string message) => | ||
logger.LogError(e, "{Message}", 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
Oops, something went wrong.