Changeset 350 for binary-improvements/MapRendering/Web/API/GetLog.cs
- Timestamp:
- Jan 19, 2019, 6:08:32 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/API/GetLog.cs
r325 r350 5 5 namespace AllocsFixes.NetConnections.Servers.Web.API { 6 6 public class GetLog : WebAPI { 7 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, 8 int permissionLevel) { 9 int firstLine, lastLine; 7 private const int MAX_COUNT = 1000; 8 9 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 10 int _permissionLevel) { 11 int count, firstLine, lastLine; 10 12 11 if (req.QueryString ["firstLine"] == null || !int.TryParse (req.QueryString ["firstLine"], out firstLine)) { 12 firstLine = LogBuffer.Instance.OldestLine; 13 if (_req.QueryString ["count"] == null || !int.TryParse (_req.QueryString ["count"], out count)) { 14 count = 50; 15 } 16 17 if (count == 0) { 18 count = 1; 19 } 20 21 if (count > MAX_COUNT) { 22 count = MAX_COUNT; 23 } 24 25 if (count < -MAX_COUNT) { 26 count = -MAX_COUNT; 27 } 28 29 if (_req.QueryString ["firstLine"] == null || !int.TryParse (_req.QueryString ["firstLine"], out firstLine)) { 30 if (count > 0) { 31 firstLine = LogBuffer.Instance.OldestLine; 32 } else { 33 firstLine = LogBuffer.Instance.LatestLine; 34 } 13 35 } 14 36 15 37 JSONObject result = new JSONObject (); 16 38 17 List<LogBuffer.LogEntry> logEntries = LogBuffer.Instance.GetRange (ref firstLine, 50, out lastLine);39 List<LogBuffer.LogEntry> logEntries = LogBuffer.Instance.GetRange (ref firstLine, count, out lastLine); 18 40 19 41 JSONArray entries = new JSONArray (); … … 25 47 entry.Add ("msg", new JSONString (logEntry.message)); 26 48 entry.Add ("trace", new JSONString (logEntry.trace)); 27 entry.Add ("type", new JSONString (logEntry.type.ToString ()));49 entry.Add ("type", new JSONString (logEntry.type.ToStringCached ())); 28 50 entries.Add (entry); 29 51 } … … 33 55 result.Add ("entries", entries); 34 56 35 WriteJSON ( resp, result);57 WriteJSON (_resp, result); 36 58 } 37 59 }
Note:
See TracChangeset
for help on using the changeset viewer.