Exemple #1
0
        public static List<LogEntry> LoadThalamusLogEntries(string filename, string assemblyPath = ".")
        {
            if (!File.Exists(filename))
            {
                throw new FileNotFoundException("File '" + filename + "' does not exist!");
            }
            else
            {
                string logFile = "";

                List<LogEntry> logEntries = new List<LogEntry>();

                List<string> failedInterfaces = new List<string>();
                using (StreamReader file = File.OpenText(filename))
                {
                    logFile = file.ReadToEnd();
                    string[] stringlogs = logFile.Split('\n');

                    foreach (string s in stringlogs)
                    {
                        try
                        {
                            if (s.Trim().Length > 0 && Regex.IsMatch(s, thalamusLogRegexValidator))
                            {
                                string log = s.Replace('\r', ' ').Trim();
                                string[] split = log.Split(':');

                                //find split[6] in assemblies
                                string interfaceName = split[6].Substring(0, split[6].IndexOf('.'));
                                if (loadedMessageTypes.ContainsKey(interfaceName))
                                {
                                    MethodInfo[] events = loadedMessageTypes[interfaceName].GetMethods();
                                    string eventName = split[6].Substring(split[6].LastIndexOf('.') + 1);
                                    foreach (MethodInfo ev in events)
                                    {
                                        if (ev.Name == eventName)
                                        {
                                            string value = log.Substring(LogTool.IndexOfNth(log, ':', 8) + 1);
                                            object[] ovalues = new object[] { };
                                            if (value.Length > 2)
                                            {
                                                value = value.Substring(1, value.Length - 3);
                                                string[] splitValues = value.Split(';');
                                                ovalues = new object[splitValues.Length];
                                                for (int i = 0; i < splitValues.Length; i++)
                                                {
                                                    ovalues[i] = splitValues[i].Split('=')[1];
                                                }
                                            }
                                            else value = "";

                                            PML pml = new PML(split[6], ev, ovalues);
                                            LogEntry l = new LogEntry(split[5].Length == 0, double.Parse(split[3].Trim().Replace(',', '.'), ifp), "", split[5].Length == 0 ? split[6] : split[5], pml);
                                            logEntries.Add(l);
                                            //Console.WriteLine("Loaded LogEntry: " + l.ToString());
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    if (!failedInterfaces.Contains(interfaceName)) failedInterfaces.Add(interfaceName);
                                }

                            }
                        }
                        catch (Exception e)
                        {
                            throw e;
                        }
                    }
                }
                if (failedInterfaces.Count > 0)
                {
                    if (LoadingInterfacesErrorEvent != null) LoadingInterfacesErrorEvent(null, new LoadingInterfacesErrorEventArgs(failedInterfaces));
                    string txt = "Failed to find the following types:\n";
                    foreach (string s in failedInterfaces)
                    {
                        txt += "\t" + s + "\n";
                    }
                    Console.WriteLine(txt);
                    //MessageBox.Show(txt, "Load Thalamus LogEntries", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                }
                return logEntries;
            }
        }
Exemple #2
0
 public void AddLog(LogEntry logEntry)
 {
     lock (logQueue)
     {
         logQueue.Add(logEntry);
     }
     updateLog = true;
 }
 void Client_EventLogged(LogEntry logEntry)
 {
     Console.WriteLine("Thalamus Event: " + logEntry.ToString());
 }
Exemple #4
0
 public void NotifyEventLogged(LogEntry logEntry)
 {
     if (EventLogged != null) EventLogged(logEntry);
 }
Exemple #5
0
 public void LogEvent(bool outwards, PML ev)
 {
     LogEntry l = new LogEntry(outwards, CentralTimePassed().TotalSeconds, ev);
     DebugLog(l.ToString());
     NotifyEventLogged(l);
     logs.Add(l);
 }
Exemple #6
0
        public void LogEvent(bool outwards, Character character, ThalamusClientProxy client, PML ev)
        {
            LogEntry l = new LogEntry(outwards, CentralTimePassed().TotalSeconds, character.Name, client == null ? "GUI" : client.Name, ev);
			DebugLog(l.ToString());
            NotifyEventLogged(l);
            logs.Add(l);
            if (character.LogToCSV) lock (csvLogs) { csvLogs.Add(l); }
        }