Skip to content

Commit

Permalink
expose Args() on LogMessage (#6472)
Browse files Browse the repository at this point in the history
* expose `Args()` on `LogMessage`

need this for Serilog support

* added API approvals

* fixed

* Fix missing paranthesis on DefaultLogMessage

---------

Co-authored-by: Gregorius Soedharmo <arkatufus@yahoo.com>
  • Loading branch information
Aaronontheweb and Arkatufus authored Mar 1, 2023
1 parent 6d24919 commit 0608656
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docs/articles/actors/coordinated-shutdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ There's an `ActorSystem` extension called `CoordinatedShutdown` that will stop c

The default phases and their orderings are defined in the default HOCON configuration as `akka.coordinated-shutdown.phases`, and they are defined below:

[!code-hocon[Pigeon.conf](../../../src/core/Akka/Configuration/Pigeon.conf#L1019-L1091)]
[!code-hocon[akka.conf](../../../src/core/Akka/Configuration/akka.conf#L1019-L1091)]

## Custom Phases

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/configuration/modules/akka.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ title: Akka Configuration

Below is the default HOCON configuration for the base `Akka` package.

[!code[Akka.dll HOCON Configuration](../../../../src/core/Akka/Configuration/Pigeon.conf)]
[!code[Akka.dll HOCON Configuration](../../../../src/core/Akka/Configuration/akka.conf)]
15 changes: 6 additions & 9 deletions src/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,14 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<PropertyGroup>
<PackageReleaseNotes>Version 1.5.0-beta3 contains **breaking API changes** and new API changes for Akka.NET.
Removed a number of `Obsolete` APIs that were generally not used much.
[Akka.Actor: `ActorSystem.Create` throws `PlatformNotSupportedException` on net7.0-android](https://github.com/akkadotnet/akka.net/issues/6459)
[Akka.Actor: Append message content to `DeadLetter` log messages](https://github.com/akkadotnet/akka.net/pull/6448)
[Akka.Streams: Use `ActorSystem` for `Materializer`](https://github.com/akkadotnet/akka.net/pull/6453) - *massive* memory improvements for applications that materialize a large number of streams.
[Akka.Persistence.Query.Sql: backpressure control for queries](https://github.com/akkadotnet/akka.net/pull/6436) - full details on this here: https://petabridge.com/blog/largescale-cqrs-akkadotnet-v1.5/
<PackageReleaseNotes>Version 1.5.0-beta4 contains **breaking API changes** and new API changes for Akka.NET.
[Akka.Persistence.TCK: remove `IDisposable` from Akka.Persistence.TCK](https://github.com/akkadotnet/akka.net/pull/6465) - this hid methods from the `TestKit` base classes.
[Akka.Remote: Make transport adapter messages public](https://github.com/akkadotnet/akka.net/pull/6469) - adds back public APIs from v1.4.
[Akka.TestKit: fix accidental breaking changes in v1.5.0-beta3](https://github.com/akkadotnet/akka.net/issues/6466)
| COMMITS | LOC+ | LOC- | AUTHOR |
| --- | --- | --- | --- |
| 14 | 68 | 794 | Gregorius Soedharmo |
| 5 | 997 | 498 | Aaron Stannard |
| 3 | 6 | 6 | dependabot[bot] |</PackageReleaseNotes>
| 2 | 110 | 37 | Aaron Stannard |
| 1 | 253 | 7 | Gregorius Soedharmo |</PackageReleaseNotes>
</PropertyGroup>
<!-- SourceLink support for all Akka.NET projects -->
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3114,6 +3114,8 @@ namespace Akka.Event
public LogMessage(Akka.Event.ILogMessageFormatter formatter, string format) { }
public string Format { get; }
[Akka.Annotations.InternalApiAttribute()]
public abstract System.Collections.Generic.IEnumerable<object> Parameters();
[Akka.Annotations.InternalApiAttribute()]
public abstract string Unformatted();
}
public class static LogMessageExtensions { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3119,6 +3119,8 @@ namespace Akka.Event
public LogMessage(Akka.Event.ILogMessageFormatter formatter, string format) { }
public string Format { get; }
[Akka.Annotations.InternalApiAttribute()]
public abstract System.Collections.Generic.IEnumerable<object> Parameters();
[Akka.Annotations.InternalApiAttribute()]
public abstract string Unformatted();
}
public class static LogMessageExtensions { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3114,6 +3114,8 @@ namespace Akka.Event
public LogMessage(Akka.Event.ILogMessageFormatter formatter, string format) { }
public string Format { get; }
[Akka.Annotations.InternalApiAttribute()]
public abstract System.Collections.Generic.IEnumerable<object> Parameters();
[Akka.Annotations.InternalApiAttribute()]
public abstract string Unformatted();
}
public class static LogMessageExtensions { }
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka/Akka.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="Configuration\Pigeon.conf" />
<EmbeddedResource Include="Configuration\akka.conf" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 1 addition & 4 deletions src/core/Akka/Configuration/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ public Config()
/// <exception cref="ArgumentNullException">This exception is thrown if the given <paramref name="root"/> value is undefined.</exception>
public Config(HoconRoot root)
{
if (root.Value == null)
throw new ArgumentNullException(nameof(root), "The root value cannot be null.");

Value = root.Value;
Value = root.Value ?? throw new ArgumentNullException(nameof(root), "The root value cannot be null.");
Root = root.Value;
Substitutions = root.Substitutions;
}
Expand Down
11 changes: 4 additions & 7 deletions src/core/Akka/Configuration/ConfigurationFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static Config Load()
/// <returns>The configuration that contains default values for all options.</returns>
public static Config Default()
{
return FromResource("Akka.Configuration.Pigeon.conf");
return FromResource("Akka.Configuration.akka.conf");
}

/// <summary>
Expand All @@ -83,7 +83,7 @@ public static Config Default()
/// <returns>The configuration defined in the current executing assembly.</returns>
internal static Config FromResource(string resourceName)
{
Assembly assembly = typeof(ConfigurationFactory).GetTypeInfo().Assembly;
var assembly = typeof(ConfigurationFactory).GetTypeInfo().Assembly;

return FromResource(resourceName, assembly);
}
Expand All @@ -97,13 +97,10 @@ internal static Config FromResource(string resourceName)
/// <returns>The configuration defined in the assembly that contains the instanced object.</returns>
public static Config FromResource(string resourceName, object instanceInAssembly)
{
var type = instanceInAssembly as Type;
if (type != null)
if (instanceInAssembly is Type type)
return FromResource(resourceName, type.GetTypeInfo().Assembly);
var assembly = instanceInAssembly as Assembly;
if (assembly != null)
return FromResource(resourceName, assembly);
return FromResource(resourceName, instanceInAssembly.GetType().GetTypeInfo().Assembly);
return FromResource(resourceName, assembly != null ? assembly : instanceInAssembly.GetType().GetTypeInfo().Assembly);
}

/// <summary>
Expand Down
File renamed without changes.
15 changes: 15 additions & 0 deletions src/core/Akka/Event/LogMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Akka.Annotations;

namespace Akka.Event
Expand Down Expand Up @@ -51,6 +52,13 @@ public LogMessage(ILogMessageFormatter formatter, string format)
/// <returns>An unformatted copy of the state string - used for debugging bad logging templates</returns>
[InternalApi]
public abstract string Unformatted();

/// <summary>
/// INTERNAL API
/// </summary>
/// <returns>The unformatted log arguments - used during debugging and by third-party logging libraries</returns>
[InternalApi]
public abstract IEnumerable<object> Parameters();
}

/// <summary>
Expand All @@ -75,6 +83,8 @@ public override string Unformatted()
{
return Arg.ToString();
}

public override IEnumerable<object> Parameters() => Arg;
}

/// <summary>
Expand All @@ -98,6 +108,11 @@ public override string Unformatted()
{
return string.Join(",", Args);
}

public override IEnumerable<object> Parameters()
{
return Args;
}
}

internal readonly struct LogValues<T1> : IReadOnlyList<object>
Expand Down

0 comments on commit 0608656

Please sign in to comment.