Skip to content

Commit

Permalink
Set serviceName in logs for not task-related logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Trolldemorted committed Apr 11, 2021
1 parent 3bcb002 commit 5da0a4d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion EnoCore/EnoCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Text.Json" Version="5.0.0" />
<PackageReference Include="System.Text.Json" Version="5.0.2" />
</ItemGroup>

</Project>
6 changes: 4 additions & 2 deletions EnoCore/Logging/EnoLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ public class EnoLogger : ILogger
private readonly string categoryName;
private readonly IEnoLogMessageProvider provider;
private readonly string tool;
private readonly string? serviceName;

public EnoLogger(IEnoLogMessageProvider provider, string categoryName, string tool)
public EnoLogger(IEnoLogMessageProvider provider, string categoryName, string tool, string? serviceName = null)
{
this.provider = provider;
this.categoryName = categoryName;
this.tool = tool;
this.serviceName = serviceName;
}

public static string GetSeverity(LogLevel logLevel)
Expand Down Expand Up @@ -150,7 +152,7 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
message,
null,
null,
null,
this.serviceName,
null);
this.provider.Log($"##ENOLOGMESSAGE {JsonSerializer.Serialize(enoLogMessage, EnoCoreUtil.CamelCaseEnumConverterOptions)}\n");
}
Expand Down
2 changes: 1 addition & 1 deletion EnoCore/Scoreboard/Scoreboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using EnoCore.Models;

public record Scoreboard(
long? CurrentRound,
long CurrentRound,
string? StartTimestamp,
double? StartTimeEpoch,
string? EndTimestamp,
Expand Down
4 changes: 2 additions & 2 deletions FlagShooter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ public List<List<Task>> BeginSubmitFlags(long flagCount)
try
{
long i = 0;
if (sb != null && sb.CurrentRound != null && sb.CurrentRound > 0)
if (sb != null && sb.CurrentRound > 0)
{
for (long r = sb.CurrentRound.Value; r > Math.Max(sb.CurrentRound.Value - this.configuration.FlagValidityInRounds, 0); r--)
for (long r = sb.CurrentRound; r > Math.Max(sb.CurrentRound - this.configuration.FlagValidityInRounds, 0); r--)
{
for (int team = 0; team < this.configuration.Teams.Count; team++)
{
Expand Down

0 comments on commit 5da0a4d

Please sign in to comment.