Skip to content

Commit ece6d58

Browse files
committedFeb 19, 2025··
Add ignoreLogProcessJsonErrors option
1 parent cb8efa5 commit ece6d58

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
 

‎src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs

+6
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ public Resolution Resolution
195195
/// </summary>
196196
[Tooltip("The log severity. Only messages of this severity level or higher will be logged")]
197197
public LogSeverity logSeverity = LogSeverity.Info;
198+
199+
/// <summary>
200+
/// Ignores errors related to log messages from the engine process being in a non-json format
201+
/// </summary>
202+
[Tooltip("Ignores errors related to log messages from the engine process being in a non-json format")]
203+
public bool ignoreLogProcessJsonErrors = false;
198204

199205
/// <summary>
200206
/// Texture that the browser will paint to

‎src/Packages/UnityWebBrowser/Runtime/Logging/ProcessLogHandler.cs

+9
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ namespace VoltstroStudios.UnityWebBrowser.Logging
1919
public class ProcessLogHandler
2020
{
2121
private readonly IWebBrowserLogger logger;
22+
private readonly bool ignoreLogProcessJsonErrors;
2223

2324
internal ProcessLogHandler(WebBrowserClient client)
2425
{
2526
logger = client.logger;
27+
ignoreLogProcessJsonErrors = client.ignoreLogProcessJsonErrors;
2628
}
2729

2830
public event Action<string> OnProcessOutputLog;
@@ -55,6 +57,13 @@ internal void HandleOutputProcessLog(object sender, DataReceivedEventArgs e)
5557
else if (logStructure.Level == LogSeverity.Fatal)
5658
logger.Error($"[{logStructure.Category}]: {logStructure.Message}\n{logStructure.Exception}");
5759
}
60+
catch (JsonException)
61+
{
62+
if(ignoreLogProcessJsonErrors)
63+
return;
64+
65+
logger.Error($"A log message from the UWB engine was not in a JSON format!\n\nRaw Log Message:\n{e.Data}");
66+
}
5867
catch (Exception ex)
5968
{
6069
logger.Error($"An error occured with processing a log event from the UWB engine!\n\nRaw Log Message:\n{e.Data}\n\nException:\n{ex}");

0 commit comments

Comments
 (0)
Please sign in to comment.