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; } }
public void Write(MyLogLevel level, string message) { lock (m_builder) { m_builder.Append(message); } FlushIfInsideSameThread(); }
public void Write(MyLogLevel level, char message) { lock (m_builders) { m_builders[(int)level].Append(message); } FlushIfInsideSameThread(); }
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; }
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; }
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(); }
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(); }
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); }
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; }
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))); }
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; }
private MyLog(MyLogLevel level) { m_level = level; }
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; }
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; }
public void WriteLine(MyLogLevel level, string value) { m_output.WriteLine("[" + level + "] " + value); }
public void Write(MyLogLevel level, char value) { m_output.WriteLine(value); }
public void Write(MyLogLevel level, string message) { m_output.WriteLine(message); }
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; } }
public void Write(MyLogLevel level, string value) { m_output.Write(value); }
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; } }
public void Write(MyLogLevel level, char message) { m_output.WriteLine(message.ToString()); }