| | 1 | | // Copyright (c) 2020-2023 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.Runtime.CompilerServices; |
| | 7 | |
|
| | 8 | | namespace GDX.Experimental.Logging |
| | 9 | | { |
| | 10 | | public struct LogEntry |
| | 11 | | { |
| | 12 | | public DateTime Timestamp; |
| | 13 | | public LogLevel Level; |
| | 14 | | public uint Identifier; |
| | 15 | | public uint ParentIdentifier; |
| | 16 | | public int CategoryIdentifier; |
| | 17 | | public string Message; |
| | 18 | | public string MemberName; |
| | 19 | | public string SourceFilePath; |
| | 20 | | public int SourceLineNumber; |
| | 21 | |
|
| | 22 | | public string ToConsoleOutput() |
| 2 | 23 | | { |
| 2 | 24 | | return |
| | 25 | | $"[{ManagedLog.GetCategoryLabel(CategoryIdentifier)}::{LogLevelToLabel(Level)}] {Message}\n\t@ {SourceFi |
| 2 | 26 | | } |
| | 27 | |
|
| | 28 | | public string ToUnityOutput() |
| 2 | 29 | | { |
| 2 | 30 | | return $"{Message}\n\t@ {SourceFilePath}:{SourceLineNumber.ToString()}"; |
| 2 | 31 | | } |
| | 32 | |
|
| | 33 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 34 | | static string LogLevelToLabel(LogLevel level) |
| 2 | 35 | | { |
| 2 | 36 | | switch (level) |
| | 37 | | { |
| | 38 | | case LogLevel.Trace: |
| 0 | 39 | | return "Trace"; |
| | 40 | | case LogLevel.Debug: |
| 0 | 41 | | return "Debug"; |
| | 42 | | case LogLevel.Info: |
| 0 | 43 | | return "Info"; |
| | 44 | | case LogLevel.Warning: |
| 2 | 45 | | return "Warning"; |
| | 46 | | case LogLevel.Error: |
| 0 | 47 | | return "Error"; |
| | 48 | | case LogLevel.Exception: |
| 0 | 49 | | return "Exception"; |
| | 50 | | case LogLevel.Assertion: |
| 0 | 51 | | return "Assertion"; |
| | 52 | | case LogLevel.Fatal: |
| 0 | 53 | | return "Fatal"; |
| | 54 | | } |
| | 55 | |
|
| 0 | 56 | | return string.Empty; |
| 2 | 57 | | } |
| | 58 | | } |
| | 59 | | } |