Beispiel #1
0
 public static void Initialize()
 {
     Loggers log = new Loggers();
     Console.Title = "Cargando Sunglow:";
     Console.WriteLine("###################################################");
     Console.WriteLine("# © NeoForex 2010-12                              #");
     Console.WriteLine("# SunGlow r0.0.1                                  #");
     Console.WriteLine("# Por: Forex                                      #");
     Console.WriteLine("# Creditos a: LittleJ, Itachi y Mas gente         #");
     Console.WriteLine("###################################################\n");
     Console.WriteLine("[" + DateTime.Now.ToString() + "] Iniciando SunGlow:");
     try
     {
         mConfig = new ConfigurationManager("Config.conf");
         Console.WriteLine("[" + DateTime.Now.ToString() +"] Iniciando sockets.");
         mListener = new TCPListener();
         Console.WriteLine("[" + DateTime.Now.ToString() + "] SunGlow iniciado, esperando conexiones.");
         PacketManager.Register();
         Token = new BigInteger(DiffieHellman.GenerateRandomHexString(15), 16).ToString();
     }
     catch (Exception e)
     {
         Loggers.AddError(e, "Environment");
     }
 }
Beispiel #2
0
        public void Run()
        {
            List <IAppender> appenders = new List <IAppender>();

            int counter = int.Parse(Console.ReadLine());

            for (int i = 0; i < counter; i++)
            {
                string[] inputInfo = Console.ReadLine()
                                     .Split(" ", StringSplitOptions.RemoveEmptyEntries);


                string      appenderType = inputInfo[0];
                string      layoutType   = inputInfo[1];
                ReportLevel reportLevel  = ReportLevel.INFO;

                if (inputInfo.Length > 2)
                {
                    reportLevel = Enum.Parse <ReportLevel>(inputInfo[2], true);
                }

                ILayout   layout   = LayoutFactory.CreateLayout(layoutType);
                IAppender appender = AppenderFactory.CreateAppender(appenderType, layout, reportLevel);

                appenders.Add(appender);
            }

            string input = Console.ReadLine();

            ILoggers loggers = new Loggers(appenders.ToArray());

            while (input != "END")
            {
                string[] inputInfo = input.Split("|");

                string loggerType = inputInfo[0];
                string date       = inputInfo[1];
                string message    = inputInfo[2];

                if (loggerType == "INFO")
                {
                    loggers.Info(date, message);
                }
                if (loggerType == "ERROR")
                {
                    loggers.Error(date, message);
                }
                if (loggerType == "WARNING")
                {
                    loggers.Warning(date, message);
                }
                if (loggerType == "CRITICAL")
                {
                    loggers.Critical(date, message);
                }
                if (loggerType == "FATAL")
                {
                    loggers.Fatal(date, message);
                }

                input = Console.ReadLine();
            }

            Console.WriteLine("Logger info");

            foreach (var appender1 in appenders)
            {
                Console.WriteLine(appender1);
            }
        }