From 8fb39e55acddac5b4d5394cdc825bfcb759ed8e3 Mon Sep 17 00:00:00 2001 From: Aaron Stannard Date: Fri, 17 Feb 2023 15:20:13 -0600 Subject: [PATCH] v1.5 logging (version 2) (#6408) * reworking the guts of the logging system * fixing compilation errors resulting from conversion to new extension methods * fixing more compilation issues had to add missing `Akka.Event` namespace reference * fixed final compilation errors * added static methods for all event calls * simplified `ILoggingAdapter` API * added API approvals * fixed erroneous ReSharperisms * added docs * fix typos and markdown linting --- .../akkadotnet-v1.5-upgrade-advisories.md | 25 + .../Logging/LoggingBenchmarks.cs | 70 +- .../Akka.Cluster.Metrics/ClusterMetrics.cs | 3 +- .../ClusterShardCoordinatorDowning2Spec.cs | 1 + .../ClusterShardCoordinatorDowningSpec.cs | 1 + .../ClusterShardingGetStatsSpec.cs | 1 + .../ClusterShardingLeavingSpec.cs | 1 + ...stShardAllocationStrategyRandomizedSpec.cs | 1 + .../PersistentStartEntitySpec.cs | 1 + .../ShardedDaemonProcessSpec.cs | 1 + .../StorageHelpers.cs | 1 + .../Akka.Cluster.Sharding/ClusterSharding.cs | 15 +- ...SourcedRememberEntitiesCoordinatorStore.cs | 1 + .../EventSourcedRememberEntitiesShardStore.cs | 1 + .../ShardedDaemonProcess.cs | 1 + .../ClusterClient/ClusterClientSpec.cs | 1 + .../ClusterSingletonManagerChaosSpec.cs | 1 + .../ClusterSingletonLeavingSpeedSpec.cs | 1 + .../DurableDataPocoSpec.cs | 1 + .../DurableDataSpec.cs | 1 + .../ReplicatorSpec.cs | 1 + .../ReplicatorResiliencySpec.cs | 1 + .../ReplicatorSpecs.cs | 1 + .../DependencyResolverSetup.cs | 2 +- .../Akka.TestKit.Xunit/Internals/Loggers.cs | 2 +- .../Akka.TestKit.Xunit2/Internals/Loggers.cs | 2 +- .../CoreAPISpec.ApproveCore.Core.verified.txt | 149 ++-- ...oreAPISpec.ApproveCore.DotNet.verified.txt | 149 ++-- .../CoreAPISpec.ApproveCore.Net.verified.txt | 149 ++-- .../QuickRestartSpec.cs | 1 + .../ClusterBroadcastRouter2266BugfixSpec.cs | 1 + .../SunnyWeatherSpec.cs | 1 + .../TransitionSpec.cs | 1 + src/core/Akka.Cluster/ClusterRemoteWatcher.cs | 1 + src/core/Akka.FSharp.Tests/RemoteSpecs.fs | 4 +- .../Akka.Persistence.TCK/Query/TestActor.cs | 1 + .../Eventsourced.Lifecycle.cs | 1 + .../Akka.Persistence/Fsm/PersistentFSM.cs | 1 + .../RemoteDeliverySpec.cs | 1 + .../RemoteNodeDeathWatchSpec.cs | 1 + .../ThrottlerTransportAdapterSpec.cs | 1 + .../Transport/DotNetty/AkkaLoggingHandler.cs | 1 + .../TestSubscriber_Shared.cs | 1 + .../Akka.Streams.Tests/Dsl/FlowDelaySpec.cs | 1 + .../Implementation/ChannelSinkSpec.cs | 1 + .../Implementation/GraphStageLogicSpec.cs | 1 + .../Dsl/FlowWithContextOperations.cs | 4 +- .../Dsl/Internal/InternalFlowOperations.cs | 2 +- src/core/Akka.Streams/Dsl/RestartFlow.cs | 1 + .../Implementation/ActorRefSinkStage.cs | 1 + .../Implementation/FanoutProcessorImpl.cs | 1 + .../Akka.Streams/Implementation/Fusing/Ops.cs | 1 + .../Implementation/Fusing/StreamOfStreams.cs | 1 + .../Implementation/IO/TcpStages.cs | 1 + .../Implementation/StreamRef/SinkRefImpl.cs | 1 + .../Implementation/StreamRef/SourceRefImpl.cs | 1 + src/core/Akka.Streams/Stage/AbstractStage.cs | 13 +- src/core/Akka.Streams/Stage/Stage.cs | 4 +- .../Internal/InternalTestActor.cs | 4 +- .../Internal/InternalTestActorRef.cs | 1 + src/core/Akka.TestKit/TestKitBase_Expect.cs | 1 + src/core/Akka.TestKit/TestKitBase_Receive.cs | 1 + src/core/Akka.Tests/Loggers/LoggerSpec.cs | 8 +- src/core/Akka/Event/BusLogging.cs | 89 +-- .../Akka/Event/DefaultLogMessageFormatter.cs | 14 +- src/core/Akka/Event/EventBus.cs | 6 +- src/core/Akka/Event/ILogMessageFormatter.cs | 13 + src/core/Akka/Event/ILoggingAdapter.cs | 742 +++++++++++++++--- src/core/Akka/Event/LogMessage.cs | 342 +++++++- src/core/Akka/Event/LoggingAdapterBase.cs | 313 +------- src/core/Akka/Event/StandardOutLogger.cs | 2 +- src/core/Akka/IO/TcpOutgoingConnection.cs | 1 + src/core/Akka/Pattern/BackoffOptions.cs | 2 +- .../Util/Reflection/ExpressionExtensions.cs | 3 +- 74 files changed, 1409 insertions(+), 769 deletions(-) diff --git a/docs/community/whats-new/akkadotnet-v1.5-upgrade-advisories.md b/docs/community/whats-new/akkadotnet-v1.5-upgrade-advisories.md index 861cdcac379..5016594a595 100644 --- a/docs/community/whats-new/akkadotnet-v1.5-upgrade-advisories.md +++ b/docs/community/whats-new/akkadotnet-v1.5-upgrade-advisories.md @@ -160,3 +160,28 @@ akka.cluster.sharding { ``` If you run into any trouble upgrading, [please file an issue with Akka.NET](https://github.com/akkadotnet/akka.net/issues/new/choose). + +### Breaking Logging Changes + +In v1.5, we've re-engineering the `ILoggingAdapter` construct to be more extensible and performant. Unfortunately this necessitate some breaking changes that will affect end-user code - but the remedy for those changes is trivial. + +After installing the v1.5 NuGet packages into your applications or libraries, you will need to add the following to all of your source files where you previously made calls to the `ILoggingAdapter`: + +```csharp +using Akka.Event; +``` + +That `using` statement will pull in the extension methods that match all of the v1.4 API `ILoggingAdapter` signatures in v1.5. + +_Even better_ - if you can take advantage of [`global using` statements in C#10](https://blog.jetbrains.com/dotnet/2021/11/18/global-usings-in-csharp-10/), then this is a one-liner as either the MSBuild or project level: + +In `Directory.Build.props`: + +```xml + + + + + + +``` diff --git a/src/benchmark/Akka.Benchmarks/Logging/LoggingBenchmarks.cs b/src/benchmark/Akka.Benchmarks/Logging/LoggingBenchmarks.cs index 4038d26249b..5a2e91138ff 100644 --- a/src/benchmark/Akka.Benchmarks/Logging/LoggingBenchmarks.cs +++ b/src/benchmark/Akka.Benchmarks/Logging/LoggingBenchmarks.cs @@ -35,68 +35,28 @@ public BenchmarkLogAdapter(int capacity) : base(DefaultLogMessageFormatter.Insta public override bool IsDebugEnabled { get; } = true; public override bool IsInfoEnabled { get; } = true; public override bool IsWarningEnabled { get; } = true; - public override bool IsErrorEnabled { get; } = true; - - private void AddLogMessage(LogEvent m) + + private LogEvent CreateLogEvent(LogLevel logLevel, object message, Exception cause = null) { - AllLogs[CurrentLogs++] = m; + return logLevel switch + { + LogLevel.DebugLevel => new Debug(cause, _logSource, _logClass, message), + LogLevel.InfoLevel => new Info(cause, _logSource, _logClass, message), + LogLevel.WarningLevel => new Warning(cause, _logSource, _logClass, message), + LogLevel.ErrorLevel => new Error(cause, _logSource, _logClass, message), + _ => throw new ArgumentOutOfRangeException(nameof(logLevel), logLevel, null) + }; } - - protected override void NotifyError(object message) + protected override void NotifyLog(LogLevel logLevel, object message, Exception cause = null) { - AddLogMessage(new Error(null, _logSource, _logClass, message)); + AddLogMessage(CreateLogEvent(logLevel, message, cause)); } - /// - /// Publishes the error message and exception onto the LoggingBus. - /// - /// The exception that caused this error. - /// The error message. - protected override void NotifyError(Exception cause, object message) - { - AddLogMessage(new Error(cause, _logSource, _logClass, message)); - } - - /// - /// Publishes the warning message onto the LoggingBus. - /// - /// The warning message. - protected override void NotifyWarning(object message) - { - AddLogMessage(new Warning(_logSource, _logClass, message)); - } - - protected override void NotifyWarning(Exception cause, object message) - { - AddLogMessage(new Warning(cause, _logSource, _logClass, message)); - } - - /// - /// Publishes the info message onto the LoggingBus. - /// - /// The info message. - protected override void NotifyInfo(object message) - { - AddLogMessage(new Info(_logSource, _logClass, message)); - } - - protected override void NotifyInfo(Exception cause, object message) - { - AddLogMessage(new Info(cause, _logSource, _logClass, message)); - } - - /// - /// Publishes the debug message onto the LoggingBus. - /// - /// The debug message. - protected override void NotifyDebug(object message) - { - AddLogMessage(new Debug(_logSource, _logClass, message)); - } + public override bool IsErrorEnabled { get; } = true; - protected override void NotifyDebug(Exception cause, object message) + private void AddLogMessage(LogEvent m) { - AddLogMessage(new Debug(cause, _logSource, _logClass, message)); + AllLogs[CurrentLogs++] = m; } } diff --git a/src/contrib/cluster/Akka.Cluster.Metrics/ClusterMetrics.cs b/src/contrib/cluster/Akka.Cluster.Metrics/ClusterMetrics.cs index ab2d2159923..d7acb99abc3 100644 --- a/src/contrib/cluster/Akka.Cluster.Metrics/ClusterMetrics.cs +++ b/src/contrib/cluster/Akka.Cluster.Metrics/ClusterMetrics.cs @@ -13,6 +13,7 @@ using Akka.Cluster.Metrics.Helpers; using Akka.Cluster.Metrics.Serialization; using Akka.Configuration; +using Akka.Event; using Akka.Util; using ConfigurationFactory = Akka.Configuration.ConfigurationFactory; @@ -88,7 +89,7 @@ public ClusterMetricsStrategy Strategy { _system.Log.Error( $"Configured strategy provider {Settings.SupervisorStrategyProvider} failed to load, " + - $"using default {typeof(ClusterMetricsStrategy).Name}."); + $"using default {nameof(ClusterMetricsStrategy)}."); return new ClusterMetricsStrategy(Settings.SupervisorStrategyConfiguration); }) .Get(); diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardCoordinatorDowning2Spec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardCoordinatorDowning2Spec.cs index ab1262bd7f6..f27c3431eb0 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardCoordinatorDowning2Spec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardCoordinatorDowning2Spec.cs @@ -11,6 +11,7 @@ using System.Linq; using System.Threading; using Akka.Actor; +using Akka.Event; using Akka.MultiNode.TestAdapter; using Akka.Remote.TestKit; using Akka.Util; diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardCoordinatorDowningSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardCoordinatorDowningSpec.cs index c5852887dc1..61e90c3ced7 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardCoordinatorDowningSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardCoordinatorDowningSpec.cs @@ -11,6 +11,7 @@ using System.Linq; using System.Threading; using Akka.Actor; +using Akka.Event; using Akka.MultiNode.TestAdapter; using Akka.Remote.TestKit; using Akka.Util; diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingGetStatsSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingGetStatsSpec.cs index e1a6b119d2d..ddffe908385 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingGetStatsSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingGetStatsSpec.cs @@ -9,6 +9,7 @@ using System.Linq; using Akka.Actor; using Akka.Configuration; +using Akka.Event; using Akka.MultiNode.TestAdapter; using Akka.Remote.TestKit; using Akka.Util; diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingLeavingSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingLeavingSpec.cs index 8afe519d7c4..9d3617de0af 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingLeavingSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingLeavingSpec.cs @@ -10,6 +10,7 @@ using System.Collections.Immutable; using System.Linq; using Akka.Actor; +using Akka.Event; using Akka.MultiNode.TestAdapter; using Akka.Remote.TestKit; using Akka.Util; diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/LeastShardAllocationStrategyRandomizedSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/LeastShardAllocationStrategyRandomizedSpec.cs index 6d80db972b5..cf021d61185 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/LeastShardAllocationStrategyRandomizedSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/LeastShardAllocationStrategyRandomizedSpec.cs @@ -9,6 +9,7 @@ using System.Collections.Immutable; using System.Linq; using Akka.Actor; +using Akka.Event; using Akka.TestKit; using FluentAssertions; using FluentAssertions.Execution; diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/PersistentStartEntitySpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/PersistentStartEntitySpec.cs index a99c5d44339..960a1c02d4f 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/PersistentStartEntitySpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/PersistentStartEntitySpec.cs @@ -10,6 +10,7 @@ using Akka.Actor; using Akka.Cluster.Tools.Singleton; using Akka.Configuration; +using Akka.Event; using Akka.TestKit; using Akka.Util; using FluentAssertions; diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ShardedDaemonProcessSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ShardedDaemonProcessSpec.cs index a1fff6a27ea..5aedbcf5d43 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ShardedDaemonProcessSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ShardedDaemonProcessSpec.cs @@ -10,6 +10,7 @@ using Akka.Actor; using Akka.Cluster.Tools.Singleton; using Akka.Configuration; +using Akka.Event; using Akka.TestKit; using Xunit; diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/StorageHelpers.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/StorageHelpers.cs index 9c6d7d3cb9d..6a55d8e097f 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/StorageHelpers.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/StorageHelpers.cs @@ -9,6 +9,7 @@ using System.IO; using Akka.Actor; using Akka.Configuration; +using Akka.Event; using Akka.TestKit; using FluentAssertions; diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/ClusterSharding.cs b/src/contrib/cluster/Akka.Cluster.Sharding/ClusterSharding.cs index d09f5baa0a9..15ecdfdc69c 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/ClusterSharding.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/ClusterSharding.cs @@ -17,6 +17,7 @@ using Akka.Cluster.Tools.Singleton; using Akka.Configuration; using Akka.Dispatch; +using Akka.Event; using Akka.Pattern; using Akka.Util; @@ -274,19 +275,19 @@ public class ClusterSharding : IExtension private readonly Cluster _cluster; /// - /// TBD + /// Retrieves or creates the extension for the given . /// - /// TBD - /// TBD + /// The ActorSystem. + /// The singleton instances of the ClusterSharding extension associated with this ActorSystem. public static ClusterSharding Get(ActorSystem system) { return system.WithExtension(); } /// - /// TBD + /// Instantiates the Akka.Cluster.Sharding extension for this system. /// - /// TBD + /// The ActorSystem. public ClusterSharding(ExtendedActorSystem system) { _system = system; @@ -1357,7 +1358,7 @@ public Task StartProxyAsync(string typeName, string role, IMessageExt #pragma warning disable CS0419 // Ambiguous reference in cref attribute /// /// Retrieve the actor reference of the actor responsible for the named entity type. - /// The entity type must be registered with the or method before it + /// The entity type must be registered with the or method before it /// can be used here. Messages to the entity is always sent via the . /// /// TBD @@ -1383,7 +1384,7 @@ public IActorRef ShardRegion(string typeName) /// Retrieve the actor reference of the actor that will act as a proxy to the /// named entity type running in another data center. A proxy within the same data center can be accessed /// with instead of this method. The entity type must be registered with the - /// method before it can be used here. Messages to the entity is always sent + /// method before it can be used here. Messages to the entity is always sent /// via the . /// /// diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/Internal/EventSourcedRememberEntitiesCoordinatorStore.cs b/src/contrib/cluster/Akka.Cluster.Sharding/Internal/EventSourcedRememberEntitiesCoordinatorStore.cs index 201d442b6e8..6f1532c7b01 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/Internal/EventSourcedRememberEntitiesCoordinatorStore.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/Internal/EventSourcedRememberEntitiesCoordinatorStore.cs @@ -10,6 +10,7 @@ using System.Collections.Immutable; using System.Linq; using Akka.Actor; +using Akka.Event; using Akka.Persistence; namespace Akka.Cluster.Sharding.Internal diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/Internal/EventSourcedRememberEntitiesShardStore.cs b/src/contrib/cluster/Akka.Cluster.Sharding/Internal/EventSourcedRememberEntitiesShardStore.cs index 208af4965e4..16a9aa2231c 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/Internal/EventSourcedRememberEntitiesShardStore.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/Internal/EventSourcedRememberEntitiesShardStore.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.Collections.Immutable; using Akka.Actor; +using Akka.Event; using Akka.Persistence; namespace Akka.Cluster.Sharding.Internal diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/ShardedDaemonProcess.cs b/src/contrib/cluster/Akka.Cluster.Sharding/ShardedDaemonProcess.cs index b326b685968..cd5f09a0de4 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/ShardedDaemonProcess.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/ShardedDaemonProcess.cs @@ -9,6 +9,7 @@ using System.Linq; using Akka.Actor; using Akka.Annotations; +using Akka.Event; using Akka.Util.Internal; namespace Akka.Cluster.Sharding diff --git a/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/ClusterClient/ClusterClientSpec.cs b/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/ClusterClient/ClusterClientSpec.cs index f2dfe120017..cfeb8c2bd86 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/ClusterClient/ClusterClientSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/ClusterClient/ClusterClientSpec.cs @@ -17,6 +17,7 @@ using Akka.Cluster.Tools.PublishSubscribe; using Akka.Cluster.Tools.PublishSubscribe.Internal; using Akka.Configuration; +using Akka.Event; using Akka.MultiNode.TestAdapter; using Akka.Remote.TestKit; using Akka.Remote.Transport; diff --git a/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerChaosSpec.cs b/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerChaosSpec.cs index 7af8719a816..4094646bdd4 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerChaosSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerChaosSpec.cs @@ -11,6 +11,7 @@ using Akka.Cluster.TestKit; using Akka.Cluster.Tools.Singleton; using Akka.Configuration; +using Akka.Event; using Akka.MultiNode.TestAdapter; using Akka.Remote.TestKit; using Akka.TestKit; diff --git a/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonLeavingSpeedSpec.cs b/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonLeavingSpeedSpec.cs index e8ade0a7fa3..fcd2a0ea83c 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonLeavingSpeedSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonLeavingSpeedSpec.cs @@ -14,6 +14,7 @@ using Akka.Actor; using Akka.Cluster.Tools.Singleton; using Akka.Configuration; +using Akka.Event; using Akka.TestKit; using Akka.TestKit.TestActors; using FluentAssertions; diff --git a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurableDataPocoSpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurableDataPocoSpec.cs index c1a6a15b351..8f1f2f6e9cf 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurableDataPocoSpec.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurableDataPocoSpec.cs @@ -13,6 +13,7 @@ using Akka.Cluster.TestKit; using Akka.Configuration; using Akka.DistributedData.Durable; +using Akka.Event; using Akka.MultiNode.TestAdapter; using Akka.Remote.TestKit; using Akka.TestKit; diff --git a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurableDataSpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurableDataSpec.cs index 03e7b4f894a..268dac285a5 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurableDataSpec.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurableDataSpec.cs @@ -13,6 +13,7 @@ using Akka.Cluster.TestKit; using Akka.Configuration; using Akka.DistributedData.Durable; +using Akka.Event; using Akka.MultiNode.TestAdapter; using Akka.Remote.TestKit; using Akka.TestKit; diff --git a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/ReplicatorSpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/ReplicatorSpec.cs index f1fa363ab0e..28c399e4714 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/ReplicatorSpec.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/ReplicatorSpec.cs @@ -14,6 +14,7 @@ using System.Linq; using Akka.Cluster; using Akka.Cluster.TestKit; +using Akka.Event; using Akka.MultiNode.TestAdapter; using Akka.Remote.Transport; using Akka.TestKit; diff --git a/src/contrib/cluster/Akka.DistributedData.Tests/ReplicatorResiliencySpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests/ReplicatorResiliencySpec.cs index c0bd77da823..62db04361f7 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests/ReplicatorResiliencySpec.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests/ReplicatorResiliencySpec.cs @@ -15,6 +15,7 @@ using Akka.Dispatch.SysMsg; using Akka.DistributedData.Durable; using Akka.DistributedData.LightningDB; +using Akka.Event; using Akka.Pattern; using Akka.TestKit; using FluentAssertions; diff --git a/src/contrib/cluster/Akka.DistributedData.Tests/ReplicatorSpecs.cs b/src/contrib/cluster/Akka.DistributedData.Tests/ReplicatorSpecs.cs index ae235e6d839..bbd583f517d 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests/ReplicatorSpecs.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests/ReplicatorSpecs.cs @@ -16,6 +16,7 @@ using Akka.Actor; using Akka.Cluster; using Akka.Configuration; +using Akka.Event; using Akka.TestKit; using FluentAssertions; using FluentAssertions.Extensions; diff --git a/src/contrib/dependencyinjection/Akka.DependencyInjection/DependencyResolverSetup.cs b/src/contrib/dependencyinjection/Akka.DependencyInjection/DependencyResolverSetup.cs index 9a87b70f22c..6dd9542637f 100644 --- a/src/contrib/dependencyinjection/Akka.DependencyInjection/DependencyResolverSetup.cs +++ b/src/contrib/dependencyinjection/Akka.DependencyInjection/DependencyResolverSetup.cs @@ -46,7 +46,7 @@ public static ServiceProviderSetup Create(IServiceProvider provider) /// The will be used to access previously registered services /// in the creation of actors and other pieces of infrastructure inside Akka.NET. /// - /// The constructor is internal. Please use to create a new instance. + /// The constructor is internal. Please use to create a new instance. /// public class DependencyResolverSetup : Setup { diff --git a/src/contrib/testkits/Akka.TestKit.Xunit/Internals/Loggers.cs b/src/contrib/testkits/Akka.TestKit.Xunit/Internals/Loggers.cs index 9564534c2e4..27ee9a0e046 100644 --- a/src/contrib/testkits/Akka.TestKit.Xunit/Internals/Loggers.cs +++ b/src/contrib/testkits/Akka.TestKit.Xunit/Internals/Loggers.cs @@ -48,7 +48,7 @@ private void Write(LogEvent e) if (e.Message is LogMessage msg) { var message = - $"Received a malformed formatted message. Log level: [{e.LogLevel()}], Template: [{msg.Format}], args: [{string.Join(",", msg.Args)}]"; + $"Received a malformed formatted message. Log level: [{e.LogLevel()}], Template: [{msg.Format}], args: [{string.Join(",", msg.Unformatted())}]"; if(e.Cause != null) throw new AggregateException(message, ex, e.Cause); throw new FormatException(message, ex); diff --git a/src/contrib/testkits/Akka.TestKit.Xunit2/Internals/Loggers.cs b/src/contrib/testkits/Akka.TestKit.Xunit2/Internals/Loggers.cs index de121bff5e5..857298a6db6 100644 --- a/src/contrib/testkits/Akka.TestKit.Xunit2/Internals/Loggers.cs +++ b/src/contrib/testkits/Akka.TestKit.Xunit2/Internals/Loggers.cs @@ -50,7 +50,7 @@ private void HandleLogEvent(LogEvent e) if (e.Message is LogMessage msg) { var message = - $"Received a malformed formatted message. Log level: [{e.LogLevel()}], Template: [{msg.Format}], args: [{string.Join(",", msg.Args)}]"; + $"Received a malformed formatted message. Log level: [{e.LogLevel()}], Template: [{msg.Format}], args: [{string.Join(",", msg.Unformatted())}]"; if (e.Cause != null) throw new AggregateException(message, ex, e.Cause); throw new FormatException(message, ex); 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 341173bf205..5b64647f54b 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 @@ -3007,14 +3007,7 @@ namespace Akka.Event public override bool IsErrorEnabled { get; } public override bool IsInfoEnabled { get; } public override bool IsWarningEnabled { get; } - protected override void NotifyDebug(object message) { } - protected override void NotifyDebug(System.Exception cause, object message) { } - protected override void NotifyError(object message) { } - protected override void NotifyError(System.Exception cause, object message) { } - protected override void NotifyInfo(object message) { } - protected override void NotifyInfo(System.Exception cause, object message) { } - protected override void NotifyWarning(object message) { } - protected override void NotifyWarning(System.Exception cause, object message) { } + protected override void NotifyLog(Akka.Event.LogLevel logLevel, object message, System.Exception cause = null) { } } public sealed class DeadLetter : Akka.Event.AllDeadLetters { @@ -3039,6 +3032,7 @@ namespace Akka.Event { public static readonly Akka.Event.DefaultLogMessageFormatter Instance; public string Format(string format, params object[] args) { } + public string Format(string format, System.Collections.Generic.IEnumerable args) { } } public class DefaultLogger : Akka.Actor.ActorBase, Akka.Dispatch.IRequiresMessageQueue { @@ -3094,25 +3088,19 @@ namespace Akka.Event public interface ILogMessageFormatter { string Format(string format, params object[] args); + string Format(string format, System.Collections.Generic.IEnumerable args); } public interface ILoggerMessageQueueSemantics : Akka.Dispatch.ISemantics { } public interface ILoggingAdapter { + Akka.Event.ILogMessageFormatter Formatter { get; } bool IsDebugEnabled { get; } bool IsErrorEnabled { get; } bool IsInfoEnabled { get; } bool IsWarningEnabled { get; } - void Debug(string format, params object[] args); - void Debug(System.Exception cause, string format, params object[] args); - void Error(string format, params object[] args); - void Error(System.Exception cause, string format, params object[] args); - void Info(string format, params object[] args); - void Info(System.Exception cause, string format, params object[] args); bool IsEnabled(Akka.Event.LogLevel logLevel); - void Log(Akka.Event.LogLevel logLevel, string format, params object[] args); - void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format, params object[] args); - void Warning(string format, params object[] args); - void Warning(System.Exception cause, string format, params object[] args); + void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format); + void Log(Akka.Event.LogLevel logLevel, System.Exception cause, Akka.Event.LogMessage message); } public class Info : Akka.Event.LogEvent { @@ -3144,13 +3132,15 @@ namespace Akka.Event WarningLevel = 2, ErrorLevel = 3, } - public class LogMessage + public abstract class LogMessage { - public LogMessage(Akka.Event.ILogMessageFormatter formatter, string format, params object[] args) { } - public object[] Args { get; } + protected readonly Akka.Event.ILogMessageFormatter Formatter; + public LogMessage(Akka.Event.ILogMessageFormatter formatter, string format) { } public string Format { get; } - public override string ToString() { } + [Akka.Annotations.InternalApiAttribute()] + public abstract string Unformatted(); } + public class static LogMessageExtensions { } public struct LogSource { public string Source { get; } @@ -3187,32 +3177,15 @@ namespace Akka.Event public abstract class LoggingAdapterBase : Akka.Event.ILoggingAdapter { protected LoggingAdapterBase(Akka.Event.ILogMessageFormatter logMessageFormatter) { } + public Akka.Event.ILogMessageFormatter Formatter { get; } public abstract bool IsDebugEnabled { get; } public abstract bool IsErrorEnabled { get; } public abstract bool IsInfoEnabled { get; } public abstract bool IsWarningEnabled { get; } - public virtual void Debug(string format, params object[] args) { } - public virtual void Debug(System.Exception cause, string format, params object[] args) { } - public virtual void Error(System.Exception cause, string format, params object[] args) { } - public virtual void Error(string format, params object[] args) { } - public virtual void Info(System.Exception cause, string format, params object[] args) { } - public virtual void Info(string format, params object[] args) { } public bool IsEnabled(Akka.Event.LogLevel logLevel) { } - public virtual void Log(Akka.Event.LogLevel logLevel, string format, params object[] args) { } - public virtual void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format, params object[] args) { } - protected abstract void NotifyDebug(object message); - protected abstract void NotifyDebug(System.Exception cause, object message); - protected abstract void NotifyError(object message); - protected abstract void NotifyError(System.Exception cause, object message); - protected abstract void NotifyInfo(object message); - protected abstract void NotifyInfo(System.Exception cause, object message); - protected void NotifyLog(Akka.Event.LogLevel logLevel, object message) { } - protected void NotifyLog(Akka.Event.LogLevel logLevel, System.Exception cause, object message) { } - protected abstract void NotifyWarning(object message); - protected abstract void NotifyWarning(System.Exception cause, object message); - public virtual void Warn(string format, params object[] args) { } - public virtual void Warning(string format, params object[] args) { } - public virtual void Warning(System.Exception cause, string format, params object[] args) { } + public void Log(Akka.Event.LogLevel logLevel, System.Exception cause, Akka.Event.LogMessage message) { } + public void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format) { } + protected abstract void NotifyLog(Akka.Event.LogLevel logLevel, object message, System.Exception cause = null); } public class LoggingBus : Akka.Event.ActorEventBus { @@ -3225,6 +3198,82 @@ namespace Akka.Event public void SetLogLevel(Akka.Event.LogLevel logLevel) { } public void StartStdoutLogger(Akka.Actor.Settings config) { } } + public class static LoggingExtensions + { + public static void Debug(this Akka.Event.ILoggingAdapter log, string format) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, object[] args) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, object[] args) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, object[] args) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, object[] args) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, object[] args) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, object[] args) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel level, string format) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel level, string format, object[] args) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel level, System.Exception cause, string format, object[] args) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1, T2 arg2) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, object[] args) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, object[] args) { } + } public abstract class MinimalLogger : Akka.Actor.MinimalActorRef { protected MinimalLogger() { } @@ -3236,22 +3285,14 @@ namespace Akka.Event public sealed class NoLogger : Akka.Event.ILoggingAdapter { public static readonly Akka.Event.ILoggingAdapter Instance; + public Akka.Event.ILogMessageFormatter Formatter { get; } public bool IsDebugEnabled { get; } public bool IsErrorEnabled { get; } public bool IsInfoEnabled { get; } public bool IsWarningEnabled { get; } - public void Debug(string format, params object[] args) { } - public void Debug(System.Exception cause, string format, params object[] args) { } - public void Error(string format, params object[] args) { } - public void Error(System.Exception cause, string format, params object[] args) { } - public void Info(string format, params object[] args) { } - public void Info(System.Exception cause, string format, params object[] args) { } public bool IsEnabled(Akka.Event.LogLevel logLevel) { } - public void Log(Akka.Event.LogLevel logLevel, string format, params object[] args) { } - public void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format, params object[] args) { } - public void Warn(string format, params object[] args) { } - public void Warning(string format, params object[] args) { } - public void Warning(System.Exception cause, string format, params object[] args) { } + public void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format) { } + public void Log(Akka.Event.LogLevel logLevel, System.Exception cause, Akka.Event.LogMessage message) { } } public class StandardOutLogger : Akka.Event.MinimalLogger { 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 98d81fa34b1..7ba934cee55 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 @@ -3012,14 +3012,7 @@ namespace Akka.Event public override bool IsErrorEnabled { get; } public override bool IsInfoEnabled { get; } public override bool IsWarningEnabled { get; } - protected override void NotifyDebug(object message) { } - protected override void NotifyDebug(System.Exception cause, object message) { } - protected override void NotifyError(object message) { } - protected override void NotifyError(System.Exception cause, object message) { } - protected override void NotifyInfo(object message) { } - protected override void NotifyInfo(System.Exception cause, object message) { } - protected override void NotifyWarning(object message) { } - protected override void NotifyWarning(System.Exception cause, object message) { } + protected override void NotifyLog(Akka.Event.LogLevel logLevel, object message, System.Exception cause = null) { } } public sealed class DeadLetter : Akka.Event.AllDeadLetters { @@ -3044,6 +3037,7 @@ namespace Akka.Event { public static readonly Akka.Event.DefaultLogMessageFormatter Instance; public string Format(string format, params object[] args) { } + public string Format(string format, System.Collections.Generic.IEnumerable args) { } } public class DefaultLogger : Akka.Actor.ActorBase, Akka.Dispatch.IRequiresMessageQueue { @@ -3099,25 +3093,19 @@ namespace Akka.Event public interface ILogMessageFormatter { string Format(string format, params object[] args); + string Format(string format, System.Collections.Generic.IEnumerable args); } public interface ILoggerMessageQueueSemantics : Akka.Dispatch.ISemantics { } public interface ILoggingAdapter { + Akka.Event.ILogMessageFormatter Formatter { get; } bool IsDebugEnabled { get; } bool IsErrorEnabled { get; } bool IsInfoEnabled { get; } bool IsWarningEnabled { get; } - void Debug(string format, params object[] args); - void Debug(System.Exception cause, string format, params object[] args); - void Error(string format, params object[] args); - void Error(System.Exception cause, string format, params object[] args); - void Info(string format, params object[] args); - void Info(System.Exception cause, string format, params object[] args); bool IsEnabled(Akka.Event.LogLevel logLevel); - void Log(Akka.Event.LogLevel logLevel, string format, params object[] args); - void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format, params object[] args); - void Warning(string format, params object[] args); - void Warning(System.Exception cause, string format, params object[] args); + void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format); + void Log(Akka.Event.LogLevel logLevel, System.Exception cause, Akka.Event.LogMessage message); } public class Info : Akka.Event.LogEvent { @@ -3149,13 +3137,15 @@ namespace Akka.Event WarningLevel = 2, ErrorLevel = 3, } - public class LogMessage + public abstract class LogMessage { - public LogMessage(Akka.Event.ILogMessageFormatter formatter, string format, params object[] args) { } - public object[] Args { get; } + protected readonly Akka.Event.ILogMessageFormatter Formatter; + public LogMessage(Akka.Event.ILogMessageFormatter formatter, string format) { } public string Format { get; } - public override string ToString() { } + [Akka.Annotations.InternalApiAttribute()] + public abstract string Unformatted(); } + public class static LogMessageExtensions { } public struct LogSource { [get: System.Runtime.CompilerServices.IsReadOnlyAttribute()] @@ -3194,32 +3184,15 @@ namespace Akka.Event public abstract class LoggingAdapterBase : Akka.Event.ILoggingAdapter { protected LoggingAdapterBase(Akka.Event.ILogMessageFormatter logMessageFormatter) { } + public Akka.Event.ILogMessageFormatter Formatter { get; } public abstract bool IsDebugEnabled { get; } public abstract bool IsErrorEnabled { get; } public abstract bool IsInfoEnabled { get; } public abstract bool IsWarningEnabled { get; } - public virtual void Debug(string format, params object[] args) { } - public virtual void Debug(System.Exception cause, string format, params object[] args) { } - public virtual void Error(System.Exception cause, string format, params object[] args) { } - public virtual void Error(string format, params object[] args) { } - public virtual void Info(System.Exception cause, string format, params object[] args) { } - public virtual void Info(string format, params object[] args) { } public bool IsEnabled(Akka.Event.LogLevel logLevel) { } - public virtual void Log(Akka.Event.LogLevel logLevel, string format, params object[] args) { } - public virtual void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format, params object[] args) { } - protected abstract void NotifyDebug(object message); - protected abstract void NotifyDebug(System.Exception cause, object message); - protected abstract void NotifyError(object message); - protected abstract void NotifyError(System.Exception cause, object message); - protected abstract void NotifyInfo(object message); - protected abstract void NotifyInfo(System.Exception cause, object message); - protected void NotifyLog(Akka.Event.LogLevel logLevel, object message) { } - protected void NotifyLog(Akka.Event.LogLevel logLevel, System.Exception cause, object message) { } - protected abstract void NotifyWarning(object message); - protected abstract void NotifyWarning(System.Exception cause, object message); - public virtual void Warn(string format, params object[] args) { } - public virtual void Warning(string format, params object[] args) { } - public virtual void Warning(System.Exception cause, string format, params object[] args) { } + public void Log(Akka.Event.LogLevel logLevel, System.Exception cause, Akka.Event.LogMessage message) { } + public void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format) { } + protected abstract void NotifyLog(Akka.Event.LogLevel logLevel, object message, System.Exception cause = null); } public class LoggingBus : Akka.Event.ActorEventBus { @@ -3232,6 +3205,82 @@ namespace Akka.Event public void SetLogLevel(Akka.Event.LogLevel logLevel) { } public void StartStdoutLogger(Akka.Actor.Settings config) { } } + public class static LoggingExtensions + { + public static void Debug(this Akka.Event.ILoggingAdapter log, string format) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, object[] args) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, object[] args) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, object[] args) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, object[] args) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, object[] args) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, object[] args) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel level, string format) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel level, string format, object[] args) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel level, System.Exception cause, string format, object[] args) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1, T2 arg2) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, object[] args) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, object[] args) { } + } public abstract class MinimalLogger : Akka.Actor.MinimalActorRef { protected MinimalLogger() { } @@ -3243,22 +3292,14 @@ namespace Akka.Event public sealed class NoLogger : Akka.Event.ILoggingAdapter { public static readonly Akka.Event.ILoggingAdapter Instance; + public Akka.Event.ILogMessageFormatter Formatter { get; } public bool IsDebugEnabled { get; } public bool IsErrorEnabled { get; } public bool IsInfoEnabled { get; } public bool IsWarningEnabled { get; } - public void Debug(string format, params object[] args) { } - public void Debug(System.Exception cause, string format, params object[] args) { } - public void Error(string format, params object[] args) { } - public void Error(System.Exception cause, string format, params object[] args) { } - public void Info(string format, params object[] args) { } - public void Info(System.Exception cause, string format, params object[] args) { } public bool IsEnabled(Akka.Event.LogLevel logLevel) { } - public void Log(Akka.Event.LogLevel logLevel, string format, params object[] args) { } - public void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format, params object[] args) { } - public void Warn(string format, params object[] args) { } - public void Warning(string format, params object[] args) { } - public void Warning(System.Exception cause, string format, params object[] args) { } + public void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format) { } + public void Log(Akka.Event.LogLevel logLevel, System.Exception cause, Akka.Event.LogMessage message) { } } public class StandardOutLogger : Akka.Event.MinimalLogger { 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 341173bf205..5b64647f54b 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 @@ -3007,14 +3007,7 @@ namespace Akka.Event public override bool IsErrorEnabled { get; } public override bool IsInfoEnabled { get; } public override bool IsWarningEnabled { get; } - protected override void NotifyDebug(object message) { } - protected override void NotifyDebug(System.Exception cause, object message) { } - protected override void NotifyError(object message) { } - protected override void NotifyError(System.Exception cause, object message) { } - protected override void NotifyInfo(object message) { } - protected override void NotifyInfo(System.Exception cause, object message) { } - protected override void NotifyWarning(object message) { } - protected override void NotifyWarning(System.Exception cause, object message) { } + protected override void NotifyLog(Akka.Event.LogLevel logLevel, object message, System.Exception cause = null) { } } public sealed class DeadLetter : Akka.Event.AllDeadLetters { @@ -3039,6 +3032,7 @@ namespace Akka.Event { public static readonly Akka.Event.DefaultLogMessageFormatter Instance; public string Format(string format, params object[] args) { } + public string Format(string format, System.Collections.Generic.IEnumerable args) { } } public class DefaultLogger : Akka.Actor.ActorBase, Akka.Dispatch.IRequiresMessageQueue { @@ -3094,25 +3088,19 @@ namespace Akka.Event public interface ILogMessageFormatter { string Format(string format, params object[] args); + string Format(string format, System.Collections.Generic.IEnumerable args); } public interface ILoggerMessageQueueSemantics : Akka.Dispatch.ISemantics { } public interface ILoggingAdapter { + Akka.Event.ILogMessageFormatter Formatter { get; } bool IsDebugEnabled { get; } bool IsErrorEnabled { get; } bool IsInfoEnabled { get; } bool IsWarningEnabled { get; } - void Debug(string format, params object[] args); - void Debug(System.Exception cause, string format, params object[] args); - void Error(string format, params object[] args); - void Error(System.Exception cause, string format, params object[] args); - void Info(string format, params object[] args); - void Info(System.Exception cause, string format, params object[] args); bool IsEnabled(Akka.Event.LogLevel logLevel); - void Log(Akka.Event.LogLevel logLevel, string format, params object[] args); - void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format, params object[] args); - void Warning(string format, params object[] args); - void Warning(System.Exception cause, string format, params object[] args); + void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format); + void Log(Akka.Event.LogLevel logLevel, System.Exception cause, Akka.Event.LogMessage message); } public class Info : Akka.Event.LogEvent { @@ -3144,13 +3132,15 @@ namespace Akka.Event WarningLevel = 2, ErrorLevel = 3, } - public class LogMessage + public abstract class LogMessage { - public LogMessage(Akka.Event.ILogMessageFormatter formatter, string format, params object[] args) { } - public object[] Args { get; } + protected readonly Akka.Event.ILogMessageFormatter Formatter; + public LogMessage(Akka.Event.ILogMessageFormatter formatter, string format) { } public string Format { get; } - public override string ToString() { } + [Akka.Annotations.InternalApiAttribute()] + public abstract string Unformatted(); } + public class static LogMessageExtensions { } public struct LogSource { public string Source { get; } @@ -3187,32 +3177,15 @@ namespace Akka.Event public abstract class LoggingAdapterBase : Akka.Event.ILoggingAdapter { protected LoggingAdapterBase(Akka.Event.ILogMessageFormatter logMessageFormatter) { } + public Akka.Event.ILogMessageFormatter Formatter { get; } public abstract bool IsDebugEnabled { get; } public abstract bool IsErrorEnabled { get; } public abstract bool IsInfoEnabled { get; } public abstract bool IsWarningEnabled { get; } - public virtual void Debug(string format, params object[] args) { } - public virtual void Debug(System.Exception cause, string format, params object[] args) { } - public virtual void Error(System.Exception cause, string format, params object[] args) { } - public virtual void Error(string format, params object[] args) { } - public virtual void Info(System.Exception cause, string format, params object[] args) { } - public virtual void Info(string format, params object[] args) { } public bool IsEnabled(Akka.Event.LogLevel logLevel) { } - public virtual void Log(Akka.Event.LogLevel logLevel, string format, params object[] args) { } - public virtual void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format, params object[] args) { } - protected abstract void NotifyDebug(object message); - protected abstract void NotifyDebug(System.Exception cause, object message); - protected abstract void NotifyError(object message); - protected abstract void NotifyError(System.Exception cause, object message); - protected abstract void NotifyInfo(object message); - protected abstract void NotifyInfo(System.Exception cause, object message); - protected void NotifyLog(Akka.Event.LogLevel logLevel, object message) { } - protected void NotifyLog(Akka.Event.LogLevel logLevel, System.Exception cause, object message) { } - protected abstract void NotifyWarning(object message); - protected abstract void NotifyWarning(System.Exception cause, object message); - public virtual void Warn(string format, params object[] args) { } - public virtual void Warning(string format, params object[] args) { } - public virtual void Warning(System.Exception cause, string format, params object[] args) { } + public void Log(Akka.Event.LogLevel logLevel, System.Exception cause, Akka.Event.LogMessage message) { } + public void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format) { } + protected abstract void NotifyLog(Akka.Event.LogLevel logLevel, object message, System.Exception cause = null); } public class LoggingBus : Akka.Event.ActorEventBus { @@ -3225,6 +3198,82 @@ namespace Akka.Event public void SetLogLevel(Akka.Event.LogLevel logLevel) { } public void StartStdoutLogger(Akka.Actor.Settings config) { } } + public class static LoggingExtensions + { + public static void Debug(this Akka.Event.ILoggingAdapter log, string format) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, object[] args) { } + public static void Debug(this Akka.Event.ILoggingAdapter log, string format, object[] args) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Error(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, object[] args) { } + public static void Error(this Akka.Event.ILoggingAdapter log, string format, object[] args) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Info(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, object[] args) { } + public static void Info(this Akka.Event.ILoggingAdapter log, string format, object[] args) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel level, string format) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel level, string format, object[] args) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel level, System.Exception cause, string format, object[] args) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1, T2 arg2) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Log(this Akka.Event.ILoggingAdapter log, Akka.Event.LogLevel logLevel, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, System.Exception cause, string format, object[] args) { } + public static void Warning(this Akka.Event.ILoggingAdapter log, string format, object[] args) { } + } public abstract class MinimalLogger : Akka.Actor.MinimalActorRef { protected MinimalLogger() { } @@ -3236,22 +3285,14 @@ namespace Akka.Event public sealed class NoLogger : Akka.Event.ILoggingAdapter { public static readonly Akka.Event.ILoggingAdapter Instance; + public Akka.Event.ILogMessageFormatter Formatter { get; } public bool IsDebugEnabled { get; } public bool IsErrorEnabled { get; } public bool IsInfoEnabled { get; } public bool IsWarningEnabled { get; } - public void Debug(string format, params object[] args) { } - public void Debug(System.Exception cause, string format, params object[] args) { } - public void Error(string format, params object[] args) { } - public void Error(System.Exception cause, string format, params object[] args) { } - public void Info(string format, params object[] args) { } - public void Info(System.Exception cause, string format, params object[] args) { } public bool IsEnabled(Akka.Event.LogLevel logLevel) { } - public void Log(Akka.Event.LogLevel logLevel, string format, params object[] args) { } - public void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format, params object[] args) { } - public void Warn(string format, params object[] args) { } - public void Warning(string format, params object[] args) { } - public void Warning(System.Exception cause, string format, params object[] args) { } + public void Log(Akka.Event.LogLevel logLevel, System.Exception cause, string format) { } + public void Log(Akka.Event.LogLevel logLevel, System.Exception cause, Akka.Event.LogMessage message) { } } public class StandardOutLogger : Akka.Event.MinimalLogger { diff --git a/src/core/Akka.Cluster.Tests.MultiNode/QuickRestartSpec.cs b/src/core/Akka.Cluster.Tests.MultiNode/QuickRestartSpec.cs index 5f0cb57e5d4..f063a14f6c6 100644 --- a/src/core/Akka.Cluster.Tests.MultiNode/QuickRestartSpec.cs +++ b/src/core/Akka.Cluster.Tests.MultiNode/QuickRestartSpec.cs @@ -12,6 +12,7 @@ using Akka.Actor; using Akka.Cluster.TestKit; using Akka.Configuration; +using Akka.Event; using Akka.MultiNode.TestAdapter; using Akka.Remote.TestKit; using Akka.TestKit; diff --git a/src/core/Akka.Cluster.Tests.MultiNode/Routing/ClusterBroadcastRouter2266BugfixSpec.cs b/src/core/Akka.Cluster.Tests.MultiNode/Routing/ClusterBroadcastRouter2266BugfixSpec.cs index 67456894e6c..e2926daa0b2 100644 --- a/src/core/Akka.Cluster.Tests.MultiNode/Routing/ClusterBroadcastRouter2266BugfixSpec.cs +++ b/src/core/Akka.Cluster.Tests.MultiNode/Routing/ClusterBroadcastRouter2266BugfixSpec.cs @@ -11,6 +11,7 @@ using Akka.Actor; using Akka.Cluster.TestKit; using Akka.Configuration; +using Akka.Event; using Akka.MultiNode.TestAdapter; using Akka.Remote.TestKit; using Akka.Routing; diff --git a/src/core/Akka.Cluster.Tests.MultiNode/SunnyWeatherSpec.cs b/src/core/Akka.Cluster.Tests.MultiNode/SunnyWeatherSpec.cs index 47acfd532c4..827f9b7438c 100644 --- a/src/core/Akka.Cluster.Tests.MultiNode/SunnyWeatherSpec.cs +++ b/src/core/Akka.Cluster.Tests.MultiNode/SunnyWeatherSpec.cs @@ -11,6 +11,7 @@ using Akka.Actor; using Akka.Cluster.TestKit; using Akka.Configuration; +using Akka.Event; using Akka.MultiNode.TestAdapter; using Akka.Remote.TestKit; using Akka.Util; diff --git a/src/core/Akka.Cluster.Tests.MultiNode/TransitionSpec.cs b/src/core/Akka.Cluster.Tests.MultiNode/TransitionSpec.cs index 4b12dcfeb92..6108eb53260 100644 --- a/src/core/Akka.Cluster.Tests.MultiNode/TransitionSpec.cs +++ b/src/core/Akka.Cluster.Tests.MultiNode/TransitionSpec.cs @@ -11,6 +11,7 @@ using Akka.Actor; using Akka.Cluster.TestKit; using Akka.Configuration; +using Akka.Event; using Akka.MultiNode.TestAdapter; using Akka.Remote.TestKit; using FluentAssertions; diff --git a/src/core/Akka.Cluster/ClusterRemoteWatcher.cs b/src/core/Akka.Cluster/ClusterRemoteWatcher.cs index 3f6de39ad95..8543d3bc421 100644 --- a/src/core/Akka.Cluster/ClusterRemoteWatcher.cs +++ b/src/core/Akka.Cluster/ClusterRemoteWatcher.cs @@ -10,6 +10,7 @@ using System.Linq; using Akka.Actor; using Akka.Dispatch; +using Akka.Event; using Akka.Remote; namespace Akka.Cluster diff --git a/src/core/Akka.FSharp.Tests/RemoteSpecs.fs b/src/core/Akka.FSharp.Tests/RemoteSpecs.fs index 1a26f5a7ff5..d1ceef0fa98 100644 --- a/src/core/Akka.FSharp.Tests/RemoteSpecs.fs +++ b/src/core/Akka.FSharp.Tests/RemoteSpecs.fs @@ -9,9 +9,7 @@ module Akka.FSharp.Tests.RemoteSpecs open System open Akka.Actor -open Akka.Configuration -open Akka.Serialization -open Newtonsoft.Json.Converters +open Akka.Event open Xunit open Xunit.Abstractions open Akka.FSharp diff --git a/src/core/Akka.Persistence.TCK/Query/TestActor.cs b/src/core/Akka.Persistence.TCK/Query/TestActor.cs index b431b79f0b8..5e9c9047885 100644 --- a/src/core/Akka.Persistence.TCK/Query/TestActor.cs +++ b/src/core/Akka.Persistence.TCK/Query/TestActor.cs @@ -8,6 +8,7 @@ using System.Collections.Immutable; using System.Linq; using Akka.Actor; +using Akka.Event; using Akka.Persistence.Journal; namespace Akka.Persistence.TCK.Query diff --git a/src/core/Akka.Persistence/Eventsourced.Lifecycle.cs b/src/core/Akka.Persistence/Eventsourced.Lifecycle.cs index a3a64f0323d..72153401521 100644 --- a/src/core/Akka.Persistence/Eventsourced.Lifecycle.cs +++ b/src/core/Akka.Persistence/Eventsourced.Lifecycle.cs @@ -7,6 +7,7 @@ using System; using Akka.Actor; +using Akka.Event; namespace Akka.Persistence { diff --git a/src/core/Akka.Persistence/Fsm/PersistentFSM.cs b/src/core/Akka.Persistence/Fsm/PersistentFSM.cs index 12b4a04f2bb..eed8d6322ac 100644 --- a/src/core/Akka.Persistence/Fsm/PersistentFSM.cs +++ b/src/core/Akka.Persistence/Fsm/PersistentFSM.cs @@ -10,6 +10,7 @@ using System.Linq; using Akka.Actor; using Akka.Configuration; +using Akka.Event; using Akka.Persistence.Serialization; using static Akka.Persistence.Fsm.PersistentFSM; diff --git a/src/core/Akka.Remote.Tests.MultiNode/RemoteDeliverySpec.cs b/src/core/Akka.Remote.Tests.MultiNode/RemoteDeliverySpec.cs index 89a02d78599..196c64636b0 100644 --- a/src/core/Akka.Remote.Tests.MultiNode/RemoteDeliverySpec.cs +++ b/src/core/Akka.Remote.Tests.MultiNode/RemoteDeliverySpec.cs @@ -11,6 +11,7 @@ using Akka.Actor; using Akka.Remote.TestKit; using Akka.Configuration; +using Akka.Event; using Akka.MultiNode.TestAdapter; namespace Akka.Remote.Tests.MultiNode diff --git a/src/core/Akka.Remote.Tests.MultiNode/RemoteNodeDeathWatchSpec.cs b/src/core/Akka.Remote.Tests.MultiNode/RemoteNodeDeathWatchSpec.cs index 11a27268700..c18500ada23 100644 --- a/src/core/Akka.Remote.Tests.MultiNode/RemoteNodeDeathWatchSpec.cs +++ b/src/core/Akka.Remote.Tests.MultiNode/RemoteNodeDeathWatchSpec.cs @@ -10,6 +10,7 @@ using System.Threading; using Akka.Actor; using Akka.Configuration; +using Akka.Event; using Akka.MultiNode.TestAdapter; using Akka.Remote.TestKit; using Akka.Remote.Transport; diff --git a/src/core/Akka.Remote.Tests/Transport/ThrottlerTransportAdapterSpec.cs b/src/core/Akka.Remote.Tests/Transport/ThrottlerTransportAdapterSpec.cs index a593c3fe61a..15b02848e96 100644 --- a/src/core/Akka.Remote.Tests/Transport/ThrottlerTransportAdapterSpec.cs +++ b/src/core/Akka.Remote.Tests/Transport/ThrottlerTransportAdapterSpec.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using Akka.Actor; using Akka.Configuration; +using Akka.Event; using Akka.Remote.Transport; using Akka.TestKit; using Akka.TestKit.Extensions; diff --git a/src/core/Akka.Remote/Transport/DotNetty/AkkaLoggingHandler.cs b/src/core/Akka.Remote/Transport/DotNetty/AkkaLoggingHandler.cs index 4a73d3ac248..cf6e59b8063 100644 --- a/src/core/Akka.Remote/Transport/DotNetty/AkkaLoggingHandler.cs +++ b/src/core/Akka.Remote/Transport/DotNetty/AkkaLoggingHandler.cs @@ -10,6 +10,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; +using Akka.Event; using Akka.Util; using DotNetty.Buffers; using DotNetty.Common.Concurrency; diff --git a/src/core/Akka.Streams.TestKit/TestSubscriber_Shared.cs b/src/core/Akka.Streams.TestKit/TestSubscriber_Shared.cs index 20a301bcf52..befeb0415a4 100644 --- a/src/core/Akka.Streams.TestKit/TestSubscriber_Shared.cs +++ b/src/core/Akka.Streams.TestKit/TestSubscriber_Shared.cs @@ -13,6 +13,7 @@ using System.Runtime.ExceptionServices; using System.Threading; using System.Threading.Tasks; +using Akka.Event; using Akka.TestKit; using Reactive.Streams; diff --git a/src/core/Akka.Streams.Tests/Dsl/FlowDelaySpec.cs b/src/core/Akka.Streams.Tests/Dsl/FlowDelaySpec.cs index 634335e0bf7..717c233c464 100644 --- a/src/core/Akka.Streams.Tests/Dsl/FlowDelaySpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/FlowDelaySpec.cs @@ -12,6 +12,7 @@ using System.Runtime.CompilerServices; using System.Threading.Tasks; using Akka.Actor; +using Akka.Event; using Akka.Streams.Dsl; using Akka.Streams.TestKit; using Akka.TestKit; diff --git a/src/core/Akka.Streams.Tests/Implementation/ChannelSinkSpec.cs b/src/core/Akka.Streams.Tests/Implementation/ChannelSinkSpec.cs index d7e243ebfdb..ed2f0ba5b47 100644 --- a/src/core/Akka.Streams.Tests/Implementation/ChannelSinkSpec.cs +++ b/src/core/Akka.Streams.Tests/Implementation/ChannelSinkSpec.cs @@ -9,6 +9,7 @@ using System.Threading; using System.Threading.Channels; using System.Threading.Tasks; +using Akka.Event; using Akka.Streams.Dsl; using Akka.Streams.TestKit; using FluentAssertions; diff --git a/src/core/Akka.Streams.Tests/Implementation/GraphStageLogicSpec.cs b/src/core/Akka.Streams.Tests/Implementation/GraphStageLogicSpec.cs index 48616a27288..5ed1532d9dd 100644 --- a/src/core/Akka.Streams.Tests/Implementation/GraphStageLogicSpec.cs +++ b/src/core/Akka.Streams.Tests/Implementation/GraphStageLogicSpec.cs @@ -9,6 +9,7 @@ using System.Linq; using Akka.Actor; using Akka.Configuration; +using Akka.Event; using Akka.Pattern; using Akka.Streams.Dsl; using Akka.Streams.Stage; diff --git a/src/core/Akka.Streams/Dsl/FlowWithContextOperations.cs b/src/core/Akka.Streams/Dsl/FlowWithContextOperations.cs index 3f462202001..7a0c14c591f 100644 --- a/src/core/Akka.Streams/Dsl/FlowWithContextOperations.cs +++ b/src/core/Akka.Streams/Dsl/FlowWithContextOperations.cs @@ -37,7 +37,7 @@ public static FlowWithContext SelectAsync - /// Context-preserving variant of + /// Context-preserving variant of /// public static FlowWithContext Collect( this FlowWithContext flow, Func fn) where TOut2 : class @@ -179,7 +179,7 @@ public static SourceWithContext SelectAsync - /// Context-preserving variant of + /// Context-preserving variant of /// public static SourceWithContext Collect( this SourceWithContext flow, Func fn) where TOut2 : class diff --git a/src/core/Akka.Streams/Dsl/Internal/InternalFlowOperations.cs b/src/core/Akka.Streams/Dsl/Internal/InternalFlowOperations.cs index 32c612180fe..6990e39239c 100644 --- a/src/core/Akka.Streams/Dsl/Internal/InternalFlowOperations.cs +++ b/src/core/Akka.Streams/Dsl/Internal/InternalFlowOperations.cs @@ -2568,7 +2568,7 @@ private static IGraph, TMat> AlsoToGraph(IGrap /// elements that would've been sent to it will be dropped instead. /// /// It is similar to which does backpressure instead of dropping elements. - /// @see + /// @see /// /// It is recommended to use the internally optimized and combiners /// where appropriate instead of manually writing functions that pass through one of the values. diff --git a/src/core/Akka.Streams/Dsl/RestartFlow.cs b/src/core/Akka.Streams/Dsl/RestartFlow.cs index 327167bdd29..c485b6d2d04 100644 --- a/src/core/Akka.Streams/Dsl/RestartFlow.cs +++ b/src/core/Akka.Streams/Dsl/RestartFlow.cs @@ -6,6 +6,7 @@ //----------------------------------------------------------------------- using System; +using Akka.Event; using Akka.Pattern; using Akka.Streams.Implementation.Fusing; using Akka.Streams.Stage; diff --git a/src/core/Akka.Streams/Implementation/ActorRefSinkStage.cs b/src/core/Akka.Streams/Implementation/ActorRefSinkStage.cs index 20a314a9e60..374c1d1a6c0 100644 --- a/src/core/Akka.Streams/Implementation/ActorRefSinkStage.cs +++ b/src/core/Akka.Streams/Implementation/ActorRefSinkStage.cs @@ -8,6 +8,7 @@ using System; using Akka.Actor; using Akka.Annotations; +using Akka.Event; using Akka.Streams.Implementation.Stages; using Akka.Streams.Stage; diff --git a/src/core/Akka.Streams/Implementation/FanoutProcessorImpl.cs b/src/core/Akka.Streams/Implementation/FanoutProcessorImpl.cs index c8a06ff0e0f..024d2949e32 100644 --- a/src/core/Akka.Streams/Implementation/FanoutProcessorImpl.cs +++ b/src/core/Akka.Streams/Implementation/FanoutProcessorImpl.cs @@ -7,6 +7,7 @@ using System; using Akka.Actor; +using Akka.Event; using Akka.Pattern; using Akka.Util.Internal; using Reactive.Streams; diff --git a/src/core/Akka.Streams/Implementation/Fusing/Ops.cs b/src/core/Akka.Streams/Implementation/Fusing/Ops.cs index 1d69d485b8d..48380b7cb9d 100644 --- a/src/core/Akka.Streams/Implementation/Fusing/Ops.cs +++ b/src/core/Akka.Streams/Implementation/Fusing/Ops.cs @@ -2930,6 +2930,7 @@ public override void OnDownstreamFinish(Exception cause) if (IsEnabled(_logLevels.OnFinish)) _log.Log( _logLevels.OnFinish, + null, "[{0}] Downstream finished. cause: {1}: {2}.", _stage._name, Logging.SimpleName(cause.GetType()), diff --git a/src/core/Akka.Streams/Implementation/Fusing/StreamOfStreams.cs b/src/core/Akka.Streams/Implementation/Fusing/StreamOfStreams.cs index ca26d7148bc..7c7e1f98307 100644 --- a/src/core/Akka.Streams/Implementation/Fusing/StreamOfStreams.cs +++ b/src/core/Akka.Streams/Implementation/Fusing/StreamOfStreams.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.Collections.Immutable; using Akka.Annotations; +using Akka.Event; using Akka.Pattern; using Akka.Streams.Actors; using Akka.Streams.Dsl; diff --git a/src/core/Akka.Streams/Implementation/IO/TcpStages.cs b/src/core/Akka.Streams/Implementation/IO/TcpStages.cs index faabac75ceb..c03a1e90c52 100644 --- a/src/core/Akka.Streams/Implementation/IO/TcpStages.cs +++ b/src/core/Akka.Streams/Implementation/IO/TcpStages.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; using Akka.Actor; using Akka.Annotations; +using Akka.Event; using Akka.IO; using Akka.Pattern; using Akka.Streams.Dsl; diff --git a/src/core/Akka.Streams/Implementation/StreamRef/SinkRefImpl.cs b/src/core/Akka.Streams/Implementation/StreamRef/SinkRefImpl.cs index 4a83b57a73b..05b88fe79c5 100644 --- a/src/core/Akka.Streams/Implementation/StreamRef/SinkRefImpl.cs +++ b/src/core/Akka.Streams/Implementation/StreamRef/SinkRefImpl.cs @@ -12,6 +12,7 @@ using System.Threading.Tasks; using Akka.Actor; using Akka.Annotations; +using Akka.Event; using Akka.Streams.Dsl; using Akka.Streams.Serialization; using Akka.Streams.Stage; diff --git a/src/core/Akka.Streams/Implementation/StreamRef/SourceRefImpl.cs b/src/core/Akka.Streams/Implementation/StreamRef/SourceRefImpl.cs index bd7880a6d3d..324651ba69c 100644 --- a/src/core/Akka.Streams/Implementation/StreamRef/SourceRefImpl.cs +++ b/src/core/Akka.Streams/Implementation/StreamRef/SourceRefImpl.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Akka.Actor; using Akka.Annotations; +using Akka.Event; using Akka.Pattern; using Akka.Streams.Actors; using Akka.Streams.Dsl; diff --git a/src/core/Akka.Streams/Stage/AbstractStage.cs b/src/core/Akka.Streams/Stage/AbstractStage.cs index bed1f127009..e97c3c93e43 100644 --- a/src/core/Akka.Streams/Stage/AbstractStage.cs +++ b/src/core/Akka.Streams/Stage/AbstractStage.cs @@ -6,6 +6,7 @@ //----------------------------------------------------------------------- using System; +using Akka.Event; using Directive = Akka.Streams.Supervision.Directive; namespace Akka.Streams.Stage @@ -440,7 +441,7 @@ public virtual void PreStart(ILifecycleContext context) /// with . /// /// - /// By default the finish signal is immediately propagated with . + /// By default the finish signal is immediately propagated with . /// /// /// IMPORTANT NOTICE: this signal is not back-pressured, it might arrive from upstream even though @@ -453,7 +454,7 @@ public virtual void PreStart(ILifecycleContext context) /// /// This method is called when downstream has cancelled. - /// By default the cancel signal is immediately propagated with . + /// By default the cancel signal is immediately propagated with . /// /// TBD /// TBD @@ -594,7 +595,7 @@ public abstract class AbstractStage. /// /// - /// By default the finish signal is immediately propagated with . + /// By default the finish signal is immediately propagated with . /// /// /// IMPORTANT NOTICE: this signal is not back-pressured, it might arrive from upstream even though @@ -614,7 +615,7 @@ public abstract class AbstractStage. /// /// - /// By default the finish signal is immediately propagated with . + /// By default the finish signal is immediately propagated with . /// /// /// IMPORTANT NOTICE: this signal is not back-pressured, it might arrive from upstream even though @@ -627,7 +628,7 @@ public abstract class AbstractStage /// This method is called when downstream has cancelled. - /// By default the cancel signal is immediately propagated with . + /// By default the cancel signal is immediately propagated with . /// /// TBD /// @@ -636,7 +637,7 @@ public abstract class AbstractStage /// This method is called when downstream has cancelled. - /// By default the cancel signal is immediately propagated with . + /// By default the cancel signal is immediately propagated with . /// /// TBD /// diff --git a/src/core/Akka.Streams/Stage/Stage.cs b/src/core/Akka.Streams/Stage/Stage.cs index 9732b16acae..91d00a14f51 100644 --- a/src/core/Akka.Streams/Stage/Stage.cs +++ b/src/core/Akka.Streams/Stage/Stage.cs @@ -56,7 +56,7 @@ public interface IStage { } /// instead of . /// /// - /// Stages are allowed to do early completion of downstream and cancel of upstream. This is done with , + /// Stages are allowed to do early completion of downstream and cancel of upstream. This is done with , /// which is a combination of cancel/complete. /// /// @@ -72,7 +72,7 @@ public interface IStage { } /// which stops the propagation of the termination signal, and puts the stage in a /// state. Depending on whether the stage has a pending pull signal it /// has not yet "consumed" by a push its handler might be called immediately or later. From - /// final elements can be pushed before completing downstream with or + /// final elements can be pushed before completing downstream with or /// . /// /// diff --git a/src/core/Akka.TestKit/Internal/InternalTestActor.cs b/src/core/Akka.TestKit/Internal/InternalTestActor.cs index bc2ea2729b8..23f04d49a1f 100644 --- a/src/core/Akka.TestKit/Internal/InternalTestActor.cs +++ b/src/core/Akka.TestKit/Internal/InternalTestActor.cs @@ -45,9 +45,9 @@ protected override bool Receive(object message) } catch (FormatException) { - if (message is LogEvent evt && evt.Message is LogMessage msg) + if (message is LogEvent { Message: LogMessage msg }) global::System.Diagnostics.Debug.WriteLine( - $"TestActor received a malformed formatted message. Template:[{msg.Format}], args:[{string.Join(",", msg.Args)}]"); + $"TestActor received a malformed formatted message. Template:[{msg.Format}], args:[{string.Join(",", msg.Unformatted())}]"); else throw; } diff --git a/src/core/Akka.TestKit/Internal/InternalTestActorRef.cs b/src/core/Akka.TestKit/Internal/InternalTestActorRef.cs index 7db216aa67e..276957ef096 100644 --- a/src/core/Akka.TestKit/Internal/InternalTestActorRef.cs +++ b/src/core/Akka.TestKit/Internal/InternalTestActorRef.cs @@ -12,6 +12,7 @@ using Akka.Actor; using Akka.Actor.Internal; using Akka.Dispatch; +using Akka.Event; using Akka.Pattern; using Akka.Util; using Akka.Util.Internal; diff --git a/src/core/Akka.TestKit/TestKitBase_Expect.cs b/src/core/Akka.TestKit/TestKitBase_Expect.cs index fe869264a01..5e38e3224fe 100644 --- a/src/core/Akka.TestKit/TestKitBase_Expect.cs +++ b/src/core/Akka.TestKit/TestKitBase_Expect.cs @@ -12,6 +12,7 @@ using System.Threading; using System.Threading.Tasks; using Akka.Actor; +using Akka.Event; using Akka.TestKit.Internal; using Akka.Util; diff --git a/src/core/Akka.TestKit/TestKitBase_Receive.cs b/src/core/Akka.TestKit/TestKitBase_Receive.cs index 7961ad65c3c..f7a2f951e6e 100644 --- a/src/core/Akka.TestKit/TestKitBase_Receive.cs +++ b/src/core/Akka.TestKit/TestKitBase_Receive.cs @@ -12,6 +12,7 @@ using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; +using Akka.Event; using Akka.TestKit.Internal; namespace Akka.TestKit diff --git a/src/core/Akka.Tests/Loggers/LoggerSpec.cs b/src/core/Akka.Tests/Loggers/LoggerSpec.cs index 99a0e2146e2..d48c7d6aace 100644 --- a/src/core/Akka.Tests/Loggers/LoggerSpec.cs +++ b/src/core/Akka.Tests/Loggers/LoggerSpec.cs @@ -138,13 +138,13 @@ public static IEnumerable LogEventFactory() var lc = logSource.Type; var formatter = DefaultLogMessageFormatter.Instance; - yield return new object[] { new Error(ex, ls, lc, new LogMessage(formatter, Case.t, Case.p)) }; + yield return new object[] { new Error(ex, ls, lc, new DefaultLogMessage(formatter, Case.t, Case.p)) }; - yield return new object[] {new Warning(ex, ls, lc, new LogMessage(formatter, Case.t, Case.p))}; + yield return new object[] {new Warning(ex, ls, lc, new DefaultLogMessage(formatter, Case.t, Case.p))}; - yield return new object[] {new Info(ex, ls, lc, new LogMessage(formatter, Case.t, Case.p))}; + yield return new object[] {new Info(ex, ls, lc, new DefaultLogMessage(formatter, Case.t, Case.p))}; - yield return new object[] {new Debug(ex, ls, lc, new LogMessage(formatter, Case.t, Case.p))}; + yield return new object[] {new Debug(ex, ls, lc, new DefaultLogMessage(formatter, Case.t, Case.p))}; } private class FakeException : Exception diff --git a/src/core/Akka/Event/BusLogging.cs b/src/core/Akka/Event/BusLogging.cs index ad723ed730b..2cf3c3f0f62 100644 --- a/src/core/Akka/Event/BusLogging.cs +++ b/src/core/Akka/Event/BusLogging.cs @@ -32,95 +32,48 @@ public BusLogging(LoggingBus bus, string logSource, Type logClass, ILogMessageFo _logSource = logSource; _logClass = logClass; - _isErrorEnabled = bus.LogLevel <= LogLevel.ErrorLevel; - _isWarningEnabled = bus.LogLevel <= LogLevel.WarningLevel; - _isInfoEnabled = bus.LogLevel <= LogLevel.InfoLevel; - _isDebugEnabled = bus.LogLevel <= LogLevel.DebugLevel; + IsErrorEnabled = bus.LogLevel <= LogLevel.ErrorLevel; + IsWarningEnabled = bus.LogLevel <= LogLevel.WarningLevel; + IsInfoEnabled = bus.LogLevel <= LogLevel.InfoLevel; + IsDebugEnabled = bus.LogLevel <= LogLevel.DebugLevel; } - private readonly bool _isDebugEnabled; /// /// Check to determine whether the is enabled. /// - public override bool IsDebugEnabled { get { return _isDebugEnabled; } } + public override bool IsDebugEnabled { get; } - private readonly bool _isErrorEnabled; /// /// Check to determine whether the is enabled. /// - public override bool IsErrorEnabled { get { return _isErrorEnabled; } } + public override bool IsErrorEnabled { get; } - private readonly bool _isInfoEnabled; /// /// Check to determine whether the is enabled. /// - public override bool IsInfoEnabled { get { return _isInfoEnabled; } } + public override bool IsInfoEnabled { get; } - private readonly bool _isWarningEnabled; /// /// Check to determine whether the is enabled. /// - public override bool IsWarningEnabled { get { return _isWarningEnabled; } } - - /// - /// Publishes the error message onto the LoggingBus. - /// - /// The error message. - protected override void NotifyError(object message) - { - _bus.Publish(new Error(null, _logSource, _logClass, message)); - } - - /// - /// Publishes the error message and exception onto the LoggingBus. - /// - /// The exception that caused this error. - /// The error message. - protected override void NotifyError(Exception cause, object message) - { - _bus.Publish(new Error(cause, _logSource, _logClass, message)); - } - - /// - /// Publishes the warning message onto the LoggingBus. - /// - /// The warning message. - protected override void NotifyWarning(object message) - { - _bus.Publish(new Warning(_logSource, _logClass, message)); - } - - protected override void NotifyWarning(Exception cause, object message) - { - _bus.Publish(new Warning(cause, _logSource, _logClass, message)); - } - - /// - /// Publishes the info message onto the LoggingBus. - /// - /// The info message. - protected override void NotifyInfo(object message) - { - _bus.Publish(new Info(_logSource, _logClass, message)); - } - - protected override void NotifyInfo(Exception cause, object message) - { - _bus.Publish(new Info(cause, _logSource, _logClass, message)); - } - - /// - /// Publishes the debug message onto the LoggingBus. - /// - /// The debug message. - protected override void NotifyDebug(object message) + public override bool IsWarningEnabled { get; } + + private LogEvent CreateLogEvent(LogLevel logLevel, object message, Exception cause = null) { - _bus.Publish(new Debug(_logSource, _logClass, message)); + return logLevel switch + { + LogLevel.DebugLevel => new Debug(cause, _logSource, _logClass, message), + LogLevel.InfoLevel => new Info(cause, _logSource, _logClass, message), + LogLevel.WarningLevel => new Warning(cause, _logSource, _logClass, message), + LogLevel.ErrorLevel => new Error(cause, _logSource, _logClass, message), + _ => throw new ArgumentOutOfRangeException(nameof(logLevel), logLevel, null) + }; } - protected override void NotifyDebug(Exception cause, object message) + protected override void NotifyLog(LogLevel logLevel, object message, Exception cause = null) { - _bus.Publish(new Debug(cause, _logSource, _logClass, message)); + var logEvent = CreateLogEvent(logLevel, message, cause); + _bus.Publish(logEvent); } } } diff --git a/src/core/Akka/Event/DefaultLogMessageFormatter.cs b/src/core/Akka/Event/DefaultLogMessageFormatter.cs index 9fb6798e039..91dc668905d 100644 --- a/src/core/Akka/Event/DefaultLogMessageFormatter.cs +++ b/src/core/Akka/Event/DefaultLogMessageFormatter.cs @@ -5,6 +5,9 @@ // //----------------------------------------------------------------------- +using System.Collections.Generic; +using System.Linq; + namespace Akka.Event { /// @@ -15,15 +18,14 @@ public class DefaultLogMessageFormatter : ILogMessageFormatter public static readonly DefaultLogMessageFormatter Instance = new DefaultLogMessageFormatter(); private DefaultLogMessageFormatter(){} - /// - /// Formats a specified composite string using an optional list of item substitutions. - /// - /// The string that is being formatted. - /// An optional list of items used to format the string. - /// The given string that has been correctly formatted. public string Format(string format, params object[] args) { return string.Format(format, args); } + + public string Format(string format, IEnumerable args) + { + return string.Format(format, args.ToArray()); + } } } diff --git a/src/core/Akka/Event/EventBus.cs b/src/core/Akka/Event/EventBus.cs index b33add96aa9..86066f5cb60 100644 --- a/src/core/Akka/Event/EventBus.cs +++ b/src/core/Akka/Event/EventBus.cs @@ -20,11 +20,9 @@ namespace Akka.Event /// The type of the subscriber that listens for events. public abstract class EventBus { - private readonly Dictionary>> _classifiers = - new Dictionary>>(); + private readonly Dictionary>> _classifiers = new(); - private volatile ConcurrentDictionary> _cache = - new ConcurrentDictionary>(); + private volatile ConcurrentDictionary> _cache = new(); /// /// Retrieves the simplified type name (the class name without the namespace) of a given object. diff --git a/src/core/Akka/Event/ILogMessageFormatter.cs b/src/core/Akka/Event/ILogMessageFormatter.cs index 3c63beac270..8953c2dddba 100644 --- a/src/core/Akka/Event/ILogMessageFormatter.cs +++ b/src/core/Akka/Event/ILogMessageFormatter.cs @@ -5,6 +5,8 @@ // //----------------------------------------------------------------------- +using System.Collections.Generic; + namespace Akka.Event { /// @@ -19,5 +21,16 @@ public interface ILogMessageFormatter /// An optional list of items used to format the string. /// The given string that has been correctly formatted. string Format(string format, params object[] args); + + /// + /// Formats a string without explicit array allocation. + /// + /// The string that is being formatted. + /// An optional list of items used to format the string. + /// The given string that has been correctly formatted. + /// + /// Delays array allocation until formatting time. + /// + string Format(string format, IEnumerable args); } } diff --git a/src/core/Akka/Event/ILoggingAdapter.cs b/src/core/Akka/Event/ILoggingAdapter.cs index 6e30b4211ea..2297f1335bf 100644 --- a/src/core/Akka/Event/ILoggingAdapter.cs +++ b/src/core/Akka/Event/ILoggingAdapter.cs @@ -6,246 +6,748 @@ //----------------------------------------------------------------------- using System; +using System.Collections.Generic; namespace Akka.Event { - /// - /// This interface describes the methods used to log events within the system. - /// - public interface ILoggingAdapter + public static class LoggingExtensions { + public static void Log(this ILoggingAdapter log, LogLevel level, string format) + { + log.Log(level, null, format); + } + + public static void Log(this ILoggingAdapter log, LogLevel level, string format, object[] args) + { + log.Log(level, null, new DefaultLogMessage(log.Formatter, format, args)); + } + + public static void Log(this ILoggingAdapter log, LogLevel level, Exception cause, string format, object[] args) + { + log.Log(level, cause, new DefaultLogMessage(log.Formatter, format, args)); + } + + public static void Log(this ILoggingAdapter log, LogLevel logLevel, Exception cause, string format, T1 arg1) + { + log.Log(logLevel, cause, new LogMessage>(log.Formatter, format, new LogValues(arg1))); + } + + public static void Log(this ILoggingAdapter log, LogLevel logLevel, Exception cause, string format, + T1 arg1, T2 arg2) + { + log.Log(logLevel, cause, + new LogMessage>(log.Formatter, format, new LogValues(arg1, arg2))); + } + + public static void Log(this ILoggingAdapter log, LogLevel logLevel, Exception cause, string format, + T1 arg1, T2 arg2, T3 arg3) + { + log.Log(logLevel, cause, + new LogMessage>(log.Formatter, format, + new LogValues(arg1, arg2, arg3))); + } + + public static void Log(this ILoggingAdapter log, LogLevel logLevel, Exception cause, + string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) + { + log.Log(logLevel, cause, + new LogMessage>(log.Formatter, format, + new LogValues(arg1, arg2, arg3, arg4))); + } + + public static void Log(this ILoggingAdapter log, LogLevel logLevel, Exception cause, + string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) + { + log.Log(logLevel, cause, + new LogMessage>(log.Formatter, format, + new LogValues(arg1, arg2, arg3, arg4, arg5))); + } + + public static void Log(this ILoggingAdapter log, LogLevel logLevel, Exception cause, + string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) + { + log.Log(logLevel, cause, + new LogMessage>(log.Formatter, format, + new LogValues(arg1, arg2, arg3, arg4, arg5, arg6))); + } + + public static void Debug(this ILoggingAdapter log, string format) + { + if (!log.IsDebugEnabled) + return; + + log.Log(LogLevel.DebugLevel, null, format); + } + + public static void Debug(this ILoggingAdapter log, Exception cause, string format) + { + if (!log.IsDebugEnabled) + return; + + log.Log(LogLevel.DebugLevel, cause, format); + } + /// - /// Check to determine whether the is enabled. + /// Logs a message. /// - bool IsDebugEnabled { get; } + /// The message that is being logged. + public static void Debug(this ILoggingAdapter log, string format, T1 arg1) + { + log.Debug(null, format, arg1); + } + + public static void Debug(this ILoggingAdapter log, Exception cause, string format, T1 arg1) + { + if (!log.IsDebugEnabled) + return; + + log.Log(LogLevel.DebugLevel, cause, format, arg1); + } + + public static void Debug(this ILoggingAdapter log, string format, T1 arg1, T2 arg2) + { + log.Debug(null, format, arg1, arg2); + } + + public static void Debug(this ILoggingAdapter log, Exception cause, string format, T1 arg1, T2 arg2) + { + if (!log.IsDebugEnabled) + return; + + log.Log(LogLevel.DebugLevel, cause, format, arg1, arg2); + } + + public static void Debug(this ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3) + { + log.Debug(null, format, arg1, arg2, arg3); + } + + public static void Debug(this ILoggingAdapter log, Exception cause, string format, T1 arg1, T2 arg2, + T3 arg3) + { + if (!log.IsDebugEnabled) + return; + + log.Log(LogLevel.DebugLevel, cause, format, arg1, arg2, arg3); + } + + public static void Debug(this ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, + T4 arg4) + { + log.Debug(null, format, arg1, arg2, arg3, arg4); + } + + public static void Debug(this ILoggingAdapter log, Exception cause, string format, T1 arg1, + T2 arg2, T3 arg3, T4 arg4) + { + if (!log.IsDebugEnabled) + return; + + log.Log(LogLevel.DebugLevel, cause, format, arg1, arg2, arg3, arg4); + } + + public static void Debug(this ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, + T4 arg4, T5 arg5) + { + log.Debug(null, format, arg1, arg2, arg3, arg4, arg5); + } + + public static void Debug(this ILoggingAdapter log, Exception cause, string format, T1 arg1, + T2 arg2, T3 arg3, T4 arg4, T5 arg5) + { + if (!log.IsDebugEnabled) + return; + + log.Log(LogLevel.DebugLevel, cause, format, arg1, arg2, arg3, arg4, arg5); + } + + public static void Debug(this ILoggingAdapter log, string format, T1 arg1, T2 arg2, + T3 arg3, T4 arg4, T5 arg5, T6 arg6) + { + log.Debug(null, format, arg1, arg2, arg3, arg4, arg5, arg6); + } + + public static void Debug(this ILoggingAdapter log, Exception cause, string format, + T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) + { + if (!log.IsDebugEnabled) + return; + + log.Log(LogLevel.DebugLevel, cause, format, arg1, arg2, arg3, arg4, arg5, arg6); + } /// - /// Check to determine whether the is enabled. + /// Logs a message and associated exception. /// - bool IsInfoEnabled { get; } + /// The exception associated with this message. + /// The message that is being logged. + /// An optional list of items used to format the message. + public static void Debug(this ILoggingAdapter log, Exception cause, string format, object[] args) + { + if (!log.IsDebugEnabled) + return; + + log.Log(LogLevel.DebugLevel, cause, format, args); + } + + public static void Debug(this ILoggingAdapter log, string format, object[] args) + { + if (!log.IsDebugEnabled) + return; + + log.Log(LogLevel.DebugLevel, null, format, args); + } + + /* END DEBUG */ /// - /// Check to determine whether the is enabled. + /// Logs a message. /// - bool IsWarningEnabled { get; } + /// The message that is being logged. + public static void Info(this ILoggingAdapter log, string format) + { + if (!log.IsInfoEnabled) + return; + + log.Log(LogLevel.InfoLevel, null, format); + } + /// - /// Check to determine whether the is enabled. + /// Logs a message. /// - bool IsErrorEnabled { get; } + /// The message that is being logged. + public static void Info(this ILoggingAdapter log, Exception cause, string format) + { + if (!log.IsInfoEnabled) + return; + + log.Log(LogLevel.InfoLevel, cause, format); + } /// - /// Determines whether a specific log level is enabled. + /// Logs a message. /// - /// The log level that is being checked. - /// true if the specified level is enabled; otherwise false. - bool IsEnabled(LogLevel logLevel); + /// The message that is being logged. + public static void Info(this ILoggingAdapter log, string format, T1 arg1) + { + log.Info(null, format, arg1); + } + + public static void Info(this ILoggingAdapter log, Exception cause, string format, T1 arg1) + { + if (!log.IsInfoEnabled) + return; + + log.Log(LogLevel.InfoLevel, cause, format, arg1); + } + + public static void Info(this ILoggingAdapter log, string format, T1 arg1, T2 arg2) + { + log.Info(null, format, arg1, arg2); + } + + public static void Info(this ILoggingAdapter log, Exception cause, string format, T1 arg1, T2 arg2) + { + if (!log.IsInfoEnabled) + return; + + log.Log(LogLevel.InfoLevel, cause, format, arg1, arg2); + } + + public static void Info(this ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3) + { + log.Info(null, format, arg1, arg2, arg3); + } + + public static void Info(this ILoggingAdapter log, Exception cause, string format, T1 arg1, T2 arg2, + T3 arg3) + { + if (!log.IsInfoEnabled) + return; + + log.Log(LogLevel.InfoLevel, cause, format, arg1, arg2, arg3); + } + + public static void Info(this ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, + T4 arg4) + { + log.Info(null, format, arg1, arg2, arg3, arg4); + } + + public static void Info(this ILoggingAdapter log, Exception cause, string format, T1 arg1, + T2 arg2, T3 arg3, T4 arg4) + { + if (!log.IsInfoEnabled) + return; + + log.Log(LogLevel.InfoLevel, cause, format, arg1, arg2, arg3, arg4); + } + + public static void Info(this ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, + T4 arg4, T5 arg5) + { + log.Info(null, format, arg1, arg2, arg3, arg4, arg5); + } + + public static void Info(this ILoggingAdapter log, Exception cause, string format, T1 arg1, + T2 arg2, T3 arg3, T4 arg4, T5 arg5) + { + if (!log.IsInfoEnabled) + return; + + log.Log(LogLevel.InfoLevel, cause, format, arg1, arg2, arg3, arg4, arg5); + } + + public static void Info(this ILoggingAdapter log, string format, T1 arg1, T2 arg2, + T3 arg3, T4 arg4, T5 arg5, T6 arg6) + { + log.Info(null, format, arg1, arg2, arg3, arg4, arg5, arg6); + } + + public static void Info(this ILoggingAdapter log, Exception cause, string format, + T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) + { + if (!log.IsInfoEnabled) + return; + + log.Log(LogLevel.InfoLevel, cause, format, arg1, arg2, arg3, arg4, arg5, arg6); + } /// - /// Logs a message. + /// Logs a message and associated exception. /// + /// The exception associated with this message. /// The message that is being logged. /// An optional list of items used to format the message. - void Debug(string format, params object[] args); + public static void Info(this ILoggingAdapter log, Exception cause, string format, object[] args) + { + if (!log.IsInfoEnabled) + return; + + log.Log(LogLevel.InfoLevel, cause, format, args); + } + + public static void Info(this ILoggingAdapter log, string format, object[] args) + { + if (!log.IsInfoEnabled) + return; + + log.Log(LogLevel.InfoLevel, null, format, args); + } + + /* BEGIN WARNING */ /// - /// Logs a message and associated exception. + /// Logs a message. /// - /// The exception associated with this message. /// The message that is being logged. /// An optional list of items used to format the message. - void Debug(Exception cause, string format, params object[] args); + public static void Warning(this ILoggingAdapter log, string format) + { + if (!log.IsWarningEnabled) + return; + + log.Log(LogLevel.WarningLevel, null, format); + } /// - /// Logs a message. + /// Logs a message. /// /// The message that is being logged. /// An optional list of items used to format the message. - void Info(string format, params object[] args); + public static void Warning(this ILoggingAdapter log, Exception cause, string format) + { + if (!log.IsWarningEnabled) + return; + + log.Log(LogLevel.WarningLevel, cause, format); + } /// - /// Logs a message and associated exception. + /// Logs a message. /// - /// The exception associated with this message. /// The message that is being logged. - /// An optional list of items used to format the message. - void Info(Exception cause, string format, params object[] args); + public static void Warning(this ILoggingAdapter log, string format, T1 arg1) + { + log.Warning(null, format, arg1); + } + + public static void Warning(this ILoggingAdapter log, Exception cause, string format, T1 arg1) + { + if (!log.IsWarningEnabled) + return; + + log.Log(LogLevel.WarningLevel, cause, format, arg1); + } + + public static void Warning(this ILoggingAdapter log, string format, T1 arg1, T2 arg2) + { + log.Warning(null, format, arg1, arg2); + } + + public static void Warning(this ILoggingAdapter log, Exception cause, string format, T1 arg1, T2 arg2) + { + if (!log.IsWarningEnabled) + return; + + log.Log(LogLevel.WarningLevel, cause, format, arg1, arg2); + } + + public static void Warning(this ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3) + { + log.Warning(null, format, arg1, arg2, arg3); + } + + public static void Warning(this ILoggingAdapter log, Exception cause, string format, T1 arg1, + T2 arg2, + T3 arg3) + { + if (!log.IsWarningEnabled) + return; + + log.Log(LogLevel.WarningLevel, cause, format, arg1, arg2, arg3); + } + + public static void Warning(this ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, + T4 arg4) + { + log.Warning(null, format, arg1, arg2, arg3, arg4); + } + + public static void Warning(this ILoggingAdapter log, Exception cause, string format, T1 arg1, + T2 arg2, T3 arg3, T4 arg4) + { + if (!log.IsWarningEnabled) + return; + + log.Log(LogLevel.WarningLevel, cause, format, arg1, arg2, arg3, arg4); + } + + public static void Warning(this ILoggingAdapter log, string format, T1 arg1, T2 arg2, + T3 arg3, + T4 arg4, T5 arg5) + { + log.Warning(null, format, arg1, arg2, arg3, arg4, arg5); + } + + public static void Warning(this ILoggingAdapter log, Exception cause, string format, + T1 arg1, + T2 arg2, T3 arg3, T4 arg4, T5 arg5) + { + if (!log.IsWarningEnabled) + return; + + log.Log(LogLevel.WarningLevel, cause, format, arg1, arg2, arg3, arg4, arg5); + } + + public static void Warning(this ILoggingAdapter log, string format, T1 arg1, T2 arg2, + T3 arg3, T4 arg4, T5 arg5, T6 arg6) + { + log.Warning(null, format, arg1, arg2, arg3, arg4, arg5, arg6); + } + + public static void Warning(this ILoggingAdapter log, Exception cause, string format, + T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) + { + if (!log.IsWarningEnabled) + return; + + log.Log(LogLevel.WarningLevel, cause, format, arg1, arg2, arg3, arg4, arg5, arg6); + } /// - /// Logs a message. + /// Logs a message and associated exception. /// + /// The exception associated with this message. /// The message that is being logged. /// An optional list of items used to format the message. - void Warning(string format, params object[] args); + public static void Warning(this ILoggingAdapter log, Exception cause, string format, object[] args) + { + if (!log.IsWarningEnabled) + return; + log.Log(LogLevel.WarningLevel, cause, format, args); + } + /// /// Logs a message and associated exception. /// /// The exception associated with this message. /// The message that is being logged. /// An optional list of items used to format the message. - void Warning(Exception cause, string format, params object[] args); + public static void Warning(this ILoggingAdapter log, string format, object[] args) + { + if (!log.IsWarningEnabled) + return; + + log.Log(LogLevel.WarningLevel, null, format, args); + } + + /* BEGIN ERROR */ /// /// Logs a message. /// /// The message that is being logged. /// An optional list of items used to format the message. - void Error(string format, params object[] args); + public static void Error(this ILoggingAdapter log, string format) + { + if (!log.IsErrorEnabled) + return; + + log.Log(LogLevel.ErrorLevel, null, format); + } /// - /// Logs a message and associated exception. + /// Logs a message. /// - /// The exception associated with this message. /// The message that is being logged. /// An optional list of items used to format the message. - void Error(Exception cause, string format, params object[] args); + public static void Error(this ILoggingAdapter log, Exception cause, string format) + { + if (!log.IsErrorEnabled) + return; + + log.Log(LogLevel.ErrorLevel, cause, format); + } /// - /// Logs a message with a specified level. + /// Logs a message. /// - /// The level used to log the message. /// The message that is being logged. - /// An optional list of items used to format the message. - void Log(LogLevel logLevel, string format, params object[] args); + public static void Error(this ILoggingAdapter log, string format, T1 arg1) + { + log.Error(null, format, arg1); + } + + public static void Error(this ILoggingAdapter log, Exception cause, string format, T1 arg1) + { + if (!log.IsErrorEnabled) + return; + + log.Log(LogLevel.ErrorLevel, cause, format, arg1); + } + + public static void Error(this ILoggingAdapter log, string format, T1 arg1, T2 arg2) + { + log.Error(null, format, arg1, arg2); + } + + public static void Error(this ILoggingAdapter log, Exception cause, string format, T1 arg1, T2 arg2) + { + if (!log.IsErrorEnabled) + return; + + log.Log(LogLevel.ErrorLevel, cause, format, arg1, arg2); + } + + public static void Error(this ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3) + { + log.Error(null, format, arg1, arg2, arg3); + } + + public static void Error(this ILoggingAdapter log, Exception cause, string format, T1 arg1, T2 arg2, + T3 arg3) + { + if (!log.IsErrorEnabled) + return; + + log.Log(LogLevel.ErrorLevel, cause, format, arg1, arg2, arg3); + } + + public static void Error(this ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, + T4 arg4) + { + log.Error(null, format, arg1, arg2, arg3, arg4); + } + + public static void Error(this ILoggingAdapter log, Exception cause, string format, T1 arg1, + T2 arg2, T3 arg3, T4 arg4) + { + if (!log.IsInfoEnabled) + return; + + log.Log(LogLevel.ErrorLevel, cause, format, arg1, arg2, arg3, arg4); + } + + public static void Error(this ILoggingAdapter log, string format, T1 arg1, T2 arg2, T3 arg3, + T4 arg4, T5 arg5) + { + log.Error(null, format, arg1, arg2, arg3, arg4, arg5); + } + + public static void Error(this ILoggingAdapter log, Exception cause, string format, T1 arg1, + T2 arg2, T3 arg3, T4 arg4, T5 arg5) + { + if (!log.IsErrorEnabled) + return; + + log.Log(LogLevel.ErrorLevel, cause, format, arg1, arg2, arg3, arg4, arg5); + } + + public static void Error(this ILoggingAdapter log, string format, T1 arg1, T2 arg2, + T3 arg3, T4 arg4, T5 arg5, T6 arg6) + { + log.Error(null, format, arg1, arg2, arg3, arg4, arg5, arg6); + } + + public static void Error(this ILoggingAdapter log, Exception cause, string format, + T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) + { + if (!log.IsErrorEnabled) + return; + + log.Log(LogLevel.ErrorLevel, cause, format, arg1, arg2, arg3, arg4, arg5, arg6); + } + /// - /// Logs a message with a specified level. + /// Logs a message and associated exception. /// - /// The level used to log the message. - /// The exception that caused this log message. + /// The exception associated with this message. /// The message that is being logged. /// An optional list of items used to format the message. - void Log(LogLevel logLevel, Exception cause, string format, params object[] args); + public static void Error(this ILoggingAdapter log, Exception cause, string format, object[] args) + { + if (!log.IsErrorEnabled) + return; + + log.Log(LogLevel.ErrorLevel, cause, format, args); + } + + public static void Error(this ILoggingAdapter log, string format, object[] args) + { + if (!log.IsErrorEnabled) + return; + + log.Log(LogLevel.ErrorLevel, null, format, args); + } } /// - /// This class represents an implementation used when messages are to be dropped instead of logged. + /// This interface describes the methods used to log events within the system. /// - public sealed class NoLogger : ILoggingAdapter + public interface ILoggingAdapter { /// - /// Retrieves a singleton instance of the class. + /// The used to format log messages. /// - public static readonly ILoggingAdapter Instance = new NoLogger(); - private NoLogger() { } + public ILogMessageFormatter Formatter { get; } /// - /// Check to determine whether the is enabled. + /// Check to determine whether the is enabled. /// - public bool IsDebugEnabled { get { return false; } } + bool IsDebugEnabled { get; } /// - /// Check to determine whether the is enabled. + /// Check to determine whether the is enabled. /// - public bool IsInfoEnabled { get { return false; } } + bool IsInfoEnabled { get; } /// - /// Check to determine whether the is enabled. + /// Check to determine whether the is enabled. /// - public bool IsWarningEnabled { get { return false; } } + bool IsWarningEnabled { get; } /// - /// Check to determine whether the is enabled. + /// Check to determine whether the is enabled. /// - public bool IsErrorEnabled { get { return false; } } + bool IsErrorEnabled { get; } /// /// Determines whether a specific log level is enabled. /// /// The log level that is being checked. - /// - /// true if the specified level is enabled; otherwise false. - /// - public bool IsEnabled(LogLevel logLevel) - { - return false; - } + /// true if the specified level is enabled; otherwise false. + bool IsEnabled(LogLevel logLevel); - /// - /// Logs a message. - /// - /// The message that is being logged. - /// An optional list of items used to format the message. - public void Debug(string format, params object[] args) { } + // /// + // /// Logs a message with a specified level. + // /// + // /// The level used to log the message. + // /// The message that is being logged. + // /// An optional list of items used to format the message. + // void Log(LogLevel logLevel, string format, params object[] args); /// - /// Logs a message and associated exception. + /// Logs a message with a specified level. /// - /// The exception associated with this message. + /// The level used to log the message. + /// The exception that caused this log message. /// The message that is being logged. /// An optional list of items used to format the message. - public void Debug(Exception cause, string format, params object[] args){ } + void Log(LogLevel logLevel, Exception cause, string format); - /// - /// Logs a message. - /// - /// The message that is being logged. - /// An optional list of items used to format the message. - public void Info(string format, params object[] args) { } + void Log(LogLevel logLevel, Exception cause, LogMessage message); + } + /// + /// This class represents an implementation used when messages are to be dropped instead of logged. + /// + public sealed class NoLogger : ILoggingAdapter + { /// - /// Logs a message and associated exception. + /// Retrieves a singleton instance of the class. /// - /// The exception associated with this message. - /// The message that is being logged. - /// An optional list of items used to format the message. - public void Info(Exception cause, string format, params object[] args){ } + public static readonly ILoggingAdapter Instance = new NoLogger(); - /// - /// Obsolete. Use instead! - /// - /// N/A - /// N/A - public void Warn(string format, params object[] args) { } + private NoLogger() + { + } - /// - /// Logs a message. - /// - /// The message that is being logged. - /// An optional list of items used to format the message. - public void Warning(string format, params object[] args) { } + public ILogMessageFormatter Formatter => DefaultLogMessageFormatter.Instance; /// - /// Logs a message and associated exception. + /// Check to determine whether the is enabled. /// - /// The exception associated with this message. - /// The message that is being logged. - /// An optional list of items used to format the message. - public void Warning(Exception cause, string format, params object[] args){ } + public bool IsDebugEnabled + { + get { return false; } + } /// - /// Logs a message. + /// Check to determine whether the is enabled. /// - /// The message that is being logged. - /// An optional list of items used to format the message. - public void Error(string format, params object[] args) { } + public bool IsInfoEnabled + { + get { return false; } + } /// - /// Logs a message and associated exception. + /// Check to determine whether the is enabled. /// - /// The exception associated with this message. - /// The message that is being logged. - /// An optional list of items used to format the message. - public void Error(Exception cause, string format, params object[] args) { } + public bool IsWarningEnabled + { + get { return false; } + } /// - /// Logs a message with a specified level. + /// Check to determine whether the is enabled. /// - /// The level used to log the message. - /// The message that is being logged. - /// An optional list of items used to format the message. - public void Log(LogLevel logLevel, string format, params object[] args) { } + public bool IsErrorEnabled + { + get { return false; } + } /// - /// Logs a message with a specified level. + /// Determines whether a specific log level is enabled. /// - /// The level used to log the message. - /// The exception that caused this log message. - /// The message that is being logged. - /// An optional list of items used to format the message. - public void Log(LogLevel logLevel, Exception cause, string format, params object[] args) + /// The log level that is being checked. + /// + /// true if the specified level is enabled; otherwise false. + /// + public bool IsEnabled(LogLevel logLevel) + { + return false; + } + + public void Log(LogLevel logLevel, Exception cause, string format) + { + } + + public void Log(LogLevel logLevel, Exception cause, LogMessage message) { } } -} +} \ No newline at end of file diff --git a/src/core/Akka/Event/LogMessage.cs b/src/core/Akka/Event/LogMessage.cs index 3efe5955ab4..97a24a723e0 100644 --- a/src/core/Akka/Event/LogMessage.cs +++ b/src/core/Akka/Event/LogMessage.cs @@ -5,45 +5,361 @@ // //----------------------------------------------------------------------- +using System; +using System.Collections; +using System.Collections.Generic; +using Akka.Annotations; + namespace Akka.Event { + /// + /// Extension methods for creating instances. + /// + public static class LogMessageExtensions{ + + } + /// /// Represents a log message which is composed of a format string and format args. /// - public class LogMessage + /// + /// Call ToString to get the formatted output. + /// + public abstract class LogMessage { - private readonly ILogMessageFormatter _formatter; + protected readonly ILogMessageFormatter Formatter; /// /// Gets the format string of this log message. /// public string Format { get; private set; } - /// - /// Gets the format args of this log message. - /// - public object[] Args { get; private set; } - /// /// Initializes an instance of the LogMessage with the specified formatter, format and args. /// /// The formatter for the LogMessage. /// The string format of the LogMessage. /// The format args of the LogMessage. - public LogMessage(ILogMessageFormatter formatter, string format, params object[] args) + public LogMessage(ILogMessageFormatter formatter, string format) { - _formatter = formatter; + Formatter = formatter; Format = format; - Args = args; } /// - /// TBD + /// INTERNAL API /// - /// TBD + /// An unformatted copy of the state string - used for debugging bad logging templates + [InternalApi] + public abstract string Unformatted(); + } + + /// + /// Generic version of the argument. + /// + /// + internal sealed class LogMessage : LogMessage where T:IEnumerable + { + public LogMessage(ILogMessageFormatter formatter, string format, T arg) : base(formatter, format) + { + Arg = arg; + } + + public T Arg { get; } + public override string ToString() { - return _formatter.Format(Format, Args); + return Formatter.Format(Format, Arg); + } + + public override string Unformatted() + { + return Arg.ToString(); + } + } + + /// + /// Works akin to the original class with an array of objects as the format args. + /// + internal sealed class DefaultLogMessage : LogMessage + { + public DefaultLogMessage(ILogMessageFormatter formatter, string format, params object[] args) : base(formatter, format) + { + Args = args; + } + + public object[] Args { get; } + + public override string ToString() + { + return Formatter.Format(Format, Args); + } + + public override string Unformatted() + { + return string.Join(",", Args); + } + } + + internal readonly struct LogValues : IReadOnlyList + { + private readonly T1 _value1; + + public LogValues(T1 value1) + { + _value1 = value1; + } + + public IEnumerator GetEnumerator() + { + yield return this[0]; + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public int Count => 1; + + public object this[int index] + { + get + { + if(index == 0) + return _value1; + throw new IndexOutOfRangeException(nameof(index)); + } + } + } + + internal readonly struct LogValues : IReadOnlyList + { + private readonly T1 _value1; + private readonly T2 _value2; + + public LogValues(T1 value1, T2 value2) + { + _value1 = value1; + _value2 = value2; + } + + public IEnumerator GetEnumerator() + { + yield return this[0]; + yield return this[1]; + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public int Count => 2; + + public object this[int index] + { + get + { + return index switch + { + 0 => _value1, + 1 => _value2, + _ => throw new IndexOutOfRangeException(nameof(index)) + }; + } + } + } + + internal readonly struct LogValues : IReadOnlyList + { + private readonly T1 _value1; + private readonly T2 _value2; + private readonly T3 _value3; + + public LogValues(T1 value1, T2 value2, T3 value3) + { + _value1 = value1; + _value2 = value2; + _value3 = value3; + } + + public IEnumerator GetEnumerator() + { + yield return this[0]; + yield return this[1]; + yield return this[2]; + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public int Count => 3; + + public object this[int index] + { + get + { + return index switch + { + 0 => _value1, + 1 => _value2, + 2 => _value3, + _ => throw new IndexOutOfRangeException(nameof(index)) + }; + } + } + } + + internal readonly struct LogValues : IReadOnlyList + { + private readonly T1 _value1; + private readonly T2 _value2; + private readonly T3 _value3; + private readonly T4 _value4; + + public LogValues(T1 value1, T2 value2, T3 value3, T4 value4) + { + _value1 = value1; + _value2 = value2; + _value3 = value3; + _value4 = value4; + } + + public IEnumerator GetEnumerator() + { + yield return this[0]; + yield return this[1]; + yield return this[2]; + yield return this[3]; + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public int Count => 4; + + public object this[int index] + { + get + { + return index switch + { + 0 => _value1, + 1 => _value2, + 2 => _value3, + 3 => _value4, + _ => throw new IndexOutOfRangeException(nameof(index)) + }; + } + } + } + + internal readonly struct LogValues : IReadOnlyList + { + private readonly T1 _value1; + private readonly T2 _value2; + private readonly T3 _value3; + private readonly T4 _value4; + private readonly T5 _value5; + + public LogValues(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5) + { + _value1 = value1; + _value2 = value2; + _value3 = value3; + _value4 = value4; + _value5 = value5; + } + + public IEnumerator GetEnumerator() + { + yield return this[0]; + yield return this[1]; + yield return this[2]; + yield return this[3]; + yield return this[4]; + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public int Count => 5; + + public object this[int index] + { + get + { + return index switch + { + 0 => _value1, + 1 => _value2, + 2 => _value3, + 3 => _value4, + 4 => _value5, + _ => throw new IndexOutOfRangeException(nameof(index)) + }; + } + } + } + + internal readonly struct LogValues : IReadOnlyList + { + private readonly T1 _value1; + private readonly T2 _value2; + private readonly T3 _value3; + private readonly T4 _value4; + private readonly T5 _value5; + private readonly T6 _value6; + + public LogValues(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6) + { + _value1 = value1; + _value2 = value2; + _value3 = value3; + _value4 = value4; + _value5 = value5; + _value6 = value6; + } + + public IEnumerator GetEnumerator() + { + yield return this[0]; + yield return this[1]; + yield return this[2]; + yield return this[3]; + yield return this[4]; + yield return this[5]; + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public int Count => 6; + + public object this[int index] + { + get + { + return index switch + { + 0 => _value1, + 1 => _value2, + 2 => _value3, + 3 => _value4, + 4 => _value5, + 5 => _value6, + _ => throw new IndexOutOfRangeException(nameof(index)) + }; + } } } } diff --git a/src/core/Akka/Event/LoggingAdapterBase.cs b/src/core/Akka/Event/LoggingAdapterBase.cs index 4a28eae6d48..e5a7e28f347 100644 --- a/src/core/Akka/Event/LoggingAdapterBase.cs +++ b/src/core/Akka/Event/LoggingAdapterBase.cs @@ -14,7 +14,7 @@ namespace Akka.Event /// public abstract class LoggingAdapterBase : ILoggingAdapter { - private readonly ILogMessageFormatter _logMessageFormatter; + public ILogMessageFormatter Formatter { get; } /// /// Check to determine whether the is enabled. @@ -36,57 +36,6 @@ public abstract class LoggingAdapterBase : ILoggingAdapter /// public abstract bool IsWarningEnabled { get; } - /// - /// Notifies all subscribers that an log event occurred. - /// - /// The message related to the log event. - protected abstract void NotifyError(object message); - - /// - /// Notifies all subscribers that an log event occurred. - /// - /// The exception that caused the log event. - /// The message related to the log event. - protected abstract void NotifyError(Exception cause, object message); - - /// - /// Notifies all subscribers that an log event occurred. - /// - /// The message related to the log event. - protected abstract void NotifyWarning(object message); - - /// - /// Notifies all subscribers that an log event occurred. - /// - /// The exception that caused the log event. - /// The message related to the log event. - protected abstract void NotifyWarning(Exception cause, object message); - - /// - /// Notifies all subscribers that an log event occurred. - /// - /// The message related to the log event. - protected abstract void NotifyInfo(object message); - - /// - /// Notifies all subscribers that an log event occurred. - /// - /// The exception that caused the log event. - /// The message related to the log event. - protected abstract void NotifyInfo(Exception cause, object message); - - /// - /// Notifies all subscribers that an log event occurred. - /// - /// The message related to the log event. - protected abstract void NotifyDebug(object message); - - /// - /// Notifies all subscribers that an log event occurred. - /// - /// The exception that caused the log event. - /// The message related to the log event. - protected abstract void NotifyDebug(Exception cause, object message); /// /// Creates an instance of the LoggingAdapterBase. @@ -95,7 +44,7 @@ public abstract class LoggingAdapterBase : ILoggingAdapter /// This exception is thrown when the given is undefined. protected LoggingAdapterBase(ILogMessageFormatter logMessageFormatter) { - _logMessageFormatter = logMessageFormatter ?? throw new ArgumentNullException(nameof(logMessageFormatter), "The message formatter must not be null."); + Formatter = logMessageFormatter ?? throw new ArgumentNullException(nameof(logMessageFormatter), "The message formatter must not be null."); } /// @@ -126,266 +75,18 @@ public bool IsEnabled(LogLevel logLevel) /// /// The log level associated with the log event. /// The message related to the log event. - /// This exception is thrown when the given is unknown. - protected void NotifyLog(LogLevel logLevel, object message) - { - switch(logLevel) - { - case LogLevel.DebugLevel: - if(IsDebugEnabled) NotifyDebug(message); - break; - case LogLevel.InfoLevel: - if(IsInfoEnabled) NotifyInfo(message); - break; - case LogLevel.WarningLevel: - if(IsWarningEnabled) NotifyWarning(message); - break; - case LogLevel.ErrorLevel: - if(IsErrorEnabled) NotifyError(message); - break; - default: - throw new NotSupportedException($"Unknown LogLevel {logLevel}"); - } - } - - /// - /// Notifies all subscribers that a log event occurred for a particular level. - /// - /// The log level associated with the log event. /// The exception that caused the log event. - /// The message related to the log event. /// This exception is thrown when the given is unknown. - protected void NotifyLog(LogLevel logLevel, Exception cause, object message) - { - switch (logLevel) - { - case LogLevel.DebugLevel: - if (IsDebugEnabled) NotifyDebug(cause, message); - break; - case LogLevel.InfoLevel: - if (IsInfoEnabled) NotifyInfo(cause, message); - break; - case LogLevel.WarningLevel: - if (IsWarningEnabled) NotifyWarning(cause, message); - break; - case LogLevel.ErrorLevel: - if (IsErrorEnabled) NotifyError(cause, message); - break; - default: - throw new NotSupportedException($"Unknown LogLevel {logLevel}"); - } - } - + protected abstract void NotifyLog(LogLevel logLevel, object message, Exception cause = null); - /// - /// Logs a message. - /// - /// The message that is being logged. - /// An optional list of items used to format the message. - public virtual void Debug(string format, params object[] args) + public void Log(LogLevel logLevel, Exception cause, LogMessage message) { - if (!IsDebugEnabled) - return; - - if (args == null || args.Length == 0) - { - NotifyDebug(format); - } - else - { - NotifyDebug(new LogMessage(_logMessageFormatter, format, args)); - } + NotifyLog(logLevel, message, cause); } - /// - /// Logs a message. - /// - /// The exception associated with this message. - /// The message that is being logged. - /// An optional list of items used to format the message. - public virtual void Debug(Exception cause, string format, params object[] args) + public void Log(LogLevel logLevel, Exception cause, string format) { - if (!IsDebugEnabled) - return; - - if (args == null || args.Length == 0) - { - NotifyDebug(cause, format); - } - else - { - NotifyDebug(cause, new LogMessage(_logMessageFormatter, format, args)); - } - } - - /// - /// Obsolete. Use instead! - /// - /// N/A - /// N/A - public virtual void Warn(string format, params object[] args) - { - Warning(format, args); - } - - /// - /// Logs a message. - /// - /// The exception associated with this message. - /// The message that is being logged. - /// An optional list of items used to format the message. - public virtual void Info(Exception cause, string format, params object[] args) - { - if (!IsInfoEnabled) - return; - - if (args == null || args.Length == 0) - { - NotifyInfo(cause, format); - } - else - { - NotifyInfo(cause, new LogMessage(_logMessageFormatter, format, args)); - } - } - - /// - /// Logs a message. - /// - /// The message that is being logged. - /// An optional list of items used to format the message. - public virtual void Warning(string format, params object[] args) - { - if (!IsWarningEnabled) - return; - - if (args == null || args.Length == 0) - { - NotifyWarning(format); - } - else - { - NotifyWarning(new LogMessage(_logMessageFormatter, format, args)); - } - } - - /// - /// Logs a message. - /// - /// The exception associated with this message. - /// The message that is being logged. - /// An optional list of items used to format the message. - public virtual void Warning(Exception cause, string format, params object[] args) - { - if (!IsWarningEnabled) - return; - - if (args == null || args.Length == 0) - { - NotifyWarning(cause, format); - } - else - { - NotifyWarning(cause, new LogMessage(_logMessageFormatter, format, args)); - } - } - - /// - /// Logs a message and associated exception. - /// - /// The exception associated with this message. - /// The message that is being logged. - /// An optional list of items used to format the message. - public virtual void Error(Exception cause, string format, params object[] args) - { - if (!IsErrorEnabled) - return; - - if (args == null || args.Length == 0) - { - NotifyError(cause, format); - } - else - { - NotifyError(cause, new LogMessage(_logMessageFormatter, format, args)); - } - } - - /// - /// Logs a message. - /// - /// The message that is being logged. - /// An optional list of items used to format the message. - public virtual void Error(string format, params object[] args) - { - if (!IsErrorEnabled) - return; - - if (args == null || args.Length == 0) - { - NotifyError(format); - } - else - { - NotifyError(new LogMessage(_logMessageFormatter, format, args)); - } - } - - /// - /// Logs a message. - /// - /// The message that is being logged. - /// An optional list of items used to format the message. - public virtual void Info(string format, params object[] args) - { - if (!IsInfoEnabled) - return; - - if (args == null || args.Length == 0) - { - NotifyInfo(format); - } - else - { - NotifyInfo(new LogMessage(_logMessageFormatter, format, args)); - } - } - - /// - /// Logs a message with a specified level. - /// - /// The level used to log the message. - /// The message that is being logged. - /// An optional list of items used to format the message. - public virtual void Log(LogLevel logLevel, string format, params object[] args) - { - if (args == null || args.Length == 0) - { - NotifyLog(logLevel, format); - } - else - { - NotifyLog(logLevel, new LogMessage(_logMessageFormatter, format, args)); - } - } - - /// - /// Logs a message with a specified level. - /// - /// The level used to log the message. - /// The exception associated with this message. - /// The message that is being logged. - /// An optional list of items used to format the message. - public virtual void Log(LogLevel logLevel, Exception cause, string format, params object[] args) - { - if (args == null || args.Length == 0) - { - NotifyLog(logLevel, cause, format); - } - else - { - NotifyLog(logLevel, cause, new LogMessage(_logMessageFormatter, format, args)); - } + NotifyLog(logLevel, format, cause); } } } diff --git a/src/core/Akka/Event/StandardOutLogger.cs b/src/core/Akka/Event/StandardOutLogger.cs index 3eb952e41e0..f67ed6e3f48 100644 --- a/src/core/Akka/Event/StandardOutLogger.cs +++ b/src/core/Akka/Event/StandardOutLogger.cs @@ -166,7 +166,7 @@ internal static void PrintLogEvent(LogEvent logEvent) switch (logEvent.Message) { case LogMessage formatted: // a parameterized log - msg = " str=[" + formatted.Format + "], args=["+ string.Join(",", formatted.Args) +"]"; + msg = " str=[" + formatted.Format + "], args=["+ formatted.Unformatted() +"]"; break; case string unformatted: // pre-formatted or non-parameterized log msg = unformatted; diff --git a/src/core/Akka/IO/TcpOutgoingConnection.cs b/src/core/Akka/IO/TcpOutgoingConnection.cs index f107b80a8b6..8e0ed76a6b3 100644 --- a/src/core/Akka/IO/TcpOutgoingConnection.cs +++ b/src/core/Akka/IO/TcpOutgoingConnection.cs @@ -13,6 +13,7 @@ using System.Runtime.CompilerServices; using Akka.Actor; using Akka.Annotations; +using Akka.Event; using Akka.Util; namespace Akka.IO diff --git a/src/core/Akka/Pattern/BackoffOptions.cs b/src/core/Akka/Pattern/BackoffOptions.cs index 1c6be98a586..9889df36137 100644 --- a/src/core/Akka/Pattern/BackoffOptions.cs +++ b/src/core/Akka/Pattern/BackoffOptions.cs @@ -11,7 +11,7 @@ namespace Akka.Pattern { /// - /// Builds back-off options for creating a back-off supervisor. You can pass to . + /// Builds back-off options for creating a back-off supervisor. You can pass to . /// public static class Backoff { diff --git a/src/core/Akka/Util/Reflection/ExpressionExtensions.cs b/src/core/Akka/Util/Reflection/ExpressionExtensions.cs index a9cbca58834..cbdb58e38b8 100644 --- a/src/core/Akka/Util/Reflection/ExpressionExtensions.cs +++ b/src/core/Akka/Util/Reflection/ExpressionExtensions.cs @@ -110,12 +110,11 @@ private static object[] ParseCallArgs(int argCount, } } } - catch (Exception exception) + catch (Exception) { //Fallback. Do the worst way and compile. try { - object fallbackVal; { _jobArgs[i] = Expression.Lambda( Expression.Convert(theArg, _objectType)