Represents an Warning log event.
Inheritance: LogEvent
 protected override bool Receive(object message)
 {
     if(message is InitializeLogger)
     {
         var initLogger = (InitializeLogger)message;
         var bus = initLogger.LoggingBus;
         var self = Context.Self;
         bus.Subscribe(self, typeof(Mute));
         bus.Subscribe(self, typeof(Unmute));
         bus.Subscribe(self, typeof(DeadLetter));
         bus.Subscribe(self, typeof(UnhandledMessage));
         Sender.Tell(new LoggerInitialized());
     }
     else if(message is Mute)
     {
         var mute = (Mute)message;
         foreach(var filter in mute.Filters)
         {
             AddFilter(filter);
         }
     }
     else if(message is Unmute)
     {
         var unmute = (Unmute)message;
         foreach(var filter in unmute.Filters)
         {
             RemoveFilter(filter);
         }
     }
     else if(message is LogEvent)
     {
         var logEvent = (LogEvent)message;
         if(!ShouldFilter(logEvent))
         {
             Print(logEvent);
         }
     }
     else if(message is DeadLetter)
     {
         HandleDeadLetter((DeadLetter)message);
     }
     else if(message is UnhandledMessage)
     {
         var un = (UnhandledMessage) message;
         var rcp = un.Recipient;
         var warning = new Warning(rcp.Path.ToString(), rcp.GetType(), "Unhandled message from " + un.Sender + ": " + un.Message);
         if(!ShouldFilter(warning))
             Print(warning);
     }
     else
     {
         Print(new Debug(Context.System.Name,GetType(),message));
     }
     return true;
 }
        private void HandleDeadLetter(DeadLetter message)
        {
            var msg = message.Message;
            var rcp = message.Recipient;
            var snd = message.Sender;
            if(!(msg is Terminate))
            {
                var recipientPath = rcp.Path.ToString();
                var recipientType = rcp.GetType();
                var warning = new Warning(recipientPath, recipientType, message);
                if(!ShouldFilter(warning))
                {
                    var msgStr = (msg is SystemMessage)
                        ? "Received dead system message: " + msg
                        : "Received dead letter from " + snd + ": " + msg;
                    var warning2 = new Warning(recipientPath, recipientType, new DeadLetter(msgStr,snd,rcp));
                    if(!ShouldFilter(warning2))
                    {
                        Print(warning2);
                    }
                }

            }
        }
Exemple #3
0
 private void Handle(Warning message)
 {
     Trace.TraceWarning("{0} {1}: {2}", message.Timestamp, message.LogSource, message.Message);
 }