Skip to content

Commit

Permalink
More logging and some cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
Lisias committed Oct 8, 2020
1 parent 7862bf6 commit 48ed4e9
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 90 deletions.
29 changes: 11 additions & 18 deletions Source/FMRS/FMRS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public FMRS()
/*************************************************************************************************************************/
void Awake()
{
Log.info("Awake");
Log.dbg("Awake");

FMRS_core_awake();

Expand Down Expand Up @@ -98,10 +98,8 @@ void Awake()
void Start()
{
//RenderingManager.AddToPostDrawQueue(3, new Callback(drawGUI));
#if DEBUG
//if (Debug_Level_1_Active)
Log.PushStackInfo("FMRS.Start", "entering Start()");
#endif
Log.PushStackInfo("FMRS.Start", "entering Start()");

if (!_SAVE_Has_Launched)
_SETTING_Enabled = false;

Expand Down Expand Up @@ -131,10 +129,7 @@ void Start()
File.Asset.Solve("icons", stockTexture),
File.Asset.Solve("icons", blizzyTexture)
);
#if DEBUG
// if (Debug_Level_1_Active)
Log.PopStackInfo("leaving FMRS.Start ()");
#endif
Log.PopStackInfo("leaving FMRS.Start ()");
GameEvents.onShowUI.Add(ShowUI);
GameEvents.onHideUI.Add(HideUI);

Expand Down Expand Up @@ -182,19 +177,14 @@ void FixedUpdate()
/*************************************************************************************************************************/
void OnDestroy()
{
#if DEBUG
//if (Debug_Level_1_Active)
Log.PushStackInfo("FMRS.OnDestroy", "enter OnDestroy()");
#endif
Log.PushStackInfo("FMRS.OnDestroy", "enter OnDestroy()");

destroy_FMRS();

remove_toolbar_button();

//RenderingManager.RemoveFromPostDrawQueue(3, new Callback(drawGUI));
#if DEBUG
//if (Debug_Level_1_Active)
Log.PopStackInfo("leave OnDestroy()");
#endif
Log.PopStackInfo("leave OnDestroy()");
}


Expand Down Expand Up @@ -345,6 +335,7 @@ void FixedUpdate()
/*************************************************************************************************************************/
void OnDestroy()
{
Log.dbg("FMRS_Space_Center OnDestroy()");
}
}

Expand Down Expand Up @@ -429,6 +420,7 @@ void FixedUpdate()
/*************************************************************************************************************************/
void OnDestroy()
{
Log.dbg("FMRS_TrackingStation OnDestroy()");
destroy_FMRS();
}
}
Expand All @@ -454,8 +446,8 @@ public FMRS_Main_Menu()
/*************************************************************************************************************************/
void Awake()
{
FMRS_core_awake();
Log.dbg("FMRS_MainMenu On Awake");
FMRS_core_awake();
}

/*************************************************************************************************************************/
Expand Down Expand Up @@ -504,6 +496,7 @@ void FixedUpdate()
/*************************************************************************************************************************/
void OnDestroy()
{
Log.dbg("FMRS_Main_Menu OnDestroy()");
//nothing
}
}
Expand Down
16 changes: 4 additions & 12 deletions Source/FMRS/FMRS_Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void FMRS_core_awake()
{
Log.PushStackInfo("FMRS_Core.FMRS_core_awake", "entering FMRS_core_awake()");

Log.force("FMRS CODE AWAKE {0}", FILES.SETTINGS_FOLDER);
Log.dbg("FMRS CODE AWAKE {0}", FILES.SETTINGS_FOLDER);
if (!System.IO.Directory.Exists(FILES.SETTINGS_FOLDER)) System.IO.Directory.CreateDirectory(FILES.SETTINGS_FOLDER);
init_Save_File_Content();
load_save_file();
Expand All @@ -112,12 +112,8 @@ public void FMRS_core_awake()
/*************************************************************************************************************************/
public void flight_scene_start_routine()
{
#if DEBUG
//if (Debug_Level_1_Active)
Log.PushStackInfo("FMRS_Core.flight_scene_start_routine", "entering flight_scene_start_routine()");
// if (Debug_Active)
Log.info("FMRS flight_scene_start_routine");
#endif
Log.dbg("FMRS flight_scene_start_routine");

plugin_active = true;
if (FlightGlobals.ActiveVessel == null)
Expand All @@ -126,10 +122,7 @@ public void flight_scene_start_routine()
{
if (FlightGlobals.ActiveVessel.situation == Vessel.Situations.PRELAUNCH || n_launchpad_preflight || flight_preflight)
{
#if DEBUG
// if (Debug_Active)
Log.info("FMRS Vessel is prelaunch");
#endif
Log.dbg("FMRS Vessel is prelaunch");

delete_dropped_vessels();
_SETTING_Enabled = true;
Expand Down Expand Up @@ -338,9 +331,8 @@ public void flight_scene_update_routine()
launch_routine(dummy_event);
}
}
#if DEBUG

Log.PopStackInfo("leaving flight_scene_update_routine");
#endif
}


Expand Down
5 changes: 1 addition & 4 deletions Source/FMRS/FMRS_Core_API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ public string FMRS_Version
{
get
{
#if false
return FMRS_Version_Info.version_number;
#endif
return "n/a";
return Version.Number;
}
}

Expand Down
4 changes: 1 addition & 3 deletions Source/FMRS/FMRS_Core_GUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,8 @@ private void init_skin()
scrollbar_stlye.overflow = new RectOffset(1, 1, 1, 1);

skin_init = true;
#if DEBUG
//if (Debug_Level_1_Active)

Log.PopStackInfo("leave init_skin()");
#endif
}
}
}
12 changes: 4 additions & 8 deletions Source/FMRS/FMRS_Core_Recovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,8 @@ public void recovery_requested_handler(Vessel vessel_recovered)
_SAVE_Switched_To_Dropped = false;

write_save_values_to_file();
#if DEBUG
//if (Debug_Level_1_Active)
Log.PopStackInfo("leave recovery_requested_handler(Vessel input)");
#endif

Log.PopStackInfo("leave recovery_requested_handler(Vessel input)");
}


Expand Down Expand Up @@ -308,10 +306,8 @@ private string get_vessel_part_list(List<ProtoVessel> vessel_list)
return_string += Math.Round(keyvlaue.Value, 2).ToString();
return_string += "@ ";
}
#if DEBUG
// if (Debug_Level_1_Active)
Log.PopStackInfo("leave get_vessel_part_list(ProtoVessel vessel)");
#endif

Log.PopStackInfo("leave get_vessel_part_list(ProtoVessel vessel)");
return return_string;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/FMRS/FMRS_THL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public class FMRS_THL_Rep : FMRS_THL_Util
/*************************************************************************************************************************/
public FMRS_THL_Rep(bool Debug_Active = false, bool Debug_Level_1_Active = false)
{
Debug.Log("### FMRS_THL_Rep: constructor");
Log.detail("### FMRS_THL_Rep: constructor");
}


Expand Down
63 changes: 23 additions & 40 deletions Source/FMRS/FMRS_Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ private void Start()

private void OnDestroy()
{
Log.dbg("FMRS_SAVE_Util OnDestroy()");
GameEvents.onGameStateSaved.Remove(OnGameStateSaved);
}

Expand Down Expand Up @@ -191,7 +192,7 @@ private void Start()

public void set_save_value(save_cat cat, string key, string value)
{
Log.detail("entering set_save_value(int cat, string key, string value)");
Log.dbg("entering set_save_value(int cat, string key, string value)");

if (Save_File_Content[cat].ContainsKey(key))
{
Expand Down Expand Up @@ -228,20 +229,22 @@ public void set_save_value(save_cat cat, string key, string value)

}

Log.info("set_save_value: {0} = {1}", key, value);
Log.detail("leaving set_save_value(int cat, string key, string value)");
Log.dbg("set_save_value: {0} = {1}", key, value);
Log.dbg("leaving set_save_value(int cat, string key, string value)");
}


/*************************************************************************************************************************/
public string get_save_value(save_cat cat, string key)
{
Log.dbg("entering get_save_value(int cat, string key) #### FMRS: NO LEAVE MESSAGE");
Log.dbg("entering get_save_value(int cat, string key) {0} {1}", cat, key);

if (Save_File_Content[cat].ContainsKey(key))
return (Save_File_Content[cat][key]);
else
return (false.ToString());
string r = Save_File_Content[cat].ContainsKey(key)
? (Save_File_Content[cat][key])
: (false.ToString())
;
Log.dbg("entering get_save_value(int cat, string key) = {0}", r);
return r;
}


Expand Down Expand Up @@ -421,10 +424,8 @@ public void flush_save_file()
bflush_save_file = false;
init_save_file();
read_save_file();
#if DEBUG
// if (Debug_Level_1_Active)
Log.PopStackInfo("leave flush_save_file()");
#endif

Log.PopStackInfo("leave flush_save_file()");
}


Expand Down Expand Up @@ -463,44 +464,32 @@ public void read_save_file()
}
if (bflush_save_file)
return;
Log.dbg("readed save file with success.");

try
{
temp_double = Convert.ToDouble(get_save_value(save_cat.SETTING, "Window_X"));
windowPos.x = Convert.ToInt32(temp_double);
temp_double = Convert.ToDouble(get_save_value(save_cat.SETTING, "Window_Y"));
windowPos.y = Convert.ToInt32(temp_double);
Debug.Log("windowPos loaded from file");
Log.dbg("windowPos loaded from file");
}
catch (Exception)
{
#if false
// DEBUG
Debug_Active = true;
Debug_Level_1_Active = true;
#endif
Log.info("invalid save file, flush save file");
Log.error("invalid save file, flush save file");
bflush_save_file = true;
}
#if DEBUG
Log.detail("Dumping Save_File_Content...");
foreach (KeyValuePair<save_cat, Dictionary<string, string>> temp_keyvalue in Save_File_Content)
foreach (KeyValuePair<string, string> readvalue in temp_keyvalue.Value)
Log.info("{0} = {1} = {2}" + temp_keyvalue.Key, readvalue.Key, readvalue.Value);
Log.detail("{0} = {1} = {2}", temp_keyvalue.Key, readvalue.Key, readvalue.Value);
Log.detail("Save_File_Content dumped.");
#endif

if (bflush_save_file)
return;
#if false
// DEBUG
if (get_save_value(save_cat.SETTING,"Debug_Level") == "1" && Debug_Active)
Debug_Level_1_Active = true;

if (get_save_value(save_cat.SETTING,"Debug_Level") == "2" && Debug_Active)
{
Debug_Level_1_Active = true;
Debug_Level_2_Active = true;
}
#endif
try
{
_SETTING_Armed = Convert.ToBoolean(get_save_value(save_cat.SETTING, "Armed"));
Expand All @@ -521,7 +510,7 @@ public void read_save_file()
}
catch (Exception)
{
Log.info("invalid save file, flush save file");
Log.error("invalid save file, flush save file");
bflush_save_file = true;
}
Log.PopStackInfo("leave read_save_file()");
Expand Down Expand Up @@ -564,10 +553,7 @@ public void init_save_file()
file.WriteLine(writecat.Key.ToString() + "=" + writevalue.Key + "=" + writevalue.Value);

file.Close();
#if DEBUG
// if (Debug_Level_1_Active)
Log.PopStackInfo("leave init_save_file()");
#endif
Log.PopStackInfo("leave init_save_file()");
}


Expand Down Expand Up @@ -600,11 +586,8 @@ public void load_save_file()
/*************************************************************************************************************************/
public void get_dropped_vessels()
{
#if DEBUG
// if (Debug_Level_1_Active)
Log.PushStackInfo("FMRS_Util.get_dropped_vessels", "entering get_dropped_vessels()");
#endif

Log.PushStackInfo("FMRS_Util.get_dropped_vessels", "entering get_dropped_vessels()");

foreach (KeyValuePair<save_cat, Dictionary<string, string>> savecat in Save_File_Content)
{
if (savecat.Key == save_cat.DROPPED)
Expand Down
8 changes: 4 additions & 4 deletions Source/FMRS/RecoveryControllerWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,21 @@ static object CallRecoveryController(string func, object modName)
}
else
{
Debug.Log(func + " not available in RecoveryController");
Log.detail("{0} not available in RecoveryController", func);
}
}
else
{
Debug.Log(func + " failed");
Log.warn("{0} failed", func);
return null;
}
}
Debug.Log("calledtype failed");
Log.warn("calledtype failed");
return null;
}
catch (Exception e)
{
Debug.Log("Error calling type: " + e);
Log.error("Error calling type: {0}", e);
return null;
}
}
Expand Down
1 change: 1 addition & 0 deletions Source/FMRS/ToolbarRegistration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class RegisterToolbar : MonoBehaviour
{
void Start()
{
Log.dbg("Toolbar Registering {0} {1}", FMRS.MODID, FMRS.MODNAME);
ToolbarControl.RegisterMod(FMRS.MODID, FMRS.MODNAME);
}
}
Expand Down

0 comments on commit 48ed4e9

Please sign in to comment.