/// <summary> /// Notify a message to the log only if the VERBOSE_DEBUG_LOG from the ksp settings.cfg /// is set to true. In debug mode the message will also be logged to the /// <paramref name="logLevel"/> list. /// </summary> /// <param name="message">Message to log</param> /// <param name="logLevel">Loglevel for debugging</param> public static void Verbose(string message, RTLogLevel logLevel = RTLogLevel.LVL1) { if (verboseLogging) { Notify(message, logLevel); } }
/// <summary> /// Notify a message to the log. In debug mode the message will also be logged /// to the <paramref name="logLevel"/> list. /// </summary> /// <param name="message">Message to log</param> /// <param name="logLevel">Loglevel for debugging</param> public static void Notify(string message, RTLogLevel logLevel = RTLogLevel.LVL1) { UnityEngine.Debug.Log("RemoteTech: " + message); #region ON-DEBUGMODE #if DEBUG NotifyToLogLevel(message, logLevel); #endif #endregion }
/// <summary> /// Notify a message to the log. In debug mode the message will also be logged /// to the <paramref name="logLevel"/> list. /// </summary> /// <param name="message">Message to log</param> /// <param name="logLevel">Loglevel for debugging</param> public static void Notify(string message, RTLogLevel logLevel = RTLogLevel.LVL1) { #if !DEBUG if (logLevel != RTLogLevel.API && logLevel != RTLogLevel.Assembly) #endif UnityEngine.Debug.Log("[RemoteTech] " + message); #region ON-DEBUGMODE #if DEBUG NotifyToLogLevel(message, logLevel); #endif #endregion }
/// <summary> /// Draws all debug logs /// </summary> private void drawRTDebugLogEntrys() { GUIStyle lablestyle = new GUIStyle(GUI.skin.label); lablestyle.wordWrap = false; lablestyle.fontSize = 11; lablestyle.normal.textColor = Color.white; // draw the vertical buttons for each debug lvl GUILayout.BeginHorizontal(); { var pushFontsize = GUI.skin.button.fontSize; GUI.skin.button.fontSize = 11; foreach (RTLogLevel lvl in Enum.GetValues(typeof(RTLogLevel))) { RTUtil.FakeStateButton(new GUIContent(lvl.ToString()), () => { this.currentLogLevel = lvl; }, (int)currentLogLevel, (int)lvl, GUILayout.Height(16)); } GUI.skin.button.fontSize = pushFontsize; } GUILayout.EndHorizontal(); // draw the input of the selected debug list debugLogScrollPosition = GUILayout.BeginScrollView(debugLogScrollPosition); { foreach (var logEntry in RTLog.RTLogList[this.currentLogLevel]) { GUILayout.Label(logEntry, lablestyle, GUILayout.Height(13)); } } GUILayout.EndScrollView(); // If the mouse is not over the debug window we will flip the scrollposition.y to maximum if (!this.backupPosition.ContainsMouse()) { debugLogScrollPosition.y = Mathf.Infinity; } }
/// <summary> /// Draws the API Tester section /// </summary> private void drawAPITester() { // switch to the API Debug log this.currentLogLevel = RTLogLevel.API; // API.HasFlightComputer #region API.HasFlightComputer GUILayout.BeginHorizontal(); { GUILayout.Label("API.HasFlightComputer; Guid: ", GUILayout.ExpandWidth(true)); this.HasFlightComputerGuidInput = GUILayout.TextField(this.HasFlightComputerGuidInput, GUILayout.Width(160)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { var result = RemoteTech.API.API.HasFlightComputer(new Guid(this.HasFlightComputerGuidInput)); RTLog.Verbose("API.HasFlightComputer({0}) = {1}", this.currentLogLevel, this.HasFlightComputerGuidInput, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion #region API.HasAnyConnection GUILayout.BeginHorizontal(); { GUILayout.Label("API.HasAnyConnection; Guid: ", GUILayout.ExpandWidth(true)); this.HasAnyConnectionGuidInput = GUILayout.TextField(this.HasAnyConnectionGuidInput, GUILayout.Width(160)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { var result = RemoteTech.API.API.HasAnyConnection(new Guid(this.HasAnyConnectionGuidInput)); RTLog.Verbose("API.HasAnyConnection({0}) = {1}", this.currentLogLevel, this.HasAnyConnectionGuidInput, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion #region API.HasConnectionToKSC GUILayout.BeginHorizontal(); { GUILayout.Label("API.HasConnectionToKSC; Guid: ", GUILayout.ExpandWidth(true)); this.HasConnectionToKSCGuidInput = GUILayout.TextField(this.HasConnectionToKSCGuidInput, GUILayout.Width(160)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { var result = RemoteTech.API.API.HasConnectionToKSC(new Guid(this.HasConnectionToKSCGuidInput)); RTLog.Verbose("API.HasConnectionToKSC({0}) = {1}", this.currentLogLevel, this.HasConnectionToKSCGuidInput, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion #region APi.GetShortestSignalDelay GUILayout.BeginHorizontal(); { GUILayout.Label("API.GetShortestSignalDelay; Guid: ", GUILayout.ExpandWidth(true)); this.GetShortestSignalDelayGuidInput = GUILayout.TextField(this.GetShortestSignalDelayGuidInput, GUILayout.Width(160)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { var result = RemoteTech.API.API.GetShortestSignalDelay(new Guid(this.GetShortestSignalDelayGuidInput)); RTLog.Verbose("API.GetShortestSignalDelayGuidInput({0}) = {1}", this.currentLogLevel, this.GetShortestSignalDelayGuidInput, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion #region API.GetSignalDelayToKSC GUILayout.BeginHorizontal(); { GUILayout.Label("API.GetSignalDelayToKSC; Guid: ", GUILayout.ExpandWidth(true)); this.GetSignalDelayToKSCGuidInput = GUILayout.TextField(this.GetSignalDelayToKSCGuidInput, GUILayout.Width(160)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { var result = RemoteTech.API.API.GetSignalDelayToKSC(new Guid(this.GetSignalDelayToKSCGuidInput)); RTLog.Verbose("API.GetSignalDelayToKSC({0}) = {1}", this.currentLogLevel, this.GetSignalDelayToKSCGuidInput, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion #region API.GetSignalDelayToSatellite GUILayout.BeginHorizontal(); { GUILayout.Label("API.GetSignalDelayToSatellite; Guid: ", GUILayout.ExpandWidth(true)); this.GetSignalDelayToSatelliteGuidAInput = GUILayout.TextField(this.GetSignalDelayToSatelliteGuidAInput, GUILayout.Width(70)); GUILayout.Label("to: ", GUILayout.ExpandWidth(true)); this.GetSignalDelayToSatelliteGuidBInput = GUILayout.TextField(this.GetSignalDelayToSatelliteGuidBInput, GUILayout.Width(70)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { var result = RemoteTech.API.API.GetSignalDelayToSatellite(new Guid(this.GetSignalDelayToSatelliteGuidAInput), new Guid(this.GetSignalDelayToSatelliteGuidBInput)); RTLog.Verbose("API.GetSignalDelayToSatellite({0},{1}) = {2}", this.currentLogLevel, this.GetSignalDelayToSatelliteGuidAInput, this.GetSignalDelayToSatelliteGuidBInput, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion #region API.QueueCommandToFlightComputer GUILayout.BeginHorizontal(); { GUILayout.Label("API.QueueCommandToFlightComputer; Guid: ", GUILayout.ExpandWidth(true)); this.ReceivDataVesselGuidInput = GUILayout.TextField(this.ReceivDataVesselGuidInput, GUILayout.Width(160)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { ConfigNode dataNode = new ConfigNode(); dataNode.AddValue("Executor", "RemoteTech"); dataNode.AddValue("QueueLabel", "Receive Data"); dataNode.AddValue("ActiveLabel", "Receiveing Data ..."); dataNode.AddValue("ShortLabel", "Receive Data"); dataNode.AddValue("ReflectionType", "RemoteTech.UI.DebugWindow"); dataNode.AddValue("ReflectionPopMethod", "ReceiveDataPop"); dataNode.AddValue("ReflectionExecuteMethod", "ReceiveDataExec"); dataNode.AddValue("ReflectionAbortMethod", "ReceiveDataAbort"); dataNode.AddValue("GUIDString", this.ReceivDataVesselGuidInput); dataNode.AddValue("YourData1", "RemoteTech"); dataNode.AddValue("YourDataN", "TechRemote"); var result = RemoteTech.API.API.QueueCommandToFlightComputer(dataNode); RTLog.Verbose("API.QueueCommandToFlightComputer(ConfigNode) = {0}", this.currentLogLevel, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion #region API.HasLocalControl GUILayout.BeginHorizontal(); { GUILayout.Label("API.HasLocalControl; Guid: ", GUILayout.ExpandWidth(true)); this.HasLocalControlGuidInput = GUILayout.TextField(this.HasLocalControlGuidInput, GUILayout.Width(160)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { var result = RemoteTech.API.API.HasLocalControl(new Guid(this.HasLocalControlGuidInput)); RTLog.Verbose("API.HasLocalControl({0}) = {1}", this.currentLogLevel, this.HasLocalControlGuidInput, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion }
/// <summary> /// Draws the API Tester section /// </summary> private void drawAPITester() { // switch to the API Debug log this.currentLogLevel = RTLogLevel.API; #region API.HasFlightComputer GUILayout.BeginHorizontal(); { GUILayout.Label("API.HasFlightComputer; Guid: ", GUILayout.ExpandWidth(true)); this.HasFlightComputerGuidInput = GUILayout.TextField(this.HasFlightComputerGuidInput, GUILayout.Width(160)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { var result = RemoteTech.API.API.HasFlightComputer(new Guid(this.HasFlightComputerGuidInput)); RTLog.Verbose("API.HasFlightComputer({0}) = {1}", this.currentLogLevel, this.HasFlightComputerGuidInput, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion #region API.HasAnyConnection GUILayout.BeginHorizontal(); { GUILayout.Label("API.HasAnyConnection; Guid: ", GUILayout.ExpandWidth(true)); this.HasAnyConnectionGuidInput = GUILayout.TextField(this.HasAnyConnectionGuidInput, GUILayout.Width(160)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { var result = RemoteTech.API.API.HasAnyConnection(new Guid(this.HasAnyConnectionGuidInput)); RTLog.Verbose("API.HasAnyConnection({0}) = {1}", this.currentLogLevel, this.HasAnyConnectionGuidInput, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion #region API.HasConnectionToKSC GUILayout.BeginHorizontal(); { GUILayout.Label("API.HasConnectionToKSC; Guid: ", GUILayout.ExpandWidth(true)); this.HasConnectionToKSCGuidInput = GUILayout.TextField(this.HasConnectionToKSCGuidInput, GUILayout.Width(160)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { var result = RemoteTech.API.API.HasConnectionToKSC(new Guid(this.HasConnectionToKSCGuidInput)); RTLog.Verbose("API.HasConnectionToKSC({0}) = {1}", this.currentLogLevel, this.HasConnectionToKSCGuidInput, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion #region APi.GetShortestSignalDelay GUILayout.BeginHorizontal(); { GUILayout.Label("API.GetShortestSignalDelay; Guid: ", GUILayout.ExpandWidth(true)); this.GetShortestSignalDelayGuidInput = GUILayout.TextField(this.GetShortestSignalDelayGuidInput, GUILayout.Width(160)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { var result = RemoteTech.API.API.GetShortestSignalDelay(new Guid(this.GetShortestSignalDelayGuidInput)); RTLog.Verbose("API.GetShortestSignalDelayGuidInput({0}) = {1}", this.currentLogLevel, this.GetShortestSignalDelayGuidInput, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion #region API.GetSignalDelayToKSC GUILayout.BeginHorizontal(); { GUILayout.Label("API.GetSignalDelayToKSC; Guid: ", GUILayout.ExpandWidth(true)); this.GetSignalDelayToKSCGuidInput = GUILayout.TextField(this.GetSignalDelayToKSCGuidInput, GUILayout.Width(160)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { var result = RemoteTech.API.API.GetSignalDelayToKSC(new Guid(this.GetSignalDelayToKSCGuidInput)); RTLog.Verbose("API.GetSignalDelayToKSC({0}) = {1}", this.currentLogLevel, this.GetSignalDelayToKSCGuidInput, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion #region API.GetSignalDelayToSatellite GUILayout.BeginHorizontal(); { GUILayout.Label("API.GetSignalDelayToSatellite; Guid: ", GUILayout.ExpandWidth(true)); this.GetSignalDelayToSatelliteGuidAInput = GUILayout.TextField(this.GetSignalDelayToSatelliteGuidAInput, GUILayout.Width(70)); GUILayout.Label("to: ", GUILayout.ExpandWidth(true)); this.GetSignalDelayToSatelliteGuidBInput = GUILayout.TextField(this.GetSignalDelayToSatelliteGuidBInput, GUILayout.Width(70)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { var result = RemoteTech.API.API.GetSignalDelayToSatellite(new Guid(this.GetSignalDelayToSatelliteGuidAInput), new Guid(this.GetSignalDelayToSatelliteGuidBInput)); RTLog.Verbose("API.GetSignalDelayToSatellite({0},{1}) = {2}", this.currentLogLevel, this.GetSignalDelayToSatelliteGuidAInput, this.GetSignalDelayToSatelliteGuidBInput, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion #region API.QueueCommandToFlightComputer GUILayout.BeginHorizontal(); { GUILayout.Label("API.QueueCommandToFlightComputer; Guid: ", GUILayout.ExpandWidth(true)); this.ReceivDataVesselGuidInput = GUILayout.TextField(this.ReceivDataVesselGuidInput, GUILayout.Width(160)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { ConfigNode dataNode = new ConfigNode(); dataNode.AddValue("Executor", "RemoteTech"); dataNode.AddValue("QueueLabel", "Receive Data"); dataNode.AddValue("ActiveLabel", "Receiveing Data ..."); dataNode.AddValue("ShortLabel", "Receive Data"); dataNode.AddValue("ReflectionType", "RemoteTech.UI.DebugWindow"); dataNode.AddValue("ReflectionPopMethod", "ReceiveDataPop"); dataNode.AddValue("ReflectionExecuteMethod", "ReceiveDataExec"); dataNode.AddValue("ReflectionAbortMethod", "ReceiveDataAbort"); dataNode.AddValue("GUIDString", this.ReceivDataVesselGuidInput); dataNode.AddValue("YourData1", "RemoteTech"); dataNode.AddValue("YourDataN", "TechRemote"); var result = RemoteTech.API.API.QueueCommandToFlightComputer(dataNode); RTLog.Verbose("API.QueueCommandToFlightComputer(ConfigNode) = {0}", this.currentLogLevel, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion #region API.HasLocalControl GUILayout.BeginHorizontal(); { GUILayout.Label("API.HasLocalControl; Guid: ", GUILayout.ExpandWidth(true)); this.HasLocalControlGuidInput = GUILayout.TextField(this.HasLocalControlGuidInput, GUILayout.Width(160)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { var result = RemoteTech.API.API.HasLocalControl(new Guid(this.HasLocalControlGuidInput)); RTLog.Verbose("API.HasLocalControl({0}) = {1}", this.currentLogLevel, this.HasLocalControlGuidInput, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion #region API.GetMaxRangeDistance GUILayout.BeginHorizontal(); { GUILayout.Label("API.GetMaxRangeDistance; Guid: ", GUILayout.ExpandWidth(true)); this.GetMaxRangeDistanceSatelliteGuidAInput = GUILayout.TextField(this.GetMaxRangeDistanceSatelliteGuidAInput, GUILayout.Width(70)); GUILayout.Label("to: ", GUILayout.ExpandWidth(true)); this.GetMaxRangeDistanceSatelliteGuidBInput = GUILayout.TextField(this.GetMaxRangeDistanceSatelliteGuidBInput, GUILayout.Width(70)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { var result = RemoteTech.API.API.GetMaxRangeDistance(new Guid(this.GetMaxRangeDistanceSatelliteGuidAInput), new Guid(this.GetMaxRangeDistanceSatelliteGuidBInput)); RTLog.Verbose("API.GetMaxRangeDistance({0},{1}) = {2}", this.currentLogLevel, this.GetMaxRangeDistanceSatelliteGuidAInput, this.GetMaxRangeDistanceSatelliteGuidBInput, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion #region API.GetRangeDistance GUILayout.BeginHorizontal(); { GUILayout.Label("API.GetRangeDistance; Guid: ", GUILayout.ExpandWidth(true)); this.GetRangeDistanceSatelliteGuidAInput = GUILayout.TextField(this.GetRangeDistanceSatelliteGuidAInput, GUILayout.Width(70)); GUILayout.Label("to: ", GUILayout.ExpandWidth(true)); this.GetRangeDistanceSatelliteGuidBInput = GUILayout.TextField(this.GetRangeDistanceSatelliteGuidBInput, GUILayout.Width(70)); if (GUILayout.Button("Run", GUILayout.Width(50))) { try { var result = RemoteTech.API.API.GetRangeDistance(new Guid(this.GetRangeDistanceSatelliteGuidAInput), new Guid(this.GetRangeDistanceSatelliteGuidBInput)); RTLog.Verbose("API.GetRangeDistance({0},{1}) = {2}", this.currentLogLevel, this.GetRangeDistanceSatelliteGuidAInput, this.GetRangeDistanceSatelliteGuidBInput, result); } catch (Exception ex) { RTLog.Verbose("Exception {0}", this.currentLogLevel, ex); } // go to the end of the log this.debugLogScrollPosition.y = Mathf.Infinity; } } GUILayout.EndHorizontal(); #endregion }
/// <summary> /// Notify a message to the log. Replaces each format item on the <paramref name="message"/> /// with the text equivalent of a corresponding objects value from <paramref name="param"/>. /// In debug mode the message will also be logged to the <paramref name="logLevel"/> list. /// </summary> /// <param name="message">Message to log with format items</param> /// <param name="logLevel">Loglevel for debugging</param> /// <param name="param">objects to format</param> public static void Notify(string message, RTLogLevel logLevel = RTLogLevel.LVL1, params object[] param) { Notify(string.Format(message, param), logLevel); }
/// <summary> /// Logs the <paramref name="message"/> to the <paramref name="logLevel"/> /// </summary> /// <param name="message">Message to log</param> /// <param name="logLevel">Loglevel for debugging</param> private static void NotifyToLogLevel(string message, RTLogLevel logLevel) { RTLogList[logLevel].Add(message); }