Ejemplo n.º 1
0
        private static void AddCrashHandler(IDiagnosticLogger logger, string projectDir)
        {
            var crashpadPath = Path.GetFullPath(Path.Combine("Packages", SentryPackageInfo.GetName(), "Plugins",
                                                             "Windows", "Sentry", "crashpad_handler.exe"));
            var targetPath = Path.Combine(projectDir, Path.GetFileName(crashpadPath));

            logger.LogInfo("Copying the native crash handler '{0}' to the output directory", Path.GetFileName(crashpadPath));
            File.Copy(crashpadPath, targetPath, true);
        }
Ejemplo n.º 2
0
        internal bool ContainsSentry(string main, IDiagnosticLogger?logger)
        {
            if (main.Contains(Include))
            {
                logger?.LogInfo("'main.mm' already contains Sentry.");
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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();
        }