Skip to content

Commit fc506f7

Browse files
committed
use KSPBT's logging library
1 parent 24c3836 commit fc506f7

File tree

12 files changed

+44
-39
lines changed

12 files changed

+44
-39
lines changed

SCANsat/SCAN_Data/SCANdata.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using SCANsat.SCAN_Palettes;
2727
using SCANsat.SCAN_Unity;
2828
using palette = SCANsat.SCAN_UI.UI_Framework.SCANcolorUtil;
29+
using Log = KSPBuildTools.Log;
2930

3031
namespace SCANsat.SCAN_Data
3132
{
@@ -861,7 +862,7 @@ internal void generateHeightMap(ref int step, ref int xStart, int width)
861862
}
862863
catch (Exception e)
863864
{
864-
Debug.LogError("[SCANsat] Error In Detecting Terrain Height Map; Stopping Height Map Generator\n" + e);
865+
Log.Error("Error In Detecting Terrain Height Map; Stopping Height Map Generator\n" + e);
865866
built = true;
866867
mapBuilding = false;
867868
overlayBuilding = false;

SCANsat/SCAN_Data/SCANresourceGlobal.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using UnityEngine;
1818

1919
using SCANsat.SCAN_Platform;
20+
using Log = KSPBuildTools.Log;
2021

2122
namespace SCANsat.SCAN_Data
2223
{
@@ -166,7 +167,7 @@ public void addToBodyConfigs(string s, SCANresourceBody r, bool warn)
166167
}
167168
else if (warn)
168169
{
169-
Debug.LogError(string.Format("[SCANsat] Warning: SCANresource Dictionary Already Contains Key Of This Type: [{0}] For Body: [{1}]", r.ResourceName, s));
170+
Log.Error(string.Format("Warning: SCANresource Dictionary Already Contains Key Of This Type: [{0}] For Body: [{1}]", r.ResourceName, s));
170171
}
171172
}
172173

SCANsat/SCAN_Map/SCANmap.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using System.IO;
1717
using UnityEngine;
1818
using SCANsat.SCAN_Platform.Palettes;
19-
using SCANsat.SCAN_Platform.Logging;
2019
using SCANsat.SCAN_Data;
2120
using SCANsat.SCAN_UI.UI_Framework;
2221
using palette = SCANsat.SCAN_UI.UI_Framework.SCANcolorUtil;

SCANsat/SCAN_Map/SCANmapExporter.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using UnityEngine;
66
using SCANsat.SCAN_Data;
77
using SCANsat.SCAN_Platform;
8+
using Log = KSPBuildTools.Log;
89

910
namespace SCANsat.SCAN_Map
1011
{
@@ -115,15 +116,15 @@ private IEnumerator exportCSV(string filePath, string fileName, SCANmap map, SCA
115116

116117
if (timer >= 20000)
117118
{
118-
Debug.LogError("[SCANsat] Something went wrong while exporting .csv data file\nCanceling export thread...");
119+
Log.Error("Something went wrong while exporting .csv data file\nCanceling export thread...");
119120
t.Abort();
120121
threadRunning = false;
121122
yield break;
122123
}
123124

124125
if (!threadFinished)
125126
{
126-
Debug.LogError("[SCANsat] Something went wrong while exporting .csv data file\nExport thread has been interrupted...");
127+
Log.Error("Something went wrong while exporting .csv data file\nExport thread has been interrupted...");
127128
yield break;
128129
}
129130
}

SCANsat/SCAN_PartModules/SCANsat.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
using UnityEngine;
2525
using palette = SCANsat.SCAN_UI.UI_Framework.SCANcolorUtil;
26+
using Log = KSPBuildTools.Log;
2627

2728
namespace SCANsat.SCAN_PartModules
2829
{
@@ -100,7 +101,7 @@ public override void OnStart(StartState state)
100101
{
101102
if (state == StartState.Editor)
102103
{
103-
print("[SCANsat] start: in editor");
104+
Log.Message("start: in editor");
104105
Events["editorExtend"].active = !string.IsNullOrEmpty(animationName);
105106
scanInfoAltitude.guiActive = false;
106107
scanInfoStatus.guiActive = false;
@@ -114,19 +115,19 @@ public override void OnStart(StartState state)
114115
scanType = getTypeString();
115116
scanAltitude = getAltString();
116117
scanPower = getECString();
117-
print("[SCANsat] start: live");
118+
Log.Message("start: live");
118119
GameEvents.onVesselSOIChanged.Add(ChangeSOI);
119120
}
120121
if (!string.IsNullOrEmpty(animationName))
121122
{
122123
Animation[] a = part.FindModelAnimators(animationName);
123124
if (a.Length == 0)
124125
{
125-
print("[SCANsat] animation '" + animationName + "' not found");
126+
Log.Message("animation '" + animationName + "' not found");
126127
}
127128
else
128129
{
129-
print("[SCANsat] using animation #1 out of " + a.Length.ToString() + " animations named '" + animationName + "'");
130+
Log.Message("using animation #1 out of " + a.Length.ToString() + " animations named '" + animationName + "'");
130131
anim = a[0];
131132
anim.playAutomatically = false;
132133
anim.cullingType = AnimationCullingType.BasedOnRenderers;
@@ -161,7 +162,7 @@ public override void OnStart(StartState state)
161162
}
162163

163164
powerIsProblem = false;
164-
print("[SCANsat] sensorType: " + sensorType.ToString() + " fov: " + fov.ToString() + " min_alt: " + min_alt.ToString() + " max_alt: " + max_alt.ToString() + " best_alt: " + best_alt.ToString());
165+
Log.Message("sensorType: " + sensorType.ToString() + " fov: " + fov.ToString() + " min_alt: " + min_alt.ToString() + " max_alt: " + max_alt.ToString() + " best_alt: " + best_alt.ToString());
165166
}
166167

167168
private void OnDestroy()

SCANsat/SCAN_Platform/Extensions/ConfigNodes/ConfigExtensions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using UnityEngine;
5+
using Log = KSPBuildTools.Log;
56

67
namespace SCANsat.SCAN_Platform.Extensions.ConfigNodes
78
{
@@ -135,7 +136,7 @@ public static Color parse(this ConfigNode node, string name, Color original)
135136
}
136137
catch (Exception e)
137138
{
138-
Debug.LogError("[SCANsat] Error while reading Color value; using default value...\n" + e);
139+
Log.Error("Error while reading Color value; using default value...\n" + e);
139140
}
140141

141142
return c;
@@ -156,7 +157,7 @@ public static Color32 parse(this ConfigNode node, string name, Color32 original)
156157
}
157158
catch (Exception e)
158159
{
159-
Debug.LogError("[SCANsat] Error while reading Color32 value; using default value...\n" + e);
160+
Log.Error("Error while reading Color32 value; using default value...\n" + e);
160161
}
161162

162163
return c;
@@ -222,7 +223,7 @@ public static Guid parse(this ConfigNode node, string name, Guid original)
222223
}
223224
catch (Exception e)
224225
{
225-
Debug.LogError("[SCANsat] Error while reading Guid value; creating new value...\n" + e);
226+
Log.Error("Error while reading Guid value; creating new value...\n" + e);
226227
}
227228

228229
return g;

SCANsat/SCAN_Platform/Logging.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
using System;
2+
using Log = KSPBuildTools.Log;
3+
4+
5+
// TODO: remove this file and fixup references to call KSPBuildTools.Log directly
26
namespace SCANsat.SCAN_Platform.Logging
37
{
48
public class ConsoleLogger
59
{
6-
7-
internal static string _AssemblyName { get { return System.Reflection.Assembly.GetExecutingAssembly().GetName().Name; } }
8-
internal string _ClassName { get { return this.GetType().Name; } }
9-
1010
[System.Diagnostics.Conditional("DEBUG")]
11-
public static void Debug(string message, params object[] strParams) { Now("DEBUG: " + message, strParams); }
11+
public static void Debug(string message, params object[] strParams)
12+
{
13+
Log.Debug(string.Format(message, strParams));
14+
}
1215

1316
public static void Now(string message, params object[] strParams)
1417
{
15-
message = string.Format(message, strParams); // This fills the params into the message
16-
string strMessageLine = string.Format("[{1}],{0}", message, _AssemblyName); // This adds our standardised wrapper to each line
17-
UnityEngine.Debug.Log(strMessageLine); // And this puts it in the log
18+
Log.Message(string.Format(message, strParams));
1819
}
1920

2021
public static void Main()

SCANsat/SCAN_UI/UI_Framework/SCANicon.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
using UnityEngine;
1919

2020
using palette = SCANsat.SCAN_UI.UI_Framework.SCANcolorUtil;
21-
using Log = SCANsat.SCAN_Platform.Logging.ConsoleLogger;
2221

2322
namespace SCANsat.SCAN_UI.UI_Framework
2423
{

SCANsat/SCAN_Unity/SCAN_UI_Overlay.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using SCANsat.SCAN_UI.UI_Framework;
2727
using KSP.UI;
2828
using palette = SCANsat.SCAN_UI.UI_Framework.SCANcolorUtil;
29+
using Log = KSPBuildTools.Log;
2930

3031
namespace SCANsat.SCAN_Unity
3132
{
@@ -866,15 +867,15 @@ private IEnumerator setOverlayMap()
866867

867868
if (timer >= 1000)
868869
{
869-
Debug.LogError("[SCANsat] Something went wrong when drawing the SCANsat resource map overlay...");
870+
Log.Error("Something went wrong when drawing the SCANsat resource map overlay...");
870871
t.Abort();
871872
threadRunning = false;
872873
yield break;
873874
}
874875

875876
if (!threadFinished)
876877
{
877-
Debug.LogError("[SCANsat] Something went wrong when drawing the SCANsat resource map overlay...");
878+
Log.Error("Something went wrong when drawing the SCANsat resource map overlay...");
878879
yield break;
879880
}
880881

@@ -960,15 +961,15 @@ private IEnumerator setTerrainMap()
960961

961962
if (timer >= 1000)
962963
{
963-
Debug.LogError("[SCANsat] Something went wrong when drawing the SCANsat terrain map overlay...");
964+
Log.Error("Something went wrong when drawing the SCANsat terrain map overlay...");
964965
t.Abort();
965966
threadRunning = false;
966967
yield break;
967968
}
968969

969970
if (!threadFinished)
970971
{
971-
Debug.LogError("[SCANsat] Something went wrong when drawing the SCANsat terrain map overlay...");
972+
Log.Error("Something went wrong when drawing the SCANsat terrain map overlay...");
972973
yield break;
973974
}
974975

SCANsat/SCANcontroller.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
using palette = SCANsat.SCAN_UI.UI_Framework.SCANcolorUtil;
3333
using FinePrint.Contracts.Parameters;
3434
using UnityEngine.Profiling;
35+
using Log = KSPBuildTools.Log;
3536

3637
namespace SCANsat
3738
{
@@ -230,7 +231,7 @@ public void addToBodyData(CelestialBody b, SCANdata data)
230231
}
231232
else
232233
{
233-
UnityEngine.Debug.LogError("[SCANsat] Warning: SCANdata Dictionary Already Contains Key of This Type");
234+
Log.Error("Warning: SCANdata Dictionary Already Contains Key of This Type");
234235
}
235236
}
236237

@@ -364,7 +365,7 @@ public static void addToTerrainConfigData(string name, SCANterrainConfig data)
364365
}
365366
else
366367
{
367-
UnityEngine.Debug.LogError("[SCANsat] Warning: SCANterrain Data Dictionary Already Contains Key Of This Type");
368+
Log.Error("SCANterrain Data Dictionary Already Contains Key Of This Type");
368369
}
369370
}
370371

@@ -494,7 +495,7 @@ public static void addToResourceData(string name, SCANresourceGlobal res)
494495
}
495496
else
496497
{
497-
UnityEngine.Debug.LogError(string.Format("[SCANsat] Warning: SCANResource Dictionary Already Contains Key of This Type: Resource: {0}", name));
498+
Log.Error(string.Format("SCANResource Dictionary Already Contains Key of This Type: Resource: {0}", name));
498499
}
499500
}
500501

@@ -506,7 +507,7 @@ public static void addToLoadedResourceNames(string name, bool warn = true)
506507
}
507508
else if (warn)
508509
{
509-
UnityEngine.Debug.LogError(string.Format("[SCANsat] Warning: Loaded Resource List Already Contains Resource Of Name: {0}", name));
510+
Log.Error(string.Format("Loaded Resource List Already Contains Resource Of Name: {0}", name));
510511
}
511512
}
512513

@@ -659,7 +660,7 @@ public override void OnLoad(ConfigNode node)
659660
}
660661
catch (Exception e)
661662
{
662-
UnityEngine.Debug.LogError(string.Format("[SCANsat] Error in loading Celestial Body [{0}]...\n{1}", body_name, e));
663+
Log.Error(string.Format("Error in loading Celestial Body [{0}]...\n{1}", body_name, e));
663664
continue;
664665
}
665666

@@ -2281,7 +2282,7 @@ private void loadCustomResourceValues(ConfigNode node)
22812282
}
22822283
catch (Exception e)
22832284
{
2284-
UnityEngine.Debug.LogError("[SCANsat] Error in loading Celestial Body...\n" + e);
2285+
Log.Error("Error in loading Celestial Body...\n" + e);
22852286
return;
22862287
}
22872288

@@ -2506,7 +2507,7 @@ private void finishRegistration(Guid id)
25062507
}
25072508
catch (Exception e)
25082509
{
2509-
UnityEngine.Debug.LogError("[SCANsat] Something went wrong while trying to load this SCANsat vessel; moving on the next vessel... \n" + e);
2510+
Log.Error("Something went wrong while trying to load this SCANsat vessel; moving on the next vessel... \n" + e);
25102511
}
25112512

25122513
if (sv.vessel == null)
@@ -2543,7 +2544,7 @@ private void registerSensor(Guid id, SCANtype sensors, double _fov, double _min_
25432544
}
25442545
catch (Exception e)
25452546
{
2546-
UnityEngine.Debug.LogError("[SCANsat] Something went wrong while trying to load this SCANsat vessel; moving on the next vessel... \n" + e);
2547+
Log.Error("Something went wrong while trying to load this SCANsat vessel; moving on the next vessel... \n" + e);
25472548
}
25482549
if (sv.vessel == null)
25492550
{

0 commit comments

Comments
 (0)