From abe967c764e2216bacdd8045237f2c5cb17089cc Mon Sep 17 00:00:00 2001 From: Varneon Date: Sun, 19 Mar 2023 13:44:07 -0700 Subject: [PATCH 1/2] Add timestamp format option to UdonConsole --- .../Runtime/Udon Programs/UdonConsole.asset | 193 ++++++++++++------ .../Runtime/Udon Programs/UdonConsole.cs | 12 +- 2 files changed, 136 insertions(+), 69 deletions(-) diff --git a/Packages/com.varneon.vudon.logger/Runtime/Udon Programs/UdonConsole.asset b/Packages/com.varneon.vudon.logger/Runtime/Udon Programs/UdonConsole.asset index f9ff1a6..0f33b84 100644 --- a/Packages/com.varneon.vudon.logger/Runtime/Udon Programs/UdonConsole.asset +++ b/Packages/com.varneon.vudon.logger/Runtime/Udon Programs/UdonConsole.asset @@ -44,7 +44,7 @@ MonoBehaviour: Data: - Name: Entry: 12 - Data: 19 + Data: 20 - Name: Entry: 7 Data: @@ -516,13 +516,13 @@ MonoBehaviour: Data: - Name: $k Entry: 1 - Data: systemPrefix + Data: timestampFormat - Name: $v Entry: 7 Data: 36|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 - Data: systemPrefix + Data: timestampFormat - Name: k__BackingField Entry: 7 Data: 37|System.RuntimeType, mscorlib @@ -603,13 +603,13 @@ MonoBehaviour: Data: - Name: $k Entry: 1 - Data: playerJoinPrefix + Data: systemPrefix - Name: $v Entry: 7 Data: 43|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 - Data: playerJoinPrefix + Data: systemPrefix - Name: k__BackingField Entry: 9 Data: 37 @@ -666,13 +666,13 @@ MonoBehaviour: Data: - Name: $k Entry: 1 - Data: playerLeavePrefix + Data: playerJoinPrefix - Name: $v Entry: 7 Data: 47|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 - Data: playerLeavePrefix + Data: playerJoinPrefix - Name: k__BackingField Entry: 9 Data: 37 @@ -729,16 +729,79 @@ MonoBehaviour: Data: - Name: $k Entry: 1 - Data: logWindow + Data: playerLeavePrefix - Name: $v Entry: 7 Data: 51|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: k__BackingField + Entry: 1 + Data: playerLeavePrefix + - Name: k__BackingField + Entry: 9 + Data: 37 + - Name: k__BackingField + Entry: 9 + Data: 37 + - Name: k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 52|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 2 + - Name: + Entry: 7 + Data: 53|UnityEngine.SerializeField, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: 54|Varneon.VInspector.FieldParentElementAttribute, Varneon.V-Inspector.Runtime + - Name: ParentName + Entry: 1 + Data: Foldout_Advanced + - Name: + Entry: 8 + Data: + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: logWindow + - Name: $v + Entry: 7 + Data: 55|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: logWindow - Name: k__BackingField Entry: 7 - Data: 52|System.RuntimeType, mscorlib + Data: 56|System.RuntimeType, mscorlib - Name: Entry: 1 Data: UnityEngine.RectTransform, UnityEngine.CoreModule @@ -747,7 +810,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 52 + Data: 56 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -762,13 +825,13 @@ MonoBehaviour: Data: true - Name: _fieldAttributes Entry: 7 - Data: 53|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + Data: 57|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 4 - Name: Entry: 7 - Data: 54|UnityEngine.SpaceAttribute, UnityEngine.CoreModule + Data: 58|UnityEngine.SpaceAttribute, UnityEngine.CoreModule - Name: height Entry: 4 Data: 8 @@ -777,7 +840,7 @@ MonoBehaviour: Data: - Name: Entry: 7 - Data: 55|UnityEngine.HeaderAttribute, UnityEngine.CoreModule + Data: 59|UnityEngine.HeaderAttribute, UnityEngine.CoreModule - Name: header Entry: 1 Data: References @@ -786,13 +849,13 @@ MonoBehaviour: Data: - Name: Entry: 7 - Data: 56|UnityEngine.SerializeField, UnityEngine.CoreModule + Data: 60|UnityEngine.SerializeField, UnityEngine.CoreModule - Name: Entry: 8 Data: - Name: Entry: 7 - Data: 57|Varneon.VInspector.FieldParentElementAttribute, Varneon.V-Inspector.Runtime + Data: 61|Varneon.VInspector.FieldParentElementAttribute, Varneon.V-Inspector.Runtime - Name: ParentName Entry: 1 Data: Foldout_References @@ -819,13 +882,13 @@ MonoBehaviour: Data: logItem - Name: $v Entry: 7 - Data: 58|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 62|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: logItem - Name: k__BackingField Entry: 7 - Data: 59|System.RuntimeType, mscorlib + Data: 63|System.RuntimeType, mscorlib - Name: Entry: 1 Data: UnityEngine.GameObject, UnityEngine.CoreModule @@ -834,7 +897,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 59 + Data: 63 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -849,19 +912,19 @@ MonoBehaviour: Data: true - Name: _fieldAttributes Entry: 7 - Data: 60|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + Data: 64|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 2 - Name: Entry: 7 - Data: 61|UnityEngine.SerializeField, UnityEngine.CoreModule + Data: 65|UnityEngine.SerializeField, UnityEngine.CoreModule - Name: Entry: 8 Data: - Name: Entry: 7 - Data: 62|Varneon.VInspector.FieldParentElementAttribute, Varneon.V-Inspector.Runtime + Data: 66|Varneon.VInspector.FieldParentElementAttribute, Varneon.V-Inspector.Runtime - Name: ParentName Entry: 1 Data: Foldout_References @@ -888,13 +951,13 @@ MonoBehaviour: Data: logToggle - Name: $v Entry: 7 - Data: 63|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 67|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: logToggle - Name: k__BackingField Entry: 7 - Data: 64|System.RuntimeType, mscorlib + Data: 68|System.RuntimeType, mscorlib - Name: Entry: 1 Data: UnityEngine.UI.Toggle, UnityEngine.UI @@ -903,7 +966,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 64 + Data: 68 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -918,19 +981,19 @@ MonoBehaviour: Data: true - Name: _fieldAttributes Entry: 7 - Data: 65|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + Data: 69|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 2 - Name: Entry: 7 - Data: 66|UnityEngine.SerializeField, UnityEngine.CoreModule + Data: 70|UnityEngine.SerializeField, UnityEngine.CoreModule - Name: Entry: 8 Data: - Name: Entry: 7 - Data: 67|Varneon.VInspector.FieldParentElementAttribute, Varneon.V-Inspector.Runtime + Data: 71|Varneon.VInspector.FieldParentElementAttribute, Varneon.V-Inspector.Runtime - Name: ParentName Entry: 1 Data: Foldout_References @@ -957,16 +1020,16 @@ MonoBehaviour: Data: warningToggle - Name: $v Entry: 7 - Data: 68|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 72|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: warningToggle - Name: k__BackingField Entry: 9 - Data: 64 + Data: 68 - Name: k__BackingField Entry: 9 - Data: 64 + Data: 68 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -981,19 +1044,19 @@ MonoBehaviour: Data: true - Name: _fieldAttributes Entry: 7 - Data: 69|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + Data: 73|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 2 - Name: Entry: 7 - Data: 70|UnityEngine.SerializeField, UnityEngine.CoreModule + Data: 74|UnityEngine.SerializeField, UnityEngine.CoreModule - Name: Entry: 8 Data: - Name: Entry: 7 - Data: 71|Varneon.VInspector.FieldParentElementAttribute, Varneon.V-Inspector.Runtime + Data: 75|Varneon.VInspector.FieldParentElementAttribute, Varneon.V-Inspector.Runtime - Name: ParentName Entry: 1 Data: Foldout_References @@ -1020,16 +1083,16 @@ MonoBehaviour: Data: errorToggle - Name: $v Entry: 7 - Data: 72|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 76|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: errorToggle - Name: k__BackingField Entry: 9 - Data: 64 + Data: 68 - Name: k__BackingField Entry: 9 - Data: 64 + Data: 68 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -1044,19 +1107,19 @@ MonoBehaviour: Data: true - Name: _fieldAttributes Entry: 7 - Data: 73|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + Data: 77|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 2 - Name: Entry: 7 - Data: 74|UnityEngine.SerializeField, UnityEngine.CoreModule + Data: 78|UnityEngine.SerializeField, UnityEngine.CoreModule - Name: Entry: 8 Data: - Name: Entry: 7 - Data: 75|Varneon.VInspector.FieldParentElementAttribute, Varneon.V-Inspector.Runtime + Data: 79|Varneon.VInspector.FieldParentElementAttribute, Varneon.V-Inspector.Runtime - Name: ParentName Entry: 1 Data: Foldout_References @@ -1083,16 +1146,16 @@ MonoBehaviour: Data: timestampsToggle - Name: $v Entry: 7 - Data: 76|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 80|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: timestampsToggle - Name: k__BackingField Entry: 9 - Data: 64 + Data: 68 - Name: k__BackingField Entry: 9 - Data: 64 + Data: 68 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -1107,19 +1170,19 @@ MonoBehaviour: Data: true - Name: _fieldAttributes Entry: 7 - Data: 77|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + Data: 81|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 2 - Name: Entry: 7 - Data: 78|UnityEngine.SerializeField, UnityEngine.CoreModule + Data: 82|UnityEngine.SerializeField, UnityEngine.CoreModule - Name: Entry: 8 Data: - Name: Entry: 7 - Data: 79|Varneon.VInspector.FieldParentElementAttribute, Varneon.V-Inspector.Runtime + Data: 83|Varneon.VInspector.FieldParentElementAttribute, Varneon.V-Inspector.Runtime - Name: ParentName Entry: 1 Data: Foldout_References @@ -1146,13 +1209,13 @@ MonoBehaviour: Data: maxLogEntriesField - Name: $v Entry: 7 - Data: 80|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 84|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: maxLogEntriesField - Name: k__BackingField Entry: 7 - Data: 81|System.RuntimeType, mscorlib + Data: 85|System.RuntimeType, mscorlib - Name: Entry: 1 Data: UnityEngine.UI.InputField, UnityEngine.UI @@ -1161,7 +1224,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 81 + Data: 85 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -1176,19 +1239,19 @@ MonoBehaviour: Data: true - Name: _fieldAttributes Entry: 7 - Data: 82|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + Data: 86|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 2 - Name: Entry: 7 - Data: 83|UnityEngine.SerializeField, UnityEngine.CoreModule + Data: 87|UnityEngine.SerializeField, UnityEngine.CoreModule - Name: Entry: 8 Data: - Name: Entry: 7 - Data: 84|Varneon.VInspector.FieldParentElementAttribute, Varneon.V-Inspector.Runtime + Data: 88|Varneon.VInspector.FieldParentElementAttribute, Varneon.V-Inspector.Runtime - Name: ParentName Entry: 1 Data: Foldout_References @@ -1215,16 +1278,16 @@ MonoBehaviour: Data: fontSizeField - Name: $v Entry: 7 - Data: 85|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 89|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: fontSizeField - Name: k__BackingField Entry: 9 - Data: 81 + Data: 85 - Name: k__BackingField Entry: 9 - Data: 81 + Data: 85 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -1239,19 +1302,19 @@ MonoBehaviour: Data: true - Name: _fieldAttributes Entry: 7 - Data: 86|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + Data: 90|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 2 - Name: Entry: 7 - Data: 87|UnityEngine.SerializeField, UnityEngine.CoreModule + Data: 91|UnityEngine.SerializeField, UnityEngine.CoreModule - Name: Entry: 8 Data: - Name: Entry: 7 - Data: 88|Varneon.VInspector.FieldParentElementAttribute, Varneon.V-Inspector.Runtime + Data: 92|Varneon.VInspector.FieldParentElementAttribute, Varneon.V-Inspector.Runtime - Name: ParentName Entry: 1 Data: Foldout_References @@ -1278,13 +1341,13 @@ MonoBehaviour: Data: scrollbar - Name: $v Entry: 7 - Data: 89|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 93|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: scrollbar - Name: k__BackingField Entry: 7 - Data: 90|System.RuntimeType, mscorlib + Data: 94|System.RuntimeType, mscorlib - Name: Entry: 1 Data: UnityEngine.UI.Scrollbar, UnityEngine.UI @@ -1293,7 +1356,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 90 + Data: 94 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -1308,7 +1371,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 91|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + Data: 95|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 0 @@ -1332,16 +1395,16 @@ MonoBehaviour: Data: canvasRoot - Name: $v Entry: 7 - Data: 92|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 96|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: canvasRoot - Name: k__BackingField Entry: 9 - Data: 52 + Data: 56 - Name: k__BackingField Entry: 9 - Data: 52 + Data: 56 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -1356,7 +1419,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 93|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + Data: 97|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 0 diff --git a/Packages/com.varneon.vudon.logger/Runtime/Udon Programs/UdonConsole.cs b/Packages/com.varneon.vudon.logger/Runtime/Udon Programs/UdonConsole.cs index f4b9967..21a0544 100644 --- a/Packages/com.varneon.vudon.logger/Runtime/Udon Programs/UdonConsole.cs +++ b/Packages/com.varneon.vudon.logger/Runtime/Udon Programs/UdonConsole.cs @@ -70,6 +70,10 @@ public class UdonConsole : UdonLogger [Space] [Header("Advanced")] + [SerializeField] + [FieldParentElement("Foldout_Advanced")] + private string timestampFormat = "yyyy.MM.dd HH:mm:ss"; + [SerializeField] [FieldParentElement("Foldout_Advanced")] private string systemPrefix = "[UdonConsole]:"; @@ -154,11 +158,11 @@ private void ReloadLogs() { GameObject item = logWindow.GetChild(i).gameObject; - string[] info = item.name.Split(' '); + string[] info = item.name.Split(new char[] { ' ' }, 2); LogType type = (LogType)int.Parse(info[0]); - string timestamp = string.Join(WHITESPACE, new string[] { info[1], info[2] }); + string timestamp = info[1]; Text text = item.GetComponent(); @@ -188,12 +192,12 @@ private void SetLogEntryActive(GameObject logEntry, LogType type) } /// - /// Gets the current timestamp formatted as "yyyy.MM.dd HH:mm:ss" + /// Gets the current timestamp formatted as defined by timestampFormat /// /// Formatted timestamp string private string GetTimestamp() { - return DateTime.UtcNow.ToLocalTime().ToString("yyyy.MM.dd HH:mm:ss"); + return DateTime.UtcNow.ToLocalTime().ToString(timestampFormat); } /// From b42ed75fe971bd59baec08413e76b09204b0e6f9 Mon Sep 17 00:00:00 2001 From: Varneon Date: Mon, 3 Apr 2023 23:28:27 -0700 Subject: [PATCH 2/2] Add code documentation for timestamp format field --- .../Runtime/Udon Programs/UdonConsole.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Packages/com.varneon.vudon.logger/Runtime/Udon Programs/UdonConsole.cs b/Packages/com.varneon.vudon.logger/Runtime/Udon Programs/UdonConsole.cs index 21a0544..9ddfab9 100644 --- a/Packages/com.varneon.vudon.logger/Runtime/Udon Programs/UdonConsole.cs +++ b/Packages/com.varneon.vudon.logger/Runtime/Udon Programs/UdonConsole.cs @@ -68,6 +68,10 @@ public class UdonConsole : UdonLogger [FieldParentElement("Foldout_Settings")] private bool proxyEntriesToLogs; + /// + /// Format of the timestamp + /// + /// [Space] [Header("Advanced")] [SerializeField]