From 06086568d97c7344f9ee68b3537b0829640425c4 Mon Sep 17 00:00:00 2001 From: Aaron Stannard Date: Tue, 28 Feb 2023 20:17:21 -0600 Subject: [PATCH] expose `Args()` on `LogMessage` (#6472) * expose `Args()` on `LogMessage` need this for Serilog support * added API approvals * fixed * Fix missing paranthesis on DefaultLogMessage --------- Co-authored-by: Gregorius Soedharmo --- docs/articles/actors/coordinated-shutdown.md | 2 +- docs/articles/configuration/modules/akka.md | 2 +- src/common.props | 15 ++++++--------- .../CoreAPISpec.ApproveCore.Core.verified.txt | 2 ++ .../CoreAPISpec.ApproveCore.DotNet.verified.txt | 2 ++ .../CoreAPISpec.ApproveCore.Net.verified.txt | 2 ++ src/core/Akka/Akka.csproj | 2 +- src/core/Akka/Configuration/Config.cs | 5 +---- .../Akka/Configuration/ConfigurationFactory.cs | 11 ++++------- .../Akka/Configuration/{Pigeon.conf => akka.conf} | 0 src/core/Akka/Event/LogMessage.cs | 15 +++++++++++++++ 11 files changed, 35 insertions(+), 23 deletions(-) rename src/core/Akka/Configuration/{Pigeon.conf => akka.conf} (100%) diff --git a/docs/articles/actors/coordinated-shutdown.md b/docs/articles/actors/coordinated-shutdown.md index 2446f76a1aa..ac0529cf31d 100644 --- a/docs/articles/actors/coordinated-shutdown.md +++ b/docs/articles/actors/coordinated-shutdown.md @@ -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 diff --git a/docs/articles/configuration/modules/akka.md b/docs/articles/configuration/modules/akka.md index 42360758438..955c1ea0677 100644 --- a/docs/articles/configuration/modules/akka.md +++ b/docs/articles/configuration/modules/akka.md @@ -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)] diff --git a/src/common.props b/src/common.props index 6162d7e1931..6259ebdb806 100644 --- a/src/common.props +++ b/src/common.props @@ -40,17 +40,14 @@ true - 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/ + 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] | +| 2 | 110 | 37 | Aaron Stannard | +| 1 | 253 | 7 | Gregorius Soedharmo | diff --git a/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.Core.verified.txt b/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.Core.verified.txt index c4eec9caa8b..4670ac2acd7 100644 --- a/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.Core.verified.txt +++ b/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.Core.verified.txt @@ -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 Parameters(); + [Akka.Annotations.InternalApiAttribute()] public abstract string Unformatted(); } public class static LogMessageExtensions { } diff --git a/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.DotNet.verified.txt b/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.DotNet.verified.txt index 4b57d12c033..3aa59f04eaf 100644 --- a/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.DotNet.verified.txt +++ b/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.DotNet.verified.txt @@ -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 Parameters(); + [Akka.Annotations.InternalApiAttribute()] public abstract string Unformatted(); } public class static LogMessageExtensions { } diff --git a/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.Net.verified.txt b/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.Net.verified.txt index c4eec9caa8b..4670ac2acd7 100644 --- a/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.Net.verified.txt +++ b/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.Net.verified.txt @@ -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 Parameters(); + [Akka.Annotations.InternalApiAttribute()] public abstract string Unformatted(); } public class static LogMessageExtensions { } diff --git a/src/core/Akka/Akka.csproj b/src/core/Akka/Akka.csproj index 19d36400fe5..a0e7342175e 100644 --- a/src/core/Akka/Akka.csproj +++ b/src/core/Akka/Akka.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/core/Akka/Configuration/Config.cs b/src/core/Akka/Configuration/Config.cs index 7d79ed26b35..74c93fdc66a 100644 --- a/src/core/Akka/Configuration/Config.cs +++ b/src/core/Akka/Configuration/Config.cs @@ -35,10 +35,7 @@ public Config() /// This exception is thrown if the given value is undefined. 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; } diff --git a/src/core/Akka/Configuration/ConfigurationFactory.cs b/src/core/Akka/Configuration/ConfigurationFactory.cs index bb1a3ebbf95..c9bd0d45f42 100644 --- a/src/core/Akka/Configuration/ConfigurationFactory.cs +++ b/src/core/Akka/Configuration/ConfigurationFactory.cs @@ -72,7 +72,7 @@ public static Config Load() /// The configuration that contains default values for all options. public static Config Default() { - return FromResource("Akka.Configuration.Pigeon.conf"); + return FromResource("Akka.Configuration.akka.conf"); } /// @@ -83,7 +83,7 @@ public static Config Default() /// The configuration defined in the current executing assembly. internal static Config FromResource(string resourceName) { - Assembly assembly = typeof(ConfigurationFactory).GetTypeInfo().Assembly; + var assembly = typeof(ConfigurationFactory).GetTypeInfo().Assembly; return FromResource(resourceName, assembly); } @@ -97,13 +97,10 @@ internal static Config FromResource(string resourceName) /// The configuration defined in the assembly that contains the instanced object. 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); } /// diff --git a/src/core/Akka/Configuration/Pigeon.conf b/src/core/Akka/Configuration/akka.conf similarity index 100% rename from src/core/Akka/Configuration/Pigeon.conf rename to src/core/Akka/Configuration/akka.conf diff --git a/src/core/Akka/Event/LogMessage.cs b/src/core/Akka/Event/LogMessage.cs index 5d1be5c8a4c..ed73d87c3ab 100644 --- a/src/core/Akka/Event/LogMessage.cs +++ b/src/core/Akka/Event/LogMessage.cs @@ -8,6 +8,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using Akka.Annotations; namespace Akka.Event @@ -51,6 +52,13 @@ public LogMessage(ILogMessageFormatter formatter, string format) /// An unformatted copy of the state string - used for debugging bad logging templates [InternalApi] public abstract string Unformatted(); + + /// + /// INTERNAL API + /// + /// The unformatted log arguments - used during debugging and by third-party logging libraries + [InternalApi] + public abstract IEnumerable Parameters(); } /// @@ -75,6 +83,8 @@ public override string Unformatted() { return Arg.ToString(); } + + public override IEnumerable Parameters() => Arg; } /// @@ -98,6 +108,11 @@ public override string Unformatted() { return string.Join(",", Args); } + + public override IEnumerable Parameters() + { + return Args; + } } internal readonly struct LogValues : IReadOnlyList