public bool IsValid(IDiagnosticLogger?logger, bool?isDevelopmentBuild = null) { if (!UploadSymbols) { logger?.LogDebug("sentry-cli: Automated symbols upload has been disabled."); return(false); } if ((isDevelopmentBuild ?? EditorUserBuildSettings.development) && !UploadDevelopmentSymbols) { logger?.LogDebug("sentry-cli: Automated symbols upload for development builds has been disabled."); return(false); } var validated = true; if (string.IsNullOrWhiteSpace(Auth)) { MissingFieldWarning(logger, "Auth name"); validated = false; } if (string.IsNullOrWhiteSpace(Organization)) { MissingFieldWarning(logger, "Organization"); validated = false; } if (string.IsNullOrWhiteSpace(Project)) { MissingFieldWarning(logger, "Project"); validated = false; } if (!validated) { logger?.LogWarning("sentry-cli validation failed. Symbols will not be uploaded." + "\nYou can disable this warning by disabling the automated symbols upload under " + EditorMenuPath); } return(validated); }
internal static SentryCommandInterceptor?UseBreadcrumbs( IQueryLogger?queryLogger = null, bool initOnce = true, IDiagnosticLogger?diagnosticLogger = null) { if (initOnce && Interlocked.Exchange(ref Init, 1) != 0) { diagnosticLogger?.LogWarning("{0}.{1} was already executed.", nameof(SentryDatabaseLogging), nameof(UseBreadcrumbs)); return(null); } diagnosticLogger?.LogInfo("{0}.{1} adding interceptor.", nameof(SentryDatabaseLogging), nameof(UseBreadcrumbs)); queryLogger ??= new SentryQueryLogger(); var interceptor = new SentryCommandInterceptor(queryLogger); DbInterception.Add(interceptor); return(interceptor); }
private static void MissingFieldWarning(IDiagnosticLogger?logger, string name) => logger?.LogWarning("sentry-cli: {0} missing. Please set it under {1}", name, EditorMenuPath);
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(); }