Version 1.10.1 1.10.1
Version 1.10.1

--- a/ARFlightController.cs
+++ b/ARFlightController.cs
@@ -249,10 +249,13 @@
 
 			this.log.Clear();
 
+			this.log.Append("[ARFlightController]: Update");
+
 			if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ready && FlightGlobals.ActiveVessel != null)
 			{
 				Vessel vessel;
 				IAntennaRelay relay;
+				IAntennaRelay bestActiveRelay;
 				IList<IAntennaRelay> activeVesselRelays;
 
 				usefulRelays.Clear();
@@ -266,36 +269,62 @@
 						continue;
 					}
 
-					log.AppendFormat("Fetching best relay for vessel {0}", vessel);
+					log.AppendFormat("\nFetching best relay for vessel {0}", vessel);
 
 					relay = vessel.GetBestRelay();
 
 					if (relay != null)
 					{
-						log.AppendFormat("Finding nearest relay for best relay {0}", relay);
+						log.AppendFormat("\n\tAdding useful relay {0}", relay);
 
 						usefulRelays.Add(relay);
-						relay.FindNearestRelay();
-					}
-				}
-
+					}
+				}
+
+				bestActiveRelay = RelayDatabase.Instance.GetBestVesselRelay(FlightGlobals.ActiveVessel);
 				activeVesselRelays = RelayDatabase.Instance[FlightGlobals.ActiveVessel];
 				for (int rIdx = 0; rIdx < activeVesselRelays.Count; rIdx++)
 				{
 					relay = activeVesselRelays[rIdx];
 
+					// The best active relay will get checked with the other useful relays later.
+					if (relay == null || relay == bestActiveRelay)
+					{
+						continue;
+					}
+
+					log.AppendFormat("\nFinding nearest relay for active vessel relay {0}", relay);
+
 					relay.FindNearestRelay();
 				}
 
-				usefulRelays.Add(RelayDatabase.Instance.GetBestVesselRelay(FlightGlobals.ActiveVessel));
+				log.AppendFormat("\n\tAdding best active vessel relay {0} to usefulRelays", bestActiveRelay);
+
+				usefulRelays.Add(bestActiveRelay);
+
+				log.AppendFormat("\n\tDoing target searches for {0} useful relays", usefulRelays.Count);
+
+				for (int uIdx = 0; uIdx < usefulRelays.Count; uIdx++)
+				{
+					relay = usefulRelays[uIdx];
+
+					if (relay == null)
+					{
+						continue;
+					}
+
+					log.AppendFormat("\n\tDoing target search for useful relay {0}", relay);
+
+					relay.FindNearestRelay();
+				}
 
 				if (this.toolbarButton != null || this.appLauncherButton != null)
 				{
-					log.Append("Checking vessel relay status.\n");
+					log.Append("\nChecking active vessel relay status.");
 
 					this.currentConnectionStatus = FlightGlobals.ActiveVessel.GetConnectionStatus();
 
-					log.AppendFormat("currentConnectionStatus: {0}, setting texture to {1}",
+					log.AppendFormat("\n\tcurrentConnectionStatus: {0}, setting texture to {1}",
 						this.currentConnectionStatus, this.currentConnectionTexture);
 
 					if (this.toolbarButton != null)
@@ -318,7 +347,7 @@
 				}
 			}
 
-			log.Print();
+			log.Print(false);
 		}
 
 		private void OnDestroy()

--- a/AntennaRelay.cs
+++ b/AntennaRelay.cs
@@ -274,21 +274,28 @@
 			#if BENCH
 			startVesselLoopTicks = performanceTimer.ElapsedTicks;
 			#endif
-
+			
 			for (int rIdx = 0; rIdx < ARFlightController.UsefulRelays.Count; rIdx++)
 			{
 				potentialBestRelay = ARFlightController.UsefulRelays[rIdx];
-				log.AppendFormat("\n\t\tgot best vessel relay {0}",
+				log.AppendFormat("\n\tgot useful relay {0}",
 					potentialBestRelay == null ? "null" : potentialBestRelay.ToString());
 
 				if (potentialBestRelay == null)
 				{
-					log.Append("\n\t\t...skipping null relay");
+					log.Append("\n\t...skipping null relay");
 					continue;
 				}
 
 				if (potentialBestRelay == this || potentialBestRelay.vessel == this.vessel)
 				{
+					log.AppendFormat(
+						"\n\t...skipping relay {0} because it or its vessel ({1}) is the same as ours" +
+						"\n\t\t(our vessel is {2})",
+						potentialBestRelay,
+						potentialBestRelay.vessel == null ? "null" : potentialBestRelay.vessel.vesselName,
+						this.vessel == null ? "null" : this.vessel.vesselName
+					);
 					continue;
 				}
 
@@ -429,11 +436,10 @@
 						// Avoid infinite loops when we're not catching things right.
 						if (iterCount > FlightGlobals.Vessels.Count)
 						{
-							Tools.PostErrorMessage(
-								"[{0}] iterCount exceeded while checking for circular network; assuming it is circular" +
-								"\n\tneedle={1}" +
-								"\n\tthis.moduleRef={2}",
-								this,
+							this.LogError(
+								"iterCount exceeded while checking for circular network; assuming it is circular" +
+								"\n\tneedle={0}" +
+								"\n\tthis.moduleRef={1}",
 								needle == null ? "null" : string.Format(
 									"{0}, needle.KerbinDirect={1}, needle.targetRelay={2}",
 									needle, needle.KerbinDirect, needle.targetRelay == null ? "null" : string.Format(
@@ -505,7 +511,7 @@
 
 			log.AppendFormat("\n{0} ({1}): Search done, figuring status.", this.ToString(), this.GetType().Name);
 			log.AppendFormat(
-				"\n{0}: nearestRelay={1} ({2}m²)), bestOccludedRelay={3} ({4}m²), kerbinSqrDistance={5}m²)",
+				"\n{0}: nearestRelay={1} ({2})), bestOccludedRelay={3} ({4}), kerbinSqrDistance={5}m²)",
 				this,
 				this.nearestRelay == null ? "null" : this.nearestRelay.ToString(),
 				nearestRelaySqrQuotient,
@@ -513,7 +519,7 @@
 				bestOccludedSqrQuotient,
 				kerbinSqrDistance
 			);
-
+			
 			#if BENCH
 			startKerbinLOSTicks = this.performanceTimer.ElapsedTicks;
 			#endif
@@ -848,7 +854,7 @@
 
 				// sb.AppendFormat(Tools.SIFormatter, "", start)
 
-				Tools.PostWarningMessage(sb.ToString());
+				this.LogWarning(sb.ToString());
 
 				Tools.PutStringBuilder(sb);
 			}
@@ -881,7 +887,7 @@
 			AntennaRelay.relayCount++;
 			#endif
 
-			Tools.PostLogMessage("{0}: constructed {1}", this.GetType().Name, this.ToString());
+			this.LogDebug("{0}: constructed {1}", this.GetType().Name, this.ToString());
 		}
 	}
 }

--- a/Properties/AssemblyInfo.cs
+++ b/Properties/AssemblyInfo.cs
@@ -39,7 +39,7 @@
 // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
 // The form "{Major}.{Minor}.*" will automatically update the build and revision,
 // and "{Major}.{Minor}.{Build}.*" will update just the revision.
-[assembly: AssemblyVersion("1.9.1.*")]
+[assembly: AssemblyVersion("1.10.1.*")]
 // The following attributes are used to specify the signing key for the assembly,
 // if desired. See the Mono documentation for more information about signing.
 //[assembly: AssemblyDelaySign(false)]

--- a/ProtoAntennaRelay.cs
+++ b/ProtoAntennaRelay.cs
@@ -58,8 +58,7 @@
 				}
 				else
 				{
-					Tools.PostErrorMessage("{0}: Could not fetch vessel!  {1}{2}{3}",
-						this.ToString(),
+					this.LogError("Could not fetch vessel!  {0}{1}{2}",
 						this.protoPart == null ? "\n\tprotoPart=null" : string.Empty,
 						this.protoPart != null && this.protoPart.pVesselRef == null ?
 							"\n\tthis.protoPart.pVesselRef=null" : string.Empty,
@@ -162,7 +161,7 @@
 		{
 			this.protoPart = pps;
 
-			Tools.PostLogMessage("{0}: constructed {1}", this.GetType().Name, this.ToString());
+			this.Log("constructed ({0})", this.GetType().Name);
 		}
 	}
 }

--- a/RelayExtensions.cs
+++ b/RelayExtensions.cs
@@ -214,6 +214,72 @@
 		public static IAntennaRelay GetBestRelay(this Vessel vessel)
 		{
 			return RelayDatabase.Instance.GetBestVesselRelay(vessel);
+		}
+
+		/// <summary>
+		/// Logs a message on behalf of this relay
+		/// </summary>
+		public static void Log(this AntennaRelay relay, string format, params object[] args)
+		{
+			Tools.PostLogMessage(string.Format("[{0}] {1}", relay.ToString(), format), args);
+		}
+
+		/// <summary>
+		/// Logs a message on behalf of this relay
+		/// </summary>
+		public static void Log(this AntennaRelay relay, string msg)
+		{
+			Tools.PostLogMessage("[{0}] {1}", relay.ToString(), msg);
+		}
+
+		/// <summary>
+		/// Logs a warning message on behalf of this relay
+		/// </summary>
+		public static void LogWarning(this AntennaRelay relay, string format, params object[] args)
+		{
+			Tools.PostWarningMessage(string.Format("[{0}] {1}", relay.ToString(), format), args);
+		}
+
+		/// <summary>
+		/// Logs a warning message on behalf of this relay
+		/// </summary>
+		public static void LogWarning(this AntennaRelay relay, string msg)
+		{
+			Tools.PostWarningMessage("[{0}] {1}", relay.ToString(), msg);
+		}
+
+		/// <summary>
+		/// Logs an error message on behalf of this relay
+		/// </summary>
+		public static void LogError(this AntennaRelay relay, string format, params object[] args)
+		{
+			Tools.PostErrorMessage(string.Format("[{0}] {1}", relay.ToString(), format), args);
+		}
+
+		/// <summary>
+		/// Logs an error message on behalf of this relay
+		/// </summary>
+		public static void LogError(this AntennaRelay relay, string msg)
+		{
+			Tools.PostErrorMessage("[{0}] {1}", relay.ToString(), msg);
+		}
+
+		/// <summary>
+		/// Logs a debug-only message on behalf of this relay
+		/// </summary>
+		[System.Diagnostics.Conditional("DEBUG")]
+		public static void LogDebug(this AntennaRelay relay, string format, params object[] args)
+		{
+			Tools.PostDebugMessage(string.Format("[{0}] {1}", relay.ToString(), format), args);
+		}
+
+		/// <summary>
+		/// Logs a debug-only message on behalf of this relay
+		/// </summary>
+		[System.Diagnostics.Conditional("DEBUG")]
+		public static void LogDebug(this AntennaRelay relay, string msg)
+		{
+			Tools.PostDebugMessage("[{0}] {1}", relay.ToString(), msg);
 		}
 	}