Skip to content

Commit 99a5b17

Browse files
committed
refactor: replace Debug.Console calls with appropriate logging methods for improved clarity
1 parent 017dc60 commit 99a5b17

3 files changed

Lines changed: 56 additions & 56 deletions

File tree

src/CustomValuesController.cs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public CustomValuesController(DeviceConfig config)
5858
{
5959
if (string.IsNullOrEmpty(_props.FilePath))
6060
{
61-
Debug.Console(0, this, "File path not specified... saving values locally");
61+
Debug.LogInformation(this, "File path not specified... saving values locally");
6262
return;
6363
}
6464

@@ -73,7 +73,7 @@ public CustomValuesController(DeviceConfig config)
7373
}
7474
catch (Exception ex)
7575
{
76-
Debug.Console(0, this, Debug.ErrorLogLevel.Warning, "Failed to save custom values data: '{0}'", ex);
76+
Debug.LogWarning(this, "Failed to save custom values data: '{0}'", ex);
7777
}
7878
}),
7979
Timeout.Infinite);
@@ -86,12 +86,12 @@ public CustomValuesController(DeviceConfig config)
8686

8787
if (data == null)
8888
{
89-
Debug.Console(0, this, "No data found in the config or file, using an empty JObject.");
89+
Debug.LogInformation(this, "No data found in the config or file, using an empty JObject.");
9090
data = new JObject();
9191
}
9292
else
9393
{
94-
Debug.Console(1, this, "Loaded data from file: {0}", _props.FilePath);
94+
Debug.LogDebug(this, "Loaded data from file: {0}", _props.FilePath);
9595
}
9696

9797
// Initialize control feedback objects early
@@ -121,15 +121,15 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E
121121

122122
if (customJoins == null)
123123
{
124-
Debug.Console(0, this, "Custom Joins not found!!!");
124+
Debug.LogInformation(this, "Custom Joins not found!!!");
125125
return;
126126
}
127127

128128
if (customJoins != null)
129129
{ joinMap.SetCustomJoinData(customJoins); }
130130

131-
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
132-
Debug.Console(1, this, "Linking to Bridge Type {0}", GetType().Name);
131+
Debug.LogDebug(this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
132+
Debug.LogDebug(this, "Linking to Bridge Type {0}", GetType().Name);
133133

134134
// Link control outputs (BoolFeedback -> BooleanInput drives outward state in Essentials)
135135
// Prefer using the constant so if join map custom data not found we still know intended default
@@ -150,7 +150,7 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E
150150
{
151151
if (_enableSaving == state) return; // no change
152152
_enableSaving = state;
153-
Debug.Console(1, this, "EnableSaving changed -> {0}", _enableSaving);
153+
Debug.LogDebug(this, "EnableSaving changed -> {0}", _enableSaving);
154154
if (_enableSaving)
155155
{
156156
_savingReady = _pluginReady && _enableSaving;
@@ -178,19 +178,19 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E
178178

179179
if (index == 0)
180180
{
181-
Debug.Console(0, this, "Cannot map path: '{0}', missing join number", path);
181+
Debug.LogInformation(this, "Cannot map path: '{0}', missing join number", path);
182182
continue;
183183
}
184184

185-
Debug.Console(1, this, "Attempting to map path: '{1}' to join: '{0}'", join, path);
185+
Debug.LogDebug(this, "Attempting to map path: '{1}' to join: '{0}'", join, path);
186186
var value = data.SelectToken(path);
187187
if (value == null)
188188
{
189-
Debug.Console(0, this, "No value found for path: '{0}' in '{1}', ignoring path, update customValues if needed.", path, _props.FilePath);
189+
Debug.LogInformation(this, "No value found for path: '{0}' in '{1}', ignoring path, update customValues if needed.", path, _props.FilePath);
190190
continue;
191191
}
192192

193-
Debug.Console(1, this, "Mapping path: '{1}' to join: '{0}' as type: '{2}' with value: '{3}'",
193+
Debug.LogDebug(this, "Mapping path: '{1}' to join: '{0}' as type: '{2}' with value: '{3}'",
194194
join, path, value.Type.ToString(), value);
195195

196196
switch (value.Type)
@@ -213,7 +213,7 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E
213213
feedback.FireUpdate();
214214
feedback.OutputChange +=
215215
(sender, args) =>
216-
Debug.Console(1, this, "Value for path:{0} updated to {1}", path, args.IntValue);
216+
Debug.LogDebug(this, "Value for path:{0} updated to {1}", path, args.IntValue);
217217

218218
break;
219219
}
@@ -235,7 +235,7 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E
235235
feedback.FireUpdate();
236236
feedback.OutputChange +=
237237
(sender, args) =>
238-
Debug.Console(1, this, "Value for path:{0} updated to {1}", path, args.StringValue);
238+
Debug.LogDebug(this, "Value for path:{0} updated to {1}", path, args.StringValue);
239239

240240
break;
241241
}
@@ -257,7 +257,7 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E
257257
feedback.FireUpdate();
258258
feedback.OutputChange +=
259259
(sender, args) =>
260-
Debug.Console(1, this, "Value for path:{0} updated to {1}", path, args.StringValue);
260+
Debug.LogDebug(this, "Value for path:{0} updated to {1}", path, args.StringValue);
261261

262262
break;
263263
}
@@ -285,13 +285,13 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E
285285
feedback.FireUpdate();
286286
feedback.OutputChange +=
287287
(sender, args) =>
288-
Debug.Console(1, this, "Value for path:{0} updated to {1}", path, args.BoolValue);
288+
Debug.LogDebug(this, "Value for path:{0} updated to {1}", path, args.BoolValue);
289289

290290
break;
291291
}
292292
default:
293293
{
294-
Debug.Console(0, this, "Cannot map path: '{0}', unsupported type: {1}", path, value.Type);
294+
Debug.LogInformation(this, "Cannot map path: '{0}', unsupported type: {1}", path, value.Type);
295295
continue;
296296
}
297297
}
@@ -300,7 +300,7 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E
300300
_pluginReady = true;
301301
_savingReady = _pluginReady && _enableSaving;
302302
_savingReadyFeedback.FireUpdate();
303-
Debug.Console(1, this, "Finished mapping joins. SavingReady: {0}", _savingReady);
303+
Debug.LogDebug(this, "Finished mapping joins. SavingReady: {0}", _savingReady);
304304
}
305305

306306
/// <summary>
@@ -322,7 +322,7 @@ private void WithLock(Action a)
322322
}
323323
catch (Exception ex)
324324
{
325-
Debug.Console(0, Debug.ErrorLogLevel.Warning, "Caught an exception within the lock:{0}", ex);
325+
Debug.LogWarning(this, "Caught an exception within the lock:{0}", ex);
326326
throw;
327327
}
328328
finally
@@ -341,7 +341,7 @@ private void WithLock(Action a)
341341
private static JObject SeedData(string fileName, JObject seed)
342342
{
343343
var filePath = Path.Combine(Global.FilePathPrefix, fileName);
344-
Debug.Console(0, "Attemping to find a file at path:{0}", filePath);
344+
Debug.LogInformation("CustomValues", "Attemping to find a file at path:{0}", filePath);
345345

346346
if (File.Exists(filePath))
347347
{
@@ -353,7 +353,7 @@ private static JObject SeedData(string fileName, JObject seed)
353353
}
354354
}
355355

356-
Debug.Console(0, "Didn't find a file at path:{0}, creating...", filePath);
356+
Debug.LogInformation("CustomValues", "Didn't find a file at path:{0}, creating...", filePath);
357357
var dataToSeed = seed ?? new JObject();
358358
using (var fs = File.Create(filePath))
359359
using (var stream = new StreamWriter(fs))
@@ -380,7 +380,7 @@ private static void SaveData(string fileName, JToken data)
380380
var filePath = Path.Combine(Global.FilePathPrefix, fileName);
381381
var tempPath = filePath + ".tmp";
382382

383-
Debug.Console(0, "Attempting to write a file at path:{0}", filePath);
383+
Debug.LogInformation("CustomValues", "Attempting to write a file at path:{0}", filePath);
384384

385385
// Write to temp file first to avoid partial/corrupt writes
386386
using (var fs = File.Create(tempPath)) // FileMode.Create -> truncates or creates new
@@ -403,7 +403,7 @@ private static void SaveData(string fileName, JToken data)
403403
}
404404
catch (Exception ex)
405405
{
406-
Debug.Console(0, Debug.ErrorLogLevel.Warning, "Failed replacing original file with temp: {0}", ex);
406+
Debug.LogWarning("CustomValues", "Failed replacing original file with temp: {0}", ex);
407407
// Fallback: attempt direct write (truncating) if temp replace failed
408408
using (var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None))
409409
using (var stream = new StreamWriter(fs))

0 commit comments

Comments
 (0)