Skip to content

Commit

Permalink
Update logging functionalities and package paths condition
Browse files Browse the repository at this point in the history
The logging functionalities within PulseFlowLogger and LogPulse were updated to allow for additional parameters and stricter class definition. Adjustments were made in the Directory.Build.props file, adding conditions to the paths of README.md and icon.png to only include them if they do not already exist.
  • Loading branch information
frankhaugen committed Jan 21, 2024
1 parent f59c301 commit e50b8ba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
<None Include="../README.md" Pack="true" PackagePath="\"/>
<None Include="../icon.png" Pack="true" PackagePath="\"/>
<None Include="../README.md" Pack="true" PackagePath="\" Condition="!Exists('README.md')"/>
<None Include="../icon.png" Pack="true" PackagePath="\" Condition="!Exists('icon.png')"/>
<InternalsVisibleTo Include="$(AssemblyName).Tests"/>
<InternalsVisibleTo Include="LINQPadQuery"/>
</ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions Frank.PulseFlow.Logging/LogPulse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Frank.PulseFlow.Logging;
/// <summary>
/// Represents a log pulse.
/// </summary>
public class LogPulse : BasePulse
public sealed class LogPulse : BasePulse
{
/// <summary>
/// Gets the log level of the application.
Expand Down Expand Up @@ -55,13 +55,15 @@ public class LogPulse : BasePulse
/// <param name="exception">The exception associated with the log event, if any.</param>
/// <param name="categoryName">The name of the log category.</param>
/// <param name="message">The log message.</param>
public LogPulse(LogLevel logLevel, EventId eventId, Exception? exception, string categoryName, string message)
/// <param name="state"></param>
public LogPulse(LogLevel logLevel, EventId eventId, Exception? exception, string categoryName, string message, IReadOnlyList<KeyValuePair<string, object?>>? state)
{
LogLevel = logLevel;
EventId = eventId;
Exception = exception;
CategoryName = categoryName;
Message = message;
State = state;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Frank.PulseFlow.Logging/PulseFlowLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public PulseFlowLogger(string categoryName, IConduit conduit, IOptionsMonitor<Lo
/// <param name="exception">The exception associated with the log entry.</param>
/// <param name="formatter">A function that formats the log message.</param>
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
=> _conduit.SendAsync(new LogPulse(logLevel, eventId, exception, _categoryName, formatter.Invoke(state, exception))).GetAwaiter().GetResult();
=> _conduit.SendAsync(new LogPulse(logLevel, eventId, exception, _categoryName, formatter.Invoke(state, exception), state as IReadOnlyList<KeyValuePair<string, object?>>)).GetAwaiter().GetResult();

/// <summary>
/// Checks if logging is enabled for the specified log level.
Expand Down

0 comments on commit e50b8ba

Please sign in to comment.