| | 1 | | // Copyright (c) 2020-2024 dotBunny Inc. |
| | 2 | | // dotBunny licenses this file to you under the BSL-1.0 license. |
| | 3 | | // See the LICENSE file in the project root for more information. |
| | 4 | |
|
| | 5 | | using System; |
| | 6 | | using System.Collections.Generic; |
| | 7 | | using UnityEngine; |
| | 8 | |
|
| | 9 | | namespace GDX.Developer |
| | 10 | | { |
| | 11 | | public struct ConsoleLogEntry : IComparable<ConsoleLogEntry>, IComparer<ConsoleLogEntry> |
| | 12 | | { |
| | 13 | | public int Frame; |
| | 14 | | public string FrameCount; |
| | 15 | | public LogType Level; |
| | 16 | | public string Message; |
| | 17 | | public string StackTrace; |
| | 18 | |
|
| | 19 | | public ConsoleLogEntry(LogType type, string message, string stackTrace = null) |
| 13 | 20 | | { |
| 13 | 21 | | Frame = Time.frameCount; |
| 13 | 22 | | FrameCount = Frame.ToString().PadLeft(10, '0'); |
| 13 | 23 | | Level = type; |
| 13 | 24 | | Message = message; |
| 13 | 25 | | StackTrace = stackTrace; |
| 13 | 26 | | } |
| | 27 | |
|
| | 28 | | public int CompareTo(ConsoleLogEntry other) |
| 0 | 29 | | { |
| | 30 | |
|
| 0 | 31 | | if (Frame > other.Frame) |
| 0 | 32 | | { |
| 0 | 33 | | return 1; |
| | 34 | | } |
| | 35 | |
|
| 0 | 36 | | if (Frame < other.Frame) |
| 0 | 37 | | { |
| 0 | 38 | | return -1; |
| | 39 | | } |
| | 40 | |
|
| 0 | 41 | | return 0; |
| 0 | 42 | | } |
| | 43 | |
|
| | 44 | | public int Compare(ConsoleLogEntry x, ConsoleLogEntry y) |
| 0 | 45 | | { |
| 0 | 46 | | if (x.Frame > y.Frame) |
| 0 | 47 | | { |
| 0 | 48 | | return 1; |
| | 49 | | } |
| | 50 | |
|
| 0 | 51 | | if (x.Frame < y.Frame) |
| 0 | 52 | | { |
| 0 | 53 | | return -1; |
| | 54 | | } |
| | 55 | |
|
| 0 | 56 | | return 0; |
| 0 | 57 | | } |
| | 58 | | } |
| | 59 | | } |