Skip to content
This repository was archived by the owner on Apr 8, 2023. It is now read-only.

Commit 1e45b69

Browse files
authored
Merge pull request Umplify#143 from Umplify:142-the-logger-outputlogger-only-logs-exceptions
The logger (OutputLogger) only logs exceptions was fixed Umplify#142
2 parents e136972 + 3823aa5 commit 1e45b69

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

azure-pipeline-PR.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ steps:
1717
displayName: 'Use .NET 6.0 sdk'
1818
inputs:
1919
packageType: sdk
20-
version: 6.0.402
20+
version: 6.0.403
2121
installationPath: $(Agent.ToolsDirectory)/dotnet
2222
- script: echo Started restoring the source code
2323
- task: DotNetCoreCLI@2

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ steps:
1919
displayName: 'Use .NET 6.0 sdk'
2020
inputs:
2121
packageType: sdk
22-
version: 6.0.402
22+
version: 6.0.403
2323
installationPath: $(Agent.ToolsDirectory)/dotnet
2424
- script: echo Started restoring the source code
2525
- task: DotNetCoreCLI@2
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
using Microsoft.Extensions.Options;
1+
using Microsoft.Extensions.Logging;
2+
using Microsoft.Extensions.Options;
23

34
namespace Xunit.Microsoft.DependencyInjection.ExampleTests.Services;
45

56
public class Calculator : ICalculator
67
{
78
private readonly Options _option;
9+
private readonly ILogger<Calculator> _logger;
810

9-
public Calculator(IOptions<Options> option)
10-
=> _option = option.Value;
11+
public Calculator(ILogger<Calculator> logger, IOptions<Options> option)
12+
=> (_logger, _option) = (logger, option.Value);
1113

1214
public int Add(int x, int y)
13-
=> (x + y) * _option.Rate;
15+
{
16+
var result = (x + y) * _option.Rate;
17+
_logger.LogInformation("The result is {@Result}", result);
18+
return result;
19+
}
1420
}

src/Logging/OutputLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
3030
}
3131
else
3232
{
33-
_testOutputHelper.WriteLine($"{logLevel} - Category: {_categoryName} : {DateTime.Now}");
33+
_testOutputHelper.WriteLine($"{logLevel} - Category: {_categoryName} : {state} :: {DateTime.Now}");
3434
}
3535
}
3636
}

0 commit comments

Comments
 (0)