/// <summary> /// This is used to interpret a SELF log, and convert it to rich, human-readable CSV. /// </summary> /// <param name="bLog">The binary log.</param> private void Interpret(SelfDecoder.BinaryLog bLog) { switch (bLog.Type) { case Shared.LogType.Dashboard: { var dashboardLog = Shared.DashboardLog.Deserialize(bLog); CsvStream.AppendLine(CompileCsv(new string[] { bLog.TimeStamp.ToString("T"), "Dashboard", "From " + dashboardLog.SourceIp, dashboardLog.Message })); break; } case Shared.LogType.Error: { var errorLog = Shared.ErrorLog.Deserialize(bLog); CsvStream.AppendLine(CompileCsv(new string[] { bLog.TimeStamp.ToString("T"), "Error", "Thrown in " + errorLog.Location, errorLog.Message })); break; } case Shared.LogType.Plugin: { var pluginLog = Shared.PluginLog.Deserialize(bLog); CsvStream.AppendLine(CompileCsv(new string[] { bLog.TimeStamp.ToString("T"), $"Plugin {pluginLog.PluginName}", pluginLog.Message })); break; } } }
public static DashboardLog Deserialize(SelfDecoder.BinaryLog source) { var data = new byte[source.LogData.Length - 4]; Buffer.BlockCopy(source.LogData, 4, data, 0, data.Length); return(new DashboardLog { SourceIp = new IPAddress(source.LogData.Take(4).ToArray()).ToString(), Message = Encoding.UTF8.GetString(data) }); }
public static ErrorLog Deserialize(SelfDecoder.BinaryLog source) { var location = (ErrorLocation)source.LogData[0]; var data = new byte[source.LogData.Length - 1]; Buffer.BlockCopy(source.LogData, 1, data, 0, data.Length); return(new ErrorLog() { Location = location, Message = Encoding.UTF8.GetString(data) }); }
public static PluginLog Deserialize(SelfDecoder.BinaryLog source) { var nameSize = source.LogData[0]; var data = new byte[nameSize]; var name = Encoding.UTF8.GetString(data); Buffer.BlockCopy(source.LogData, 1, data, 0, nameSize); data = new byte[source.LogData.Length - nameSize - 1]; Buffer.BlockCopy(source.LogData, nameSize + 1, data, 0, data.Length); return(new PluginLog() { PluginName = name, Message = Encoding.UTF8.GetString(data) }); }
public static RpcLog Deserialize(SelfDecoder.BinaryLog source) { var log = new RpcLog(); log.Type = (Shared.RpcCalls)source.LogData[0]; var buffer = new byte[4]; Buffer.BlockCopy(source.LogData, 1, buffer, 0, 4); log.GameCode = BitConverter.ToInt32(buffer, 0); Buffer.BlockCopy(source.LogData, 5, buffer, 0, 4); log.IpAddress = new IPAddress(buffer).ToString(); buffer = new byte[source.LogData.Length - 9]; Buffer.BlockCopy(source.LogData, 9, buffer, 0, buffer.Length); log.RpcData = buffer; return(log); }