Skip to content

Commit 2f4cfa3

Browse files
committed
Merge branch 'dev/v3.17.x.x'
2 parents 262d022 + bcfa3d4 commit 2f4cfa3

File tree

9 files changed

+65
-17
lines changed

9 files changed

+65
-17
lines changed

Assets/PatchKit Patcher/Scripts/AppData/Local/Pack1Meta.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
using System.IO;
22
using Newtonsoft.Json;
3+
using PatchKit.Unity.Patcher.Debug;
34

45
namespace PatchKit.Unity.Patcher.AppData.Local
56
{
67
public class Pack1Meta
78
{
9+
private static readonly DebugLogger DebugLogger = new DebugLogger(typeof(Pack1Meta));
10+
811
#region Fields
912

1013
public string Version { get; set; }
@@ -30,7 +33,7 @@ public static Pack1Meta ParseFromFile(string filename)
3033

3134
public static Pack1Meta Parse(string content)
3235
{
33-
UnityEngine.Debug.Log(content);
36+
DebugLogger.Log(content);
3437
return JsonConvert.DeserializeObject<Pack1Meta>(content);
3538
}
3639

Assets/PatchKit Patcher/Scripts/AppData/Local/ThreadBufferedStream.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
using System.IO;
33
using System.Threading;
44
using JetBrains.Annotations;
5+
using PatchKit.Unity.Patcher.Debug;
56

67
namespace PatchKit.Unity.Patcher.AppData.Local
78
{
89
public class ThreadBufferedStream : Stream
910
{
11+
private static readonly DebugLogger DebugLogger = new DebugLogger(typeof(ThreadBufferedStream));
12+
1013
private readonly Stream _innerStream;
1114
private readonly byte[] _buffer;
1215

@@ -68,12 +71,12 @@ private void SpawnReaderThread()
6871
{
6972
try
7073
{
71-
//UnityEngine.Debug.Log("Entering semaphore from thread...");
74+
//DebugLogger.Log("Entering semaphore from thread...");
7275
_semaphore.WaitOne();
7376
{
7477
if (_eof)
7578
{
76-
//UnityEngine.Debug.Log("BREAKING semaphore from thread...");
79+
//DebugLogger.Log("BREAKING semaphore from thread...");
7780
break;
7881
}
7982

@@ -85,7 +88,7 @@ private void SpawnReaderThread()
8588
}
8689
finally
8790
{
88-
//UnityEngine.Debug.Log("Leaving semaphore from thread.");
91+
//DebugLogger.Log("Leaving semaphore from thread.");
8992
_semaphore.Release();
9093
}
9194

@@ -100,7 +103,7 @@ public override int Read(byte[] buffer, int offset, int count)
100103

101104
try
102105
{
103-
//UnityEngine.Debug.Log("Entering semaphore from Read..." + count);
106+
//DebugLogger.Log("Entering semaphore from Read..." + count);
104107
_semaphore.WaitOne();
105108
{
106109
// repeat while there's something to read
@@ -131,36 +134,36 @@ public override int Read(byte[] buffer, int offset, int count)
131134
if (copied == count)
132135
{
133136
// all bytes has been copied
134-
//UnityEngine.Debug.Log("BREAK semaphore from Read.");
137+
//DebugLogger.Log("BREAK semaphore from Read.");
135138
break;
136139
}
137140
}
138141
}
139142
}
140143
finally
141144
{
142-
//UnityEngine.Debug.Log("Leaving semaphore from Read.");
145+
//DebugLogger.Log("Leaving semaphore from Read.");
143146
_semaphore.Release();
144147
}
145148

146149
_position += copied;
147150

148-
//UnityEngine.Debug.Log("Returning " + copied);
151+
//DebugLogger.Log("Returning " + copied);
149152

150153
return copied;
151154
}
152155

153156
private void ReadToBuffer()
154157
{
155158
int size = _buffer.Length - _bufferedBytes;
156-
//UnityEngine.Debug.Log("Reading into buffer " + size);
159+
//DebugLogger.Log("Reading into buffer " + size);
157160

158161
int read = _innerStream.Read(_buffer, _bufferedBytes, size);
159162
_bufferedBytes += read;
160163

161164
if (read == 0)
162165
{
163-
//UnityEngine.Debug.Log("End of file");
166+
//DebugLogger.Debug.Log("End of file");
164167
_eof = true;
165168
}
166169
}

Assets/PatchKit Patcher/Scripts/Debug/UnityMessageWriter.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public UnityMessageWriter([NotNull] IMessageFormatter formatter)
1919
public void Write(Message message, MessageContext messageContext)
2020
{
2121
var text = _formatter.Format(message, messageContext);
22+
var patcher = Patcher.Instance;
23+
if (!string.IsNullOrEmpty(patcher.AppSecret))
24+
{
25+
text = text.Replace(patcher.AppSecret, patcher.TraceableAppSecret);
26+
}
2227

2328
switch (message.Type)
2429
{

Assets/PatchKit Patcher/Scripts/Patcher.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,23 @@ public static Patcher Instance
8787

8888
private PatchKit.Unity.Patcher.Cancellation.CancellationTokenSource _updateAppCancellationTokenSource;
8989

90+
public string TraceableAppSecret
91+
{
92+
get
93+
{
94+
if (_traceableAppSecret == null)
95+
{
96+
_traceableAppSecret = BuildTraceableAppSecret();
97+
}
98+
99+
return _traceableAppSecret;
100+
}
101+
}
102+
103+
private string _traceableAppSecret;
104+
105+
public string AppSecret { get; private set; }
106+
90107
public ErrorDialog ErrorDialog;
91108

92109
public string EditorAppSecret;
@@ -512,6 +529,8 @@ private void ThreadLoadPatcherData()
512529
var inputArgumentsPatcherDataReader = new InputArgumentsPatcherDataReader();
513530
_data.Value = inputArgumentsPatcherDataReader.Read();
514531
#endif
532+
AppSecret = _data.Value.AppSecret;
533+
515534
DebugLogger.LogVariable(_data.Value.AppSecret, "Data.AppSecret");
516535
DebugLogger.LogVariable(_data.Value.AppDataPath, "Data.AppDataPath");
517536
DebugLogger.LogVariable(_data.Value.OverrideLatestVersionId, "Data.OverrideLatestVersionId");
@@ -953,5 +972,11 @@ private bool ThreadTryRestartWithRequestForPermissions()
953972
return false;
954973
}
955974
}
975+
976+
private string BuildTraceableAppSecret()
977+
{
978+
return string.Format("{0}...{1}", AppSecret.Substring(0, 6),
979+
AppSecret.Substring(AppSecret.Length - 6));
980+
}
956981
}
957982
}

Assets/PatchKit Patcher/Scripts/PatcherSenderId.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
using PatchKit.Unity.Patcher.AppData;
44
using PatchKit.Unity.Patcher.AppData.FileSystem;
55
using PatchKit.Unity.Patcher.Cancellation;
6+
using PatchKit.Unity.Patcher.Debug;
67
using PatchKit.Unity.Utilities;
78

89
namespace PatchKit.Unity.Patcher
910
{
1011
public class PatcherSenderId
1112
{
13+
private static readonly DebugLogger DebugLogger = new DebugLogger(typeof(PatcherSenderId));
14+
1215
private static string _senderId;
1316

1417
public static string Get()
@@ -25,7 +28,7 @@ private static string GenerateOrRead()
2528
string savedSenderId = File.ReadAllText(filePath);
2629
if (!string.IsNullOrEmpty(savedSenderId))
2730
{
28-
UnityEngine.Debug.Log("SenderId: " + savedSenderId + " (loaded from " + filePath + ")");
31+
DebugLogger.Log("SenderId: " + savedSenderId + " (loaded from " + filePath + ")");
2932

3033
return savedSenderId;
3134
}
@@ -41,7 +44,7 @@ private static string GenerateOrRead()
4144

4245
File.WriteAllText(filePath, senderId);
4346

44-
UnityEngine.Debug.Log("SenderId: " + senderId + " (saved in " + filePath + ")");
47+
DebugLogger.Log("SenderId: " + senderId + " (saved in " + filePath + ")");
4548

4649
return senderId;
4750
}

Assets/PatchKit Patcher/Scripts/PatcherStatistics.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ namespace PatchKit.Unity.Patcher
1717
{
1818
public class PatcherStatistics
1919
{
20+
private static readonly DebugLogger DebugLogger = new DebugLogger(typeof(PatcherStatistics));
21+
2022
public enum Event
2123
{
2224
[Description("content_download_started")]
@@ -201,7 +203,7 @@ public static IEnumerator SendEvent(Event ev, string appSecret, OptionalParams?
201203
request.downloadHandler = new DownloadHandlerBuffer();
202204
request.SetRequestHeader("Content-Type", "application/json");
203205

204-
UnityEngine.Debug.Log("Sending event:\n" + json.ToString(Formatting.Indented));
206+
DebugLogger.Log("Sending event:\n" + json.ToString(Formatting.Indented));
205207

206208
yield return request.Send();
207209

@@ -211,11 +213,11 @@ public static IEnumerator SendEvent(Event ev, string appSecret, OptionalParams?
211213
if (request.isError || request.responseCode != 201)
212214
#endif
213215
{
214-
UnityEngine.Debug.LogError("Failed to send event " + eventName + " (" + request.responseCode + "):\n" + request.error);
216+
DebugLogger.LogError("Failed to send event " + eventName + " (" + request.responseCode + "):\n" + request.error);
215217
}
216218
else
217219
{
218-
UnityEngine.Debug.Log("Event " + eventName + " has been sent!");
220+
DebugLogger.Log("Event " + eventName + " has been sent!");
219221
}
220222
}
221223
}

Assets/PatchKit Patcher/Scripts/UI/Changelog/ChangelogList.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
using PatchKit.Api.Models.Main;
66
using PatchKit.Unity.Patcher.AppData.Local;
77
using PatchKit.Unity.Patcher.Cancellation;
8+
using PatchKit.Unity.Patcher.Debug;
89
using PatchKit.Unity.UI;
910
using PatchKit.Unity.Utilities;
1011

1112
namespace PatchKit.Unity.Patcher.UI
1213
{
1314
public class ChangelogList : UIApiComponent
1415
{
16+
private static readonly DebugLogger DebugLogger = new DebugLogger(typeof(ChangelogList));
17+
1518
public ChangelogElement TitlePrefab;
1619

1720
public ChangelogElement ChangePrefab;
@@ -67,7 +70,7 @@ private void CreateAndCacheChangelog(string appSecret, AppVersion[] versions)
6770
}
6871
catch (Exception e)
6972
{
70-
UnityEngine.Debug.Log(e.ToString());
73+
DebugLogger.Log(e.ToString());
7174
}
7275

7376
CreateChangelog(versions);

Assets/PatchKit Patcher/Scripts/Version.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public static class Version
44
{
55
public const int Major = 3;
66
public const int Minor = 17;
7-
public const int Patch = 2;
7+
public const int Patch = 3;
88
public const int Hotfix = 0;
99

1010
public static string Value

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [3.17.3.0]
8+
### Added
9+
- Filtering the secret in the patcher logs (#2040)
10+
711
## [3.17.2.0]
812
### Added
913
- Attempting to repair content on failed installation

0 commit comments

Comments
 (0)