protected override async Task SerializeToStreamAsync(Stream stream, TransportContext?context) { try { await _envelope.SerializeAsync(stream, _logger).ConfigureAwait(false); } catch (Exception e) { _logger?.LogError("Failed to serialize Envelope into the network stream", e); throw; } }
/// <summary> /// Attempts to serialize /// </summary> /// <param name="value"></param> /// <param name="logger"></param> /// <returns></returns> public static string?SerializeSafely(object value, IDiagnosticLogger?logger = null) { if (value is string stringValue) { // Otherwise it'll return ""value"" return(stringValue); } try { return(JsonSerializer.Serialize(value)); } catch (Exception e) { logger?.LogError("Failed to serialize value of type \"{0}\"", e, value.GetType()); return(null); } }
private static void UploadDebugSymbols(IDiagnosticLogger logger, string projectDir, string executableName) { var cliOptions = SentryCliOptions.LoadCliOptions(); if (!cliOptions.IsValid(logger)) { return; } logger.LogInfo("Uploading debugging information using sentry-cli in {0}", projectDir); var paths = ""; Func <string, bool> addPath = (string name) => { var fullPath = Path.Combine(projectDir, name); if (Directory.Exists(fullPath) || File.Exists(fullPath)) { paths += $" \"{name}\""; logger.LogDebug($"Adding '{name}' to the debug-info upload"); return(true); } else { logger.LogWarning($"Coudn't find '{name}' - debug symbol upload will be incomplete"); return(false); } }; addPath(executableName); addPath("GameAssembly.dll"); addPath("UnityPlayer.dll"); addPath(Path.GetFileNameWithoutExtension(executableName) + "_BackUpThisFolder_ButDontShipItWithYourGame"); addPath(Path.GetFileNameWithoutExtension(executableName) + "_Data/Plugins/x86_64/sentry.dll"); // Note: using Path.GetFullPath as suggested by https://docs.unity3d.com/Manual/upm-assets.html addPath(Path.GetFullPath($"Packages/{SentryPackageInfo.GetName()}/Plugins/Windows/Sentry/sentry.pdb")); // Configure the process using the StartInfo properties. var process = new Process { StartInfo = new ProcessStartInfo { FileName = SentryCli.SetupSentryCli(), WorkingDirectory = projectDir, Arguments = "upload-dif " + paths, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true } }; 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.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); }