Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve log #643

Merged
merged 4 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog].
- Small performance improve `#641`

### Changed
- All logs passed to ErrorReport is now shown on the console log `#643`

### Deprecated

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog].
- Small performance improve `#641`

### Changed
- All logs passed to ErrorReport is now shown on the console log `#643`

### Deprecated

Expand Down
22 changes: 22 additions & 0 deletions Internal/ErrorReporter/Editor/BuildReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using JetBrains.Annotations;
using UnityEditor;
using UnityEngine;
Expand Down Expand Up @@ -102,6 +103,27 @@ internal static ErrorLog Log(ReportLevel level, string code, string[] strings, A
strings[i] = strings[i] ?? "";
var errorLog = new ErrorLog(level, code, strings, assembly);

var builder = new StringBuilder("BuildReport: ");
builder.Append(code);
foreach (var s in strings)
builder.Append(", '").Append(s).Append("'");
switch (level)
{
case ReportLevel.Validation:
case ReportLevel.Error:
case ReportLevel.InternalError:
Debug.LogError(builder.ToString());
break;
case ReportLevel.Info:
Debug.Log(builder.ToString());
break;
case ReportLevel.Warning:
Debug.LogWarning(builder.ToString());
break;
default:
throw new ArgumentOutOfRangeException(nameof(level), level, null);
}

var avatarReport = CurrentReport.CurrentAvatar;
if (avatarReport == null)
{
Expand Down
2 changes: 0 additions & 2 deletions Internal/ErrorReporter/Editor/BuildReportContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public void OnDeactivate(BuildContext context)
BuildReport.SaveReport();
if (avatar.logs.Any())
ErrorReportUI.OpenErrorReportUIFor(avatar);
else
ErrorReportUI.MaybeOpenErrorReportUI();
if (!successful) throw new Exception("Avatar processing failed");
}
}
Expand Down