コード例 #1
0
ファイル: Log.cs プロジェクト: jiangboh/httpServer
 public static void SetLogLevel(String level)
 {
     if (String.Compare(level, "debug", true) == 0)
     {
         logLevel = MyLogLevel.LOG_DEBUG;
     }
     else if (String.Compare(level, "info", true) == 0)
     {
         logLevel = MyLogLevel.LOG_INFO;
     }
     else if (String.Compare(level, "warning", true) == 0)
     {
         logLevel = MyLogLevel.LOG_WARNING;
     }
     else if (String.Compare(level, "error", true) == 0)
     {
         logLevel = MyLogLevel.LOG_ERROR;
     }
     else if (String.Compare(level, "nowrite", true) == 0)
     {
         logLevel = MyLogLevel.LOG_NOWRITE;
     }
     else
     {
         logLevel = MyLogLevel.LOG_DEBUG;
     }
 }
コード例 #2
0
 public void Write(MyLogLevel level, string message)
 {
     lock (m_builder)
     {
         m_builder.Append(message);
     }
     FlushIfInsideSameThread();
 }
コード例 #3
0
 public void Write(MyLogLevel level, char message)
 {
     lock (m_builders)
     {
         m_builders[(int)level].Append(message);
     }
     FlushIfInsideSameThread();
 }
コード例 #4
0
ファイル: Log.cs プロジェクト: xeronith/BrainSimulator
            public void Write(MyLogLevel level, char value)
            {
                ConsoleColor tmp = Console.ForegroundColor;

                Console.ForegroundColor = GetConsoleColor(level);
                m_stdOut.Write(value);
                m_stdOut.Flush();
                Console.ForegroundColor = tmp;
            }
コード例 #5
0
ファイル: Log.cs プロジェクト: xeronith/BrainSimulator
            public void WriteLine(MyLogLevel level, string value)
            {
                ConsoleColor tmp = Console.ForegroundColor;

                Console.ForegroundColor = GetConsoleColor(level);
                m_stdOut.WriteLine("[" + level + "] " + value);
                m_stdOut.Flush();
                Console.ForegroundColor = tmp;
            }
コード例 #6
0
 public void WriteLine(MyLogLevel level, string message)
 {
     lock (m_builder)
     {
         if (level > MyLogLevel.INFO)
         {
             m_builder.Append("[" + level + "] ");
         }
         m_builder.Append(message);
         m_builder.Append("\n");
     }
     FlushIfInsideSameThread();
 }
コード例 #7
0
 public void WriteLine(MyLogLevel level, string message)
 {
     lock (m_builders)
     {
         StringBuilder builder = m_builders[(int)level];
         if (level > MyLogLevel.INFO)
         {
             builder.Append("[" + level + "] ");
         }
         builder.Append(message);
         builder.Append("\n");
     }
     FlushIfInsideSameThread();
 }
コード例 #8
0
ファイル: Log.cs プロジェクト: xeronith/BrainSimulator
            private static ConsoleColor GetConsoleColor(MyLogLevel level)
            {
                switch (level)
                {
                case MyLogLevel.DEBUG: return(ConsoleColor.Gray);

                case MyLogLevel.INFO: return(ConsoleColor.White);

                case MyLogLevel.WARNING: return(ConsoleColor.Yellow);

                case MyLogLevel.ERROR: return(ConsoleColor.Red);
                }
                return(ConsoleColor.White);
            }
コード例 #9
0
        public MyProjectRunner(MyLogLevel level = MyLogLevel.DEBUG)
        {
            // why not to directly ask for TypeMap.GetInstance<MySimulation> ?
            // because in Typemap configuration, MySimulation is set to be singleton - this causes problems when MyProjectRunner
            // is instantiated multiple times - second and following instances obtain an instance of MySimulation from the first
            // MyProjectRunner instance. If the first MyProjectRunner instance was Shutdown-ed, the MySimulation instance is also
            // cleared and any following Shutdown on other MyProjectRunner instances will cause freeze/inifnite hang.
            // This code creates new MySimulation instance for each MyProjectRunner instance.
            // Other solution could be to not have a MySimulation as a singleton in TypeMap configuration - and it could work just OK,
            // because in BrainSim, the TypeMap's GetInstance on MySimulation is only on one place in MainForm. However, this may change
            // in future or the change itself may have other consequences, so for now I pick this solution, as it is safer.
            MySimulation simulation = new MyLocalSimulation(TypeMap.GetInstance <MyValidator>(), TypeMap.GetInstance <IMyExecutionPlanner>());

            SimulationHandler = new MySimulationHandler(simulation);
            m_resultIdCounter = 0;

            SimulationHandler.ProgressChanged += SimulationHandler_ProgressChanged;
            SimulationHandler.StepPerformed   += SimulationHandler_StepPerformed;

            m_monitors = new List <Tuple <int, uint, MonitorFunc> >();
            m_results  = new Hashtable();

            Project = new MyProject();

            var path = MyResources.GetEntryAssemblyPath();

            if (MyConfiguration.ModulesSearchPath.Count == 0)
            {
                MyConfiguration.SetupModuleSearchPath();
            }
            MyConfiguration.ProcessCommandParams();

            try
            {
                if (MyConfiguration.Modules.Count == 0)
                {
                    MyConfiguration.LoadModules();
                }
            }
            catch (Exception e)
            {
                MyLog.WARNING.WriteLine(e.Message);
                throw;
            }

            MyLog.Level = level;
        }
コード例 #10
0
        public IEnumerable <BrainTest> FindTests()
        {
            MyLogLevel originalLogLevel = MyLog.Level;

            MyLog.Level = MyLogLevel.INFO;

            var testList = new List <BrainTest>();

            try
            {
                testList.AddRange(SafeCollectTests(CollectBinaryTests));
                testList.AddRange(SafeCollectTests(CollectBrainUnitNodeTests));
            }
            finally
            {
                MyLog.Level = originalLogLevel;
            }

            return(string.IsNullOrEmpty(m_filter)
                ? testList
                : testList.Where(test => test.Name.ToLower().Contains(m_filter)));
        }
コード例 #11
0
        public MyProjectRunner(MyLogLevel level = MyLogLevel.DEBUG)
        {
            MySimulation simulation = TypeMap.GetInstance <MySimulation>();

            SimulationHandler = new MySimulationHandler(simulation);
            m_resultIdCounter = 0;

            SimulationHandler.ProgressChanged += SimulationHandler_ProgressChanged;
            SimulationHandler.StepPerformed   += SimulationHandler_StepPerformed;

            m_monitors = new List <Tuple <int, uint, MonitorFunc> >();
            m_results  = new Hashtable();

            Project = new MyProject();

            var path = MyResources.GetEntryAssemblyPath();

            if (MyConfiguration.ModulesSearchPath.Count == 0)
            {
                MyConfiguration.SetupModuleSearchPath();
            }
            MyConfiguration.ProcessCommandParams();

            try
            {
                if (MyConfiguration.Modules.Count == 0)
                {
                    MyConfiguration.LoadModules();
                }
            }
            catch (Exception e)
            {
                MyLog.WARNING.WriteLine(e.Message);
                throw;
            }

            MyLog.Level = level;
        }
コード例 #12
0
ファイル: Log.cs プロジェクト: sschocke/BrainSimulator
 private MyLog(MyLogLevel level)
 {
     m_level = level;
 }
コード例 #13
0
ファイル: Log.cs プロジェクト: sschocke/BrainSimulator
 public void WriteLine(MyLogLevel level, string value)
 {
     ConsoleColor tmp = Console.ForegroundColor;
     Console.ForegroundColor = GetConsoleColor(level);
     m_stdOut.WriteLine("[" + level + "] " + value);
     m_stdOut.Flush();
     Console.ForegroundColor = tmp;
 }
コード例 #14
0
ファイル: Log.cs プロジェクト: sschocke/BrainSimulator
 private static ConsoleColor GetConsoleColor(MyLogLevel level)
 {
     switch (level)
     {
         case MyLogLevel.DEBUG: return ConsoleColor.Gray;
         case MyLogLevel.INFO: return ConsoleColor.White;
         case MyLogLevel.WARNING: return ConsoleColor.Yellow;
         case MyLogLevel.ERROR: return ConsoleColor.Red;
     }
     return ConsoleColor.White;
 }
コード例 #15
0
ファイル: ConsoleForm.cs プロジェクト: J-F-B-M/BrainSimulator
 public void WriteLine(MyLogLevel level, string message)
 {
     lock (m_builders)
     {
         StringBuilder builder = m_builders[(int)level];
         if (level > MyLogLevel.INFO)
         {
             builder.Append("[" + level + "] ");
         }
         builder.Append(message);
         builder.Append("\n");
     }
     FlushIfInsideSameThread();
 }
コード例 #16
0
ファイル: Log.cs プロジェクト: sschocke/BrainSimulator
 public void Write(MyLogLevel level, char value)
 {
     ConsoleColor tmp = Console.ForegroundColor;
     Console.ForegroundColor = GetConsoleColor(level);
     m_stdOut.Write(value);
     m_stdOut.Flush();
     Console.ForegroundColor = tmp;
 }
コード例 #17
0
ファイル: ConsoleForm.cs プロジェクト: J-F-B-M/BrainSimulator
 public void WriteLine(MyLogLevel level, string message)
 {
     lock (m_builder)
     {
         if (level > MyLogLevel.INFO)
         {
             m_builder.Append("[" + level + "] ");
         }
         m_builder.Append(message);
         m_builder.Append("\n");
     }
     FlushIfInsideSameThread();
 }
コード例 #18
0
ファイル: ConsoleForm.cs プロジェクト: J-F-B-M/BrainSimulator
 public void Write(MyLogLevel level, char message)
 {
     lock (m_builders)
     {
         m_builders[(int)level].Append(message);
     }
     FlushIfInsideSameThread();
 }
コード例 #19
0
        public MyProjectRunner(MyLogLevel level = MyLogLevel.DEBUG)
        {
            MySimulation simulation = TypeMap.GetInstance<MySimulation>();
            SimulationHandler = new MySimulationHandler(simulation);
            m_resultIdCounter = 0;

            SimulationHandler.ProgressChanged += SimulationHandler_ProgressChanged;
            SimulationHandler.StepPerformed += SimulationHandler_StepPerformed;

            m_monitors = new List<Tuple<int, uint, MonitorFunc>>();
            m_results = new Hashtable();

            Project = new MyProject();

            var path = MyResources.GetEntryAssemblyPath();

            if (MyConfiguration.ModulesSearchPath.Count == 0)
                MyConfiguration.SetupModuleSearchPath();
            MyConfiguration.ProcessCommandParams();

            try
            {
                if (MyConfiguration.Modules.Count == 0)
                    MyConfiguration.LoadModules();
            }
            catch (Exception e)
            {
                MyLog.WARNING.WriteLine(e.Message);
                throw;
            }

            MyLog.Level = level;
        }
コード例 #20
0
ファイル: ConsoleForm.cs プロジェクト: J-F-B-M/BrainSimulator
 public void Write(MyLogLevel level, string message)
 {
     lock (m_builder)
     {
         m_builder.Append(message);
     }
     FlushIfInsideSameThread();
 }
コード例 #21
0
ファイル: Log.cs プロジェクト: xeronith/BrainSimulator
 public void WriteLine(MyLogLevel level, string value)
 {
     m_output.WriteLine("[" + level + "] " + value);
 }
コード例 #22
0
ファイル: Log.cs プロジェクト: xeronith/BrainSimulator
 private MyLog(MyLogLevel level)
 {
     m_level = level;
 }
コード例 #23
0
ファイル: Log.cs プロジェクト: GoodAI/BrainSimulator
 public void Write(MyLogLevel level, char value)
 {
     m_output.WriteLine(value);
 }
コード例 #24
0
 public void Write(MyLogLevel level, string message)
 {
     m_output.WriteLine(message);
 }
コード例 #25
0
 private static void ReadLogLevel(JsonData json, ref MyLogLevel value)
 {
     if (json != null && json.IsString)
     {
         string testVal = ((string)json).ToLowerInvariant();
         if (testVal == "log")
             value = MyLogLevel.LogAll;
         if (testVal == "warning")
             value = MyLogLevel.Warning;
         if (testVal == "error")
             value = MyLogLevel.Errors;
         if (testVal == "none")
             value = MyLogLevel.None;
     }
 }
コード例 #26
0
ファイル: Log.cs プロジェクト: GoodAI/BrainSimulator
 public void Write(MyLogLevel level, string value)
 {
     m_output.Write(value);
 }
コード例 #27
0
ファイル: Log.cs プロジェクト: GoodAI/BrainSimulator
 public void WriteLine(MyLogLevel level, string value)
 {
     m_output.WriteLine("[" + level + "] " + value);
 }
コード例 #28
0
 private static bool TestLogLevel(MyLogLevel myLog, LogType testLog)
 {
     switch(testLog)
     {
         case LogType.Log:
             return myLog <= MyLogLevel.LogAll;
         case LogType.Warning:
             return myLog <= MyLogLevel.Warning;
         default:
             return myLog <= MyLogLevel.Errors;
     }
 }
コード例 #29
0
ファイル: Log.cs プロジェクト: xeronith/BrainSimulator
 public void Write(MyLogLevel level, char value)
 {
     m_output.WriteLine(value);
 }
コード例 #30
0
 public void Write(MyLogLevel level, char message)
 {
     m_output.WriteLine(message.ToString());
 }
コード例 #31
0
ファイル: Log.cs プロジェクト: xeronith/BrainSimulator
 public void Write(MyLogLevel level, string value)
 {
     m_output.Write(value);
 }