Skip to content

Commit

Permalink
Unify akka logs with neo logs (neo-project#1623)
Browse files Browse the repository at this point in the history
* Unify akka logs

* Add event

* dotnet format

* Remove event

* Remove overload

* Clean changes

* Fix compilation error

* Simplify Logger

Co-authored-by: erikzhang <[email protected]>
  • Loading branch information
2 people authored and Tommo-L committed Jun 22, 2020
1 parent b9b853e commit 3cec48b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/neo/LogLevel.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using static Akka.Event.LogLevel;

namespace Neo
{
public enum LogLevel : byte
{
Fatal,
Error,
Warning,
Info,
Debug
Debug = DebugLevel,
Info = InfoLevel,
Warning = WarningLevel,
Error = ErrorLevel,
Fatal = Error + 1
}
}
2 changes: 1 addition & 1 deletion src/neo/NeoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Neo
public class NeoSystem : IDisposable
{
public ActorSystem ActorSystem { get; } = ActorSystem.Create(nameof(NeoSystem),
$"akka {{ log-dead-letters = off }}" +
$"akka {{ log-dead-letters = off , loglevel = warning, loggers = [ \"{typeof(Utility.Logger).AssemblyQualifiedName}\" ] }}" +
$"blockchain-mailbox {{ mailbox-type: \"{typeof(BlockchainMailbox).AssemblyQualifiedName}\" }}" +
$"task-manager-mailbox {{ mailbox-type: \"{typeof(TaskManagerMailbox).AssemblyQualifiedName}\" }}" +
$"remote-node-mailbox {{ mailbox-type: \"{typeof(RemoteNodeMailbox).AssemblyQualifiedName}\" }}" +
Expand Down
11 changes: 11 additions & 0 deletions src/neo/Utility.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Akka.Actor;
using Akka.Event;
using Microsoft.Extensions.Configuration;
using Neo.Plugins;
using System;
Expand All @@ -6,6 +8,15 @@ namespace Neo
{
public static class Utility
{
internal class Logger : ReceiveActor
{
public Logger()
{
Receive<InitializeLogger>(_ => Sender.Tell(new LoggerInitialized()));
Receive<LogEvent>(e => Log(e.LogSource, (LogLevel)e.LogLevel(), e.Message.ToString()));
}
}

/// <summary>
/// Load configuration with different Environment Variable
/// </summary>
Expand Down

0 comments on commit 3cec48b

Please sign in to comment.