Changeset 382 for binary-improvements2/MapRendering/Web/LogBuffer.cs
- Timestamp:
- Aug 1, 2022, 12:54:31 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/MapRendering/Web/LogBuffer.cs
r369 r382 5 5 namespace AllocsFixes.NetConnections.Servers.Web { 6 6 public class LogBuffer { 7 private const int MAX_ENTRIES = 3000; 7 private const int maxEntries = 3000; 8 8 9 private static LogBuffer instance; 9 10 … … 22 23 } 23 24 24 public static LogBuffer Instance { 25 get { 26 if (instance == null) { 27 instance = new LogBuffer (); 28 } 29 30 return instance; 31 } 32 } 25 public static LogBuffer Instance => instance ?? (instance = new LogBuffer ()); 33 26 34 27 public int OldestLine { … … 69 62 70 63 private void LogCallback (string _formattedMsg, string _plainMsg, string _trace, LogType _type, DateTime _timestamp, long _uptime) { 71 LogEntry le = new LogEntry (); 72 73 le.date = $"{_timestamp.Year:0000}-{_timestamp.Month:00}-{_timestamp.Day:00}"; 74 le.time = $"{_timestamp.Hour:00}:{_timestamp.Minute:00}:{_timestamp.Second:00}"; 75 le.uptime = _uptime.ToString (); 76 le.message = _plainMsg; 77 le.trace = _trace; 78 le.type = _type; 64 LogEntry le = new LogEntry (_timestamp, _plainMsg, _trace, _type, _uptime); 79 65 80 66 lock (logEntries) { 81 67 logEntries.Add (le); 82 if (logEntries.Count > MAX_ENTRIES) {83 listOffset += logEntries.Count - MAX_ENTRIES;84 logEntries.RemoveRange (0, logEntries.Count - MAX_ENTRIES);68 if (logEntries.Count > maxEntries) { 69 listOffset += logEntries.Count - maxEntries; 70 logEntries.RemoveRange (0, logEntries.Count - maxEntries); 85 71 } 86 72 } … … 140 126 141 127 public class LogEntry { 142 public string date; 143 public string message; 144 public string time; 145 public string trace; 146 public LogType type; 147 public string uptime; 128 public readonly DateTime timestamp; 129 public readonly string date; 130 public readonly string time; 131 public readonly string isoTime; 132 public readonly string message; 133 public readonly string trace; 134 public readonly LogType type; 135 public readonly long uptime; 136 137 public LogEntry (DateTime _timestamp, string _message, string _trace, LogType _type, long _uptime) { 138 timestamp = _timestamp; 139 date = $"{_timestamp.Year:0000}-{_timestamp.Month:00}-{_timestamp.Day:00}"; 140 time = $"{_timestamp.Hour:00}:{_timestamp.Minute:00}:{_timestamp.Second:00}"; 141 isoTime = _timestamp.ToString ("o"); 142 143 message = _message; 144 trace = _trace; 145 type = _type; 146 uptime = _uptime; 147 } 148 148 } 149 149 }
Note:
See TracChangeset
for help on using the changeset viewer.