Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</PropertyGroup>

<PropertyGroup>
<Authors>AStar Developement, Jason Barden</Authors>
<Authors>AStar Development, Jason Barden</Authors>
<Company>AStar Development</Company>
<Copyright>AStar Developement, 2025</Copyright>
<Copyright>AStar Development, 2025</Copyright>
<Description>This package contains extension methods designed to add Serilog and Application Insights to the project. The logging is opinionated but the configuration can be overridden. In addition, Open Telemetry is being incorporated</Description>
<DocumentationFile>$(AssemblyName).xml</DocumentationFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -31,7 +31,7 @@
<RepositoryUrl>https://github.com/astar-development/astar-dev-logging-extensions.git</RepositoryUrl>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Title>AStar.Dev.Logging.Extensions</Title>
<Version>0.6.2</Version>
<Version>0.6.3</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/AStar.Dev.Logging.Extensions/AStarLogger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using Microsoft.ApplicationInsights;

namespace AStar.Dev.Logging.Extensions;

Expand All @@ -7,7 +8,7 @@ namespace AStar.Dev.Logging.Extensions;
/// with structured logging for enhanced observability in A* applications.
/// </summary>
/// <typeparam name="TCategoryName">The category name for the logger, typically derived from the type being logged.</typeparam>
public sealed class AStarLogger<TCategoryName>(ILogger<TCategoryName> logger, ITelemetryClient telemetryClient) : ILoggerAstar<TCategoryName>
public sealed class AStarLogger<TCategoryName>(ILogger<TCategoryName> logger, Microsoft.ApplicationInsights.TelemetryClient telemetryClient) : ILoggerAstar<TCategoryName>
{
/// <inheritdoc />
public void LogPageView(string pageName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ namespace AStar.Dev.Logging.Extensions.Tests.Unit;
[TestSubject(typeof(AStarLogger<>))]
public class AStarLoggerShould
{
private readonly AStarLogger<string> _astLogger;
private readonly AStarLogger<string> _astarLogger;
private readonly ILogger<string> _mockLogger;
private readonly ITelemetryClient _mockTelemetryClient;

public AStarLoggerShould()
{
_mockLogger = Substitute.For<ILogger<string>>();
_mockTelemetryClient = Substitute.For<ITelemetryClient>();
_astLogger = new(_mockLogger, _mockTelemetryClient);
_astarLogger = new(_mockLogger, null!);
}

[Fact]
public void LogPageView_WhenCalled_TracksPageViewAndLogsInformation()
{
const string pageName = "HomePage";

_astLogger.LogPageView(pageName);
_astarLogger.LogPageView(pageName);

_mockLogger.Received(1).Log(
LogLevel.Information,
Expand All @@ -40,7 +40,7 @@ public void BeginScope_WhenCalled_ReturnsDisposable()
var mockScope = Substitute.For<IDisposable>();
_mockLogger.BeginScope(state).Returns(mockScope);

var result = _astLogger.BeginScope(state);
var result = _astarLogger.BeginScope(state);

result.ShouldBeSameAs(mockScope);
_mockLogger.Received(1).BeginScope(state);
Expand All @@ -52,7 +52,7 @@ public void IsEnabled_WhenLogLevelEnabled_ReturnsTrue()
const LogLevel logLevel = LogLevel.Debug;
_mockLogger.IsEnabled(logLevel).Returns(true);

var result = _astLogger.IsEnabled(logLevel);
var result = _astarLogger.IsEnabled(logLevel);

result.ShouldBeTrue();
_mockLogger.Received(1).IsEnabled(logLevel);
Expand All @@ -64,7 +64,7 @@ public void IsEnabled_WhenLogLevelIsDisabled_ReturnsFalse()
const LogLevel logLevel = LogLevel.Trace;
_mockLogger.IsEnabled(logLevel).Returns(false);

var result = _astLogger.IsEnabled(logLevel);
var result = _astarLogger.IsEnabled(logLevel);

result.ShouldBeFalse();
_mockLogger.Received(1).IsEnabled(logLevel);
Expand All @@ -83,7 +83,7 @@ static string formatter(object s, Exception? e)
return s.ToString()!;
}

_astLogger.Log(logLevel, eventId, state, exception, (Func<object, Exception?, string>)formatter);
_astarLogger.Log(logLevel, eventId, state, exception, (Func<object, Exception?, string>)formatter);

_mockLogger.Received(1).Log(
logLevel,
Expand All @@ -106,7 +106,7 @@ static string formatter(object s, Exception? e)
return s.ToString()!;
}

_astLogger.Log(logLevel, eventId, state, exception, (Func<object, Exception?, string>)formatter);
_astarLogger.Log(logLevel, eventId, state, exception, (Func<object, Exception?, string>)formatter);

_mockLogger.Received(1).Log(
logLevel,
Expand All @@ -121,7 +121,7 @@ public void LogPageView_WhenPageNameIsNull_ThrowsArgumentNullException()
{
string? pageName = null;

Should.Throw<ArgumentNullException>(() => _astLogger.LogPageView(pageName!));
Should.Throw<ArgumentNullException>(() => _astarLogger.LogPageView(pageName!));

_mockLogger.DidNotReceive().Log(
Arg.Any<LogLevel>(),
Expand Down
Loading