Skip to content

Commit 30bf01f

Browse files
Stephen HodgsonStephen Hodgson
authored andcommitted
Added a way to toggle sharing service logs on and off.
Misc fixes.
1 parent 10c158a commit 30bf01f

File tree

8 files changed

+222
-118
lines changed

8 files changed

+222
-118
lines changed

Assets/HoloToolkit/Sharing/Scripts/SharingStage.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ public class SharingStage : Singleton<SharingStage>
111111
private float pingIntervalCurrent;
112112
private bool isTryingToFindServer;
113113

114+
[Tooltip("Show Detailed Information for server connections")]
115+
public bool ShowDetailedLogs;
116+
114117
public string UserName
115118
{
116119
get
@@ -154,6 +157,7 @@ protected override void Awake()
154157

155158
AppInstanceUniqueId = Guid.NewGuid().ToString();
156159
logWriter = new ConsoleLogWriter();
160+
logWriter.ShowDetailedLogs = ShowDetailedLogs;
157161

158162
if (AutoDiscoverServer)
159163
{
@@ -298,7 +302,10 @@ private void SendConnectedNotification()
298302

299303
private void AutoDiscoverInit()
300304
{
301-
Debug.Log("Looking for servers...");
305+
if (ShowDetailedLogs)
306+
{
307+
Debug.Log("Looking for servers...");
308+
}
302309
discoveryClientAdapter = new DiscoveryClientAdapter();
303310
discoveryClientAdapter.DiscoveredEvent += OnSystemDiscovered;
304311

@@ -315,6 +322,10 @@ private void AutoDiscoverUpdate()
315322
pingIntervalCurrent += Time.deltaTime;
316323
if (pingIntervalCurrent > PingIntervalSec)
317324
{
325+
if (ShowDetailedLogs)
326+
{
327+
Debug.Log("Looking for servers...");
328+
}
318329
pingIntervalCurrent = 0;
319330
discoveryClient.Ping();
320331
}
@@ -328,9 +339,15 @@ private void OnSystemDiscovered(DiscoveredSystem obj)
328339
//Found a server. Stop pinging the network and connect
329340
isTryingToFindServer = false;
330341
ServerAddress = obj.GetAddress();
331-
Debug.Log("Server discovered at: " + ServerAddress);
342+
if (ShowDetailedLogs)
343+
{
344+
Debug.Log("Server discovered at: " + ServerAddress);
345+
}
332346
Connect();
333-
Debug.LogFormat("Connected to: {0}:{1}", ServerAddress, ServerPort.ToString());
347+
if (ShowDetailedLogs)
348+
{
349+
Debug.LogFormat("Connected to: {0}:{1}", ServerAddress, ServerPort.ToString());
350+
}
334351
}
335352
}
336353

@@ -372,7 +389,10 @@ private void HandleLog(string logString, string stackTrace, LogType type)
372389

373390
case LogType.Log:
374391
default:
375-
Log.Info(logString);
392+
if (ShowDetailedLogs)
393+
{
394+
Log.Info(logString);
395+
}
376396
break;
377397
}
378398
}

Assets/HoloToolkit/Sharing/Scripts/Utilities/AutoJoinSession.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public class AutoJoinSession : MonoBehaviour
2525

2626
private void Start()
2727
{
28-
// Get the ServerSessionsTracker to use later. Note that if this processes takes the role of a secondary client,
28+
// Get the ServerSessionsTracker to use later.
29+
// Note that if this processes takes the role of a secondary client,
2930
// then the sessionsTracker will always be null
3031
if (SharingStage.Instance != null && SharingStage.Instance.Manager != null)
3132
{
@@ -51,8 +52,11 @@ private void Update()
5152
currentSession.GetName().GetString() != SessionName || // We're in the wrong session
5253
currentSession.GetMachineSessionState() == MachineSessionState.DISCONNECTED) // We aren't joined or joining the right session
5354
{
54-
Debug.LogFormat("Session conn {0} Sessions: {1}.", sessionsTracker.IsServerConnected.ToString(), sessionsTracker.Sessions.Count.ToString());
55-
Debug.Log("Looking for " + SessionName);
55+
if (SharingStage.Instance.ShowDetailedLogs)
56+
{
57+
Debug.LogFormat("Session conn {0} Sessions: {1}.", sessionsTracker.IsServerConnected.ToString(), sessionsTracker.Sessions.Count.ToString());
58+
Debug.Log("Looking for " + SessionName);
59+
}
5660
bool sessionFound = false;
5761

5862
for (int i = 0; i < sessionsTracker.Sessions.Count; ++i)
@@ -69,7 +73,11 @@ private void Update()
6973

7074
if (sessionsTracker.IsServerConnected && !sessionFound && !sessionCreationRequested)
7175
{
72-
Debug.Log("Didn't find session, making a new one");
76+
if (SharingStage.Instance.ShowDetailedLogs)
77+
{
78+
Debug.Log("Didn't find session, making a new one");
79+
}
80+
7381
if (sessionsTracker.CreateSession(new XString(SessionName)))
7482
{
7583
sessionCreationRequested = true;

Assets/HoloToolkit/Sharing/Scripts/Utilities/ConsoleLogWriter.cs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,25 @@ namespace HoloToolkit.Sharing.Utilities
1010
/// </summary>
1111
public class ConsoleLogWriter : LogWriter
1212
{
13+
public bool ShowDetailedLogs = false;
14+
1315
public override void WriteLogEntry(LogSeverity severity, string message)
1416
{
15-
if (severity == LogSeverity.Info)
16-
{
17-
Debug.Log(message);
18-
}
19-
else if (severity == LogSeverity.Warning)
20-
{
21-
Debug.LogWarning(message);
22-
}
23-
else
17+
switch (severity)
2418
{
25-
Debug.LogError(message);
19+
case LogSeverity.Warning:
20+
Debug.LogWarning(message);
21+
break;
22+
case LogSeverity.Error:
23+
Debug.LogError(message);
24+
break;
25+
case LogSeverity.Info:
26+
default:
27+
if (ShowDetailedLogs)
28+
{
29+
Debug.Log(message);
30+
}
31+
break;
2632
}
2733
}
2834
}

Assets/HoloToolkit/Sharing/Scripts/Utilities/DirectPairing.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ private void OnDestroy()
8080

8181
private void OnPairingConnectionSucceeded()
8282
{
83-
Debug.Log("Direct Pairing Succeeded");
83+
if (SharingStage.Instance.ShowDetailedLogs)
84+
{
85+
Debug.Log("Direct Pairing Succeeded");
86+
}
8487
}
8588

8689
private void OnPairingConnectionFailed(PairingResult result)
@@ -89,6 +92,7 @@ private void OnPairingConnectionFailed(PairingResult result)
8992

9093
if (AutoReconnect)
9194
{
95+
Debug.LogWarning("Attempting to reconnect...");
9296
StartPairing();
9397
}
9498
}

Assets/HoloToolkit/Sharing/Tests/Scenes/SharingTest.unity

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -196,21 +196,6 @@ Transform:
196196
m_Father: {fileID: 0}
197197
m_RootOrder: 0
198198
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
199-
--- !u!1 &611461194 stripped
200-
GameObject:
201-
m_PrefabParentObject: {fileID: 163528, guid: 8aaf37823b26ee449bb3b3d7775965c3, type: 2}
202-
m_PrefabInternal: {fileID: 1703234099}
203-
--- !u!114 &611461195
204-
MonoBehaviour:
205-
m_ObjectHideFlags: 0
206-
m_PrefabParentObject: {fileID: 0}
207-
m_PrefabInternal: {fileID: 0}
208-
m_GameObject: {fileID: 611461194}
209-
m_Enabled: 1
210-
m_EditorHideFlags: 0
211-
m_Script: {fileID: 11500000, guid: 9236b45f60c55874b93c630faf4d45b9, type: 3}
212-
m_Name:
213-
m_EditorClassIdentifier:
214199
--- !u!1 &685058484
215200
GameObject:
216201
m_ObjectHideFlags: 0
@@ -303,6 +288,7 @@ GameObject:
303288
- component: {fileID: 942915102}
304289
- component: {fileID: 942915101}
305290
- component: {fileID: 942915103}
291+
- component: {fileID: 942915104}
306292
m_Layer: 0
307293
m_Name: HologramCollection
308294
m_TagString: Untagged
@@ -359,6 +345,17 @@ MonoBehaviour:
359345
m_Script: {fileID: 11500000, guid: c7a63ef1b98adec49bdb80fe1f187893, type: 3}
360346
m_Name:
361347
m_EditorClassIdentifier:
348+
--- !u!114 &942915104
349+
MonoBehaviour:
350+
m_ObjectHideFlags: 0
351+
m_PrefabParentObject: {fileID: 0}
352+
m_PrefabInternal: {fileID: 0}
353+
m_GameObject: {fileID: 942915099}
354+
m_Enabled: 1
355+
m_EditorHideFlags: 0
356+
m_Script: {fileID: 11500000, guid: 9236b45f60c55874b93c630faf4d45b9, type: 3}
357+
m_Name:
358+
m_EditorClassIdentifier:
362359
--- !u!1001 &1703234099
363360
Prefab:
364361
m_ObjectHideFlags: 0
@@ -398,7 +395,11 @@ Prefab:
398395
propertyPath: m_RootOrder
399396
value: 1
400397
objectReference: {fileID: 0}
401-
m_RemovedComponents:
402-
- {fileID: 0}
398+
- target: {fileID: 114000012667812730, guid: 8aaf37823b26ee449bb3b3d7775965c3,
399+
type: 2}
400+
propertyPath: ShowDetailedLogs
401+
value: 1
402+
objectReference: {fileID: 0}
403+
m_RemovedComponents: []
403404
m_ParentPrefab: {fileID: 100100000, guid: 8aaf37823b26ee449bb3b3d7775965c3, type: 2}
404405
m_IsPrefabParent: 0

0 commit comments

Comments
 (0)