Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify akka logs with neo logs #1623

Merged
merged 9 commits into from
May 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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