Skip to content

Commit c10fe54

Browse files
committed
Add verbose debug logging
1 parent feedf8e commit c10fe54

File tree

12 files changed

+767
-52
lines changed

12 files changed

+767
-52
lines changed

Assets/UnityEventTimeline/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to UnityEventTimeline will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.0.5] - 2024-12-23
9+
10+
Verbose debug logging implementation.
11+
12+
### Added
13+
- Verbose debug logging capabilities (`EVENTTIMELINE_DEBUG_VERBOSE`)
14+
815
## [1.0.0] - 2024-12-21
916

1017
Initial release of the UnityEventTimeline package.
@@ -24,3 +31,4 @@ Initial release of the UnityEventTimeline package.
2431
- Debug logging capabilities (`EVENTTIMELINE_DEBUG`)
2532

2633
[1.0.0]: https://github.com/ahmedkamalio/UnityEventTimeline/releases/tag/v1.0.0
34+
[1.0.5]: https://github.com/ahmedkamalio/UnityEventTimeline/releases/tag/v1.0.5

Assets/UnityEventTimeline/Documentation~/UnityEventTimeline.md

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,77 @@ EventTimeline.Instance.SetMaxProcessingTime(8.0f); // milliseconds
203203

204204
## Debug Support
205205

206-
Enable debug logging by defining the EVENTTIMELINE_DEBUG symbol in your development builds:
206+
The event timeline system provides two levels of debug logging that can be enabled via compiler symbols:
207+
208+
### Basic Debug Logging
209+
210+
Basic debug logging includes warnings and errors, enabled by defining the `EVENTTIMELINE_DEBUG` symbol. The logging will
211+
be active in the Unity Editor or development builds when this symbol is defined:
207212

208213
```csharp
209214
#if (DEVELOPMENT_BUILD || UNITY_EDITOR) && EVENTTIMELINE_DEBUG
210-
// Debug logging will be active
215+
// Basic debug logging is enabled in this condition.
211216
#endif
212217
```
213218

219+
### Verbose Debug Logging
220+
221+
Verbose logging includes detailed operational information and requires both `EVENTTIMELINE_DEBUG` and
222+
`EVENTTIMELINE_DEBUG_VERBOSE` symbols to be defined:
223+
224+
```csharp
225+
#if EVENTTIMELINE_DEBUG && EVENTTIMELINE_DEBUG_VERBOSE
226+
// Verbose debug logging is enabled in this condition.
227+
#endif
228+
```
229+
230+
### Configuring Debug Symbols
231+
232+
There are two ways to define these debug symbols:
233+
234+
1. Via Unity's Player Settings:
235+
- Open Project Settings -> Player
236+
- Under "Other Settings" -> "Script Compilation"
237+
- Add to "Scripting Define Symbols":
238+
```
239+
EVENTTIMELINE_DEBUG
240+
EVENTTIMELINE_DEBUG_VERBOSE
241+
```
242+
243+
2. Via compilation arguments in your build configuration:
244+
```
245+
-define:EVENTTIMELINE_DEBUG
246+
-define:EVENTTIMELINE_DEBUG_VERBOSE
247+
```
248+
249+
### Debug Output Examples
250+
251+
Basic debug logging (`EVENTTIMELINE_DEBUG`) includes:
252+
253+
- Warnings about invalid operations
254+
- Error conditions
255+
- Important state changes
256+
257+
Verbose logging (`EVENTTIMELINE_DEBUG_VERBOSE`) additionally includes:
258+
259+
- Detailed execution timing
260+
- Event processing steps
261+
- Pool operations
262+
- Queue state changes
263+
- Memory optimization details
264+
265+
For example, event execution with verbose logging enabled:
266+
267+
```
268+
[TimelineEvent] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
269+
[TimelineEvent] Beginning internal execution of event: CustomEvent
270+
[TimelineEvent] Successfully executed event: CustomEvent
271+
[TimelineEvent] Execution time: 1ms
272+
[TimelineEvent] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
273+
```
274+
275+
Note: Debug logging is automatically disabled in release builds unless explicitly enabled through compilation symbols.
276+
214277
## Example Scenarios
215278
216279
### Quest System

Assets/UnityEventTimeline/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Ahmed Kamal
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Assets/UnityEventTimeline/LICENSE.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/UnityEventTimeline/Runtime/EventTimeline.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#define __EVENTTIMELINE_DEBUG
55
#endif
66

7+
#if __EVENTTIMELINE_DEBUG && EVENTTIMELINE_DEBUG_VERBOSE
8+
#define __EVENTTIMELINE_DEBUG_VERBOSE
9+
#endif
10+
711
using UnityEngine;
812
using UnityEngine.SceneManagement;
913
using UnityEventTimeline.Internal;
@@ -52,11 +56,17 @@ public static EventTimeline Instance
5256
{
5357
if (_instance is not null)
5458
{
59+
#if __EVENTTIMELINE_DEBUG_VERBOSE
60+
Debug.Log("[EventTimeline] Returning existing instance");
61+
#endif
5562
return _instance;
5663
}
5764

5865
lock (SingletonLock)
5966
{
67+
#if __EVENTTIMELINE_DEBUG_VERBOSE
68+
Debug.Log("[EventTimeline] Creating new instance");
69+
#endif
6070
var go = new GameObject(nameof(EventTimeline));
6171
_instance = go.AddComponent<EventTimeline>();
6272
DontDestroyOnLoad(go);
@@ -95,13 +105,22 @@ protected override void Awake()
95105
{
96106
if (_instance is not null && _instance != this)
97107
{
108+
#if __EVENTTIMELINE_DEBUG
109+
Debug.LogWarning("[EventTimeline] Duplicate instance detected, destroying GameObject");
110+
#endif
111+
98112
Destroy(gameObject);
113+
99114
return;
100115
}
101116

102117
_instance = this;
103118

104119
DontDestroyOnLoad(gameObject);
120+
121+
#if __EVENTTIMELINE_DEBUG_VERBOSE
122+
Debug.Log("[EventTimeline] Instance initialized in Awake");
123+
#endif
105124
}
106125
}
107126

@@ -142,6 +161,9 @@ protected override void OnDestroy()
142161
{
143162
if (_instance == this)
144163
{
164+
#if __EVENTTIMELINE_DEBUG_VERBOSE
165+
Debug.Log("[EventTimeline] Clearing singleton instance");
166+
#endif
145167
_instance = null;
146168
}
147169
}
@@ -156,7 +178,15 @@ protected override void OnDestroy()
156178
/// </remarks>
157179
private void HandleSceneUnloaded(Scene scene)
158180
{
181+
#if __EVENTTIMELINE_DEBUG_VERBOSE
182+
Debug.Log($"[EventTimeline] Scene unloaded: {scene.name}");
183+
#endif
184+
159185
OptimizeMemory();
186+
187+
#if __EVENTTIMELINE_DEBUG_VERBOSE
188+
Debug.Log("[EventTimeline] Memory optimization completed after scene unload");
189+
#endif
160190
}
161191
}
162192
}

0 commit comments

Comments
 (0)