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

chore: update CLI to v2.2.0 #826

Merged
merged 2 commits into from
Jun 20, 2022
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
- Bump Native SDK to v0.4.18 ([#810](https://github.com/getsentry/sentry-unity/pull/810) & [#824](https://github.com/getsentry/sentry-unity/pull/824))
- [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#0418)
- [diff](https://github.com/getsentry/sentry-native/compare/0.4.15-7-g9eecb1b...0.4.18)
- Bump CLI to v2.2.0 ([#826](https://github.com/getsentry/sentry-unity/pull/826))
- [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#220)
- [diff](https://github.com/getsentry/sentry-cli/compare/1.71.0...2.2.0)

## 0.19.0

Expand Down
2 changes: 1 addition & 1 deletion scripts/download-sentry-cli.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Set-StrictMode -Version latest

$version = '1.71.0'
$version = '2.2.0'
$platforms = @('Darwin-universal', 'Linux-x86_64', 'Windows-x86_64')
$targetDir = "$PSScriptRoot/../package-dev/Editor/sentry-cli"
$baseUrl = "https://github.com/getsentry/sentry-cli/releases/download/$version/sentry-cli-"
Expand Down
27 changes: 25 additions & 2 deletions src/Sentry.Unity.Editor/Native/BuildPostProcess.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.IO;
using Sentry.Extensibility;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Callbacks;
Expand Down Expand Up @@ -181,8 +182,30 @@ private static void UploadDebugSymbols(IDiagnosticLogger logger, BuildTarget tar
process.StartInfo.EnvironmentVariables["SENTRY_ORG"] = cliOptions.Organization;
process.StartInfo.EnvironmentVariables["SENTRY_PROJECT"] = cliOptions.Project;
process.StartInfo.EnvironmentVariables["SENTRY_AUTH_TOKEN"] = cliOptions.Auth;
process.OutputDataReceived += (sender, args) => logger.LogDebug($"sentry-cli: {args.Data.ToString()}");
process.ErrorDataReceived += (sender, args) => logger.LogError($"sentry-cli: {args.Data.ToString()}");
process.StartInfo.EnvironmentVariables["SENTRY_LOG_LEVEL"] = "info";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be based on the options? If Debug=true we add it, based on the DiagnosticLevel?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We forward it through the logger (below), with the level parsed from the CLI output, and let that decide whether to print or not, depending on the configuration.


DataReceivedEventHandler logForwarder = (object sender, DataReceivedEventArgs e) =>
{
var msg = e.Data.ToString().Trim();
var msgLower = msg.ToLowerInvariant();
var level = SentryLevel.Info;
if (msgLower.StartsWith("error"))
{
level = SentryLevel.Error;
}
else if (msgLower.StartsWith("warn"))
{
level = SentryLevel.Warning;
}

// Remove the level and timestamp from the beginning of the message.
// INFO 2022-06-20 15:10:03.613794800 +02:00
msg = Regex.Replace(msg, "^[a-zA-Z]+ +[0-9\\-]{10} [0-9:]{8}\\.[0-9]+ \\+[0-9:]{5} +", "");
logger.Log(level, "sentry-cli: {0}", null, msg);
};

process.OutputDataReceived += logForwarder;
process.ErrorDataReceived += logForwarder;
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
Expand Down