public SysLog(byte[] aBinarySysLogData) { iEntries = aBinarySysLogData.Length / SysLogEntry.kSysLogEntryBytes; iLog = new SysLogEntry[iEntries]; for (int i = 0; i < iEntries; i++) { iLog[i] = new SysLogEntry(aBinarySysLogData, i * SysLogEntry.kSysLogEntryBytes); } }
private string GetSysLogPretty(byte[] aSysLogResponse, string aApplicationStartupPath) { string sysLogString = ""; try { SysLog sys = new SysLog(aSysLogResponse); Tags tags = null; // try the default installer location string fullpath = Path.GetFullPath(Path.Combine(aApplicationStartupPath, "Tags.xml")); if (File.Exists(fullpath)) { tags = new Tags(File.ReadAllText(fullpath)); } else { // try the default build location fullpath = Path.GetFullPath(Path.Combine(aApplicationStartupPath, "../../share/Linn/ProductSupport/Tags.xml")); if (File.Exists(fullpath)) { tags = new Tags(File.ReadAllText(fullpath)); } else { return("System Log Error: Could not find the file 'Tags.xml'" + Environment.NewLine); } } int maxSize = 0; for (int i = 0; i < sys.Entries; i++) { SysLogEntry entry = sys.At(i); string var = tags.Tag(entry.Key); if (var.Length > maxSize) { maxSize = var.Length; } } for (int i = 0; i < sys.Entries; i++) { SysLogEntry entry = sys.At(i); ulong left = entry.TimestampUs / 1000000; ulong right = entry.TimestampUs % 1000000; sysLogString += left.ToString().PadLeft(8) + "." + right.ToString().PadLeft(6, '0') + "s: " + tags.Tag(entry.Key).PadLeft(maxSize); sysLogString += " [0x" + entry.Payload.ToString("x").PadLeft(8, '0') + " " + entry.Payload + "]" + Environment.NewLine; } } catch (Exception e) { return("System Log Error: " + e.Message + Environment.NewLine); } return(sysLogString); }