Skip to content

Commit c535d74

Browse files
committed
Simplified diagnostics class
1 parent c925bcd commit c535d74

File tree

6 files changed

+102
-460
lines changed

6 files changed

+102
-460
lines changed

Runtime/Scripts/BetaHubDiagnostics.cs

Lines changed: 6 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -11,184 +11,68 @@ public interface IContextualDiagnostics
1111
/// <summary>
1212
/// Logs an informational message for an operation.
1313
/// </summary>
14-
/// <param name="operation">The operation name</param>
15-
/// <param name="message">The message to log</param>
1614
void LogInfo(string operation, string message);
1715

1816
/// <summary>
1917
/// Logs a successful operation completion.
2018
/// </summary>
21-
/// <param name="operation">The operation name</param>
22-
/// <param name="message">The success message</param>
2319
void LogSuccess(string operation, string message);
2420

2521
/// <summary>
2622
/// Logs progress information for a long-running operation.
2723
/// </summary>
28-
/// <param name="operation">The operation name</param>
29-
/// <param name="message">The progress message</param>
3024
void LogProgress(string operation, string message);
3125

3226
/// <summary>
33-
/// Logs an error with automatic exception categorization and retry analysis.
27+
/// Logs an error with a custom message and exception details.
3428
/// </summary>
35-
/// <param name="operation">The operation name</param>
36-
/// <param name="ex">The exception that occurred</param>
37-
void LogError(string operation, Exception ex);
38-
39-
/// <summary>
40-
/// Logs an error with explicit categorization and retry information.
41-
/// </summary>
42-
/// <param name="operation">The operation name</param>
43-
/// <param name="message">The error message</param>
44-
/// <param name="category">The error category</param>
45-
/// <param name="isRetryable">Whether the error is retryable</param>
46-
void LogError(string operation, string message, BetaHubErrorCategory category = BetaHubErrorCategory.Unknown, bool isRetryable = false);
29+
void LogError(string operation, string message, Exception ex);
4730
}
4831

4932
/// <summary>
50-
/// Main entry point for BetaHub diagnostics. Provides contextual diagnostics services
51-
/// for consistent error handling and logging across the plugin.
33+
/// Main entry point for BetaHub diagnostics.
5234
/// </summary>
5335
public static class BetaHubDiagnostics
5436
{
5537
/// <summary>
5638
/// Creates a contextual diagnostics service for a specific component or operation context.
5739
/// </summary>
58-
/// <param name="contextName">The name of the context (e.g., "Issue(abc123)", "GameRecorder", etc.)</param>
59-
/// <returns>A contextual diagnostics service instance</returns>
6040
public static IContextualDiagnostics ForContext(string contextName)
6141
{
6242
return new ContextualDiagnostics(contextName);
6343
}
6444
}
6545

6646
/// <summary>
67-
/// Implementation of contextual diagnostics that provides consistent logging and error handling
68-
/// for a specific context (component, operation, or scope).
47+
/// Implementation of contextual diagnostics that provides consistent logging.
6948
/// </summary>
7049
internal class ContextualDiagnostics : IContextualDiagnostics
7150
{
7251
private readonly string _contextName;
7352

74-
/// <summary>
75-
/// Initializes a new instance of contextual diagnostics for the specified context.
76-
/// </summary>
77-
/// <param name="contextName">The context name to include in all log messages</param>
7853
public ContextualDiagnostics(string contextName)
7954
{
8055
_contextName = contextName ?? throw new ArgumentNullException(nameof(contextName));
8156
}
8257

83-
/// <summary>
84-
/// Logs an informational message for an operation.
85-
/// </summary>
86-
/// <param name="operation">The operation name</param>
87-
/// <param name="message">The message to log</param>
8858
public void LogInfo(string operation, string message)
8959
{
9060
Debug.Log($"[INFO] {_contextName}.{operation}: {message}");
9161
}
9262

93-
/// <summary>
94-
/// Logs a successful operation completion.
95-
/// </summary>
96-
/// <param name="operation">The operation name</param>
97-
/// <param name="message">The success message</param>
9863
public void LogSuccess(string operation, string message)
9964
{
10065
Debug.Log($"[SUCCESS] {_contextName}.{operation}: {message}");
10166
}
10267

103-
/// <summary>
104-
/// Logs progress information for a long-running operation.
105-
/// </summary>
106-
/// <param name="operation">The operation name</param>
107-
/// <param name="message">The progress message</param>
10868
public void LogProgress(string operation, string message)
10969
{
11070
Debug.Log($"[PROGRESS] {_contextName}.{operation}: {message}");
11171
}
11272

113-
/// <summary>
114-
/// Logs an error with automatic exception categorization and retry analysis.
115-
/// </summary>
116-
/// <param name="operation">The operation name</param>
117-
/// <param name="ex">The exception that occurred</param>
118-
public void LogError(string operation, Exception ex)
119-
{
120-
var category = BetaHubErrorHelper.CategorizeException(ex);
121-
var isRetryable = BetaHubErrorHelper.IsRetryable(ex);
122-
LogError(operation, ex.Message, category, isRetryable);
123-
}
124-
125-
/// <summary>
126-
/// Logs an error with explicit categorization and retry information.
127-
/// </summary>
128-
/// <param name="operation">The operation name</param>
129-
/// <param name="message">The error message</param>
130-
/// <param name="category">The error category</param>
131-
/// <param name="isRetryable">Whether the error is retryable</param>
132-
public void LogError(string operation, string message, BetaHubErrorCategory category = BetaHubErrorCategory.Unknown, bool isRetryable = false)
73+
public void LogError(string operation, string message, Exception ex)
13374
{
134-
string retryInfo = isRetryable ? " (Retryable)" : " (Not retryable)";
135-
Debug.LogError($"[ERROR] {_contextName}.{operation} [{category}]: {message}{retryInfo}");
75+
Debug.LogError($"[ERROR] {_contextName}.{operation}: {message} - {ex.Message}");
13676
}
13777
}
138-
139-
/// <summary>
140-
/// Configuration class for BetaHub diagnostics behavior.
141-
/// Allows customization of logging levels and formatting.
142-
/// </summary>
143-
public static class BetaHubDiagnosticsConfig
144-
{
145-
/// <summary>
146-
/// Gets or sets whether to include timestamps in log messages.
147-
/// Default: false (Unity Console already includes timestamps)
148-
/// </summary>
149-
public static bool IncludeTimestamps { get; set; } = false;
150-
151-
/// <summary>
152-
/// Gets or sets whether to include stack traces in error logs.
153-
/// Default: false (Unity Console shows stack traces separately)
154-
/// </summary>
155-
public static bool IncludeStackTraces { get; set; } = false;
156-
157-
/// <summary>
158-
/// Gets or sets the minimum log level to output.
159-
/// Can be used to reduce log verbosity in production builds.
160-
/// </summary>
161-
public static BetaHubLogLevel MinimumLogLevel { get; set; } = BetaHubLogLevel.Info;
162-
}
163-
164-
/// <summary>
165-
/// Log levels for BetaHub diagnostics.
166-
/// </summary>
167-
public enum BetaHubLogLevel
168-
{
169-
/// <summary>
170-
/// Progress and detailed information
171-
/// </summary>
172-
Progress = 0,
173-
174-
/// <summary>
175-
/// General information
176-
/// </summary>
177-
Info = 1,
178-
179-
/// <summary>
180-
/// Success notifications
181-
/// </summary>
182-
Success = 2,
183-
184-
/// <summary>
185-
/// Error messages only
186-
/// </summary>
187-
Error = 3,
188-
189-
/// <summary>
190-
/// No logging
191-
/// </summary>
192-
None = 4
193-
}
19478
}

Runtime/Scripts/BetaHubErrorCategory.cs

Lines changed: 0 additions & 150 deletions
This file was deleted.

Runtime/Scripts/BetaHubErrorCategory.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)