Beispiel #1
0
        internal static void Log(string message = "OK.", bool show = false, Defcon defcon = Defcon.DEFAULT)
        {
            switch (defcon)
            {
            case Defcon.INFO:
            {
                _logger.Info(message);
                break;
            }

            case Defcon.WARN:
            {
                _logger.Warn(message);
                break;
            }

            case Defcon.ERROR:
            {
                _logger.Error(message);
                break;
            }

            default:
            {
                _logger.Info(message);
                break;
            }
            }
            if (show)
            {
                Console.WriteLine(message);
            }
        }
Beispiel #2
0
        public static void Log(string _Message = "OK.", Defcon _Defcon = Defcon.DEFAULT)
        {
            switch (_Defcon)
            {
            case Defcon.DEBUG:
            {
                Logger.Debug(_Message);
                break;
            }

            case Defcon.INFO:
            {
                Logger.Info(_Message);
                break;
            }

            case Defcon.WARN:
            {
                Logger.Warn(_Message);
                break;
            }

            case Defcon.TRACE:
            {
                Logger.Trace(_Message);
                break;
            }

            case Defcon.ERROR:
            {
                Logger.Error(_Message);
                break;
            }

            case Defcon.FATAL:
            {
                Logger.Fatal(_Message);
                break;
            }

            default:
            {
                Logger.Info(_Message);
                break;
            }
            }
        }
Beispiel #3
0
        internal static void Log(string message = "OK.", Defcon defcon = Defcon.DEFAULT)
        {
            if (Constants.WriteLog)
            {
                switch (defcon)
                {
                case Defcon.INFO:
                {
                    _logger.Info(message);
                    break;
                }

                case Defcon.WARN:
                {
                    _logger.Warn(message);
                    break;
                }

                case Defcon.ERROR:
                {
                    _logger.Error(message);
                    break;
                }

                case Defcon.TRACE:
                {
                    _logger.Trace(message);
                    break;
                }

                case Defcon.FATAL:
                {
                    _logger.Fatal(message);
                    break;
                }

                default:
                {
                    _logger.Info(message);
                    break;
                }
                }
            }
        }
Beispiel #4
0
        internal static void Log(Message Message, string prefix = null, Defcon defcon = Defcon.DEBUG)
        {
            StringBuilder packet = new StringBuilder();

            packet.Append($"{DateTime.Now:yyyy/MM/dd/HH/mm/ss};");
            if (!string.IsNullOrEmpty(prefix))
            {
                packet.Append($"{prefix};");
            }
            packet.Append($"{Message.Identifier}({Message.Version});{Message.Length};");
            if (Message.Reader != null)
            {
                var data = Message.Reader.ReadFully();
                Message.Reader.BaseStream.Position = 0;
                packet.AppendLine(BitConverter.ToString(data.ToArray()).Replace("-", String.Empty));
                packet.AppendLine(Regex.Replace(Encoding.UTF8.GetString(data.ToArray()),
                                                @"[^\u0020-\u007F]", "."));
            }
            else if (Message.Data != null)
            {
                packet.AppendLine(BitConverter.ToString(Message.Data.ToArray()).Replace("-", String.Empty));
                packet.AppendLine(Regex.Replace(Encoding.UTF8.GetString(Message.Data.ToArray()),
                                                @"[^\u0020-\u007F]", "."));
            }

            switch (defcon)
            {
            case Defcon.TRACE:
            {
                _logger.Trace(packet.ToString);
                break;
            }

            default:
            {
                _logger.Debug(packet.ToString);
                break;
            }
            }
        }
Beispiel #5
0
 public void ChangeLockdown(Defcon lockdown)
 {
     this.Level = lockdown;
     if (OrderLockdownChanged != null)
         OrderLockdownChanged(this);
 }