private static Session RunConsole()

in JetBrains.Profiler.SelfApi/src/DotMemory.cs [329:385]


    private static Session RunConsole(string command, Config config)
    {
      Trace.Verbose("DotMemory.RunConsole: Looking for runner...");

      var runnerPath = ConsoleRunnerPackage.GetRunnerPath();

      var workspaceFile = GetSaveToFilePath(config);

      var pid = config.Pid ?? Process.GetCurrentProcess().Id;

      var commandLine = new StringBuilder();
      if (config.LogLevel != null)
        commandLine.Append($"--log-level={config.LogLevel} ");

      if (config.LogFile != null)
        commandLine.Append($"\"--log-file={config.LogFile}\" ");

      commandLine.Append($"{command} {pid} \"-f={workspaceFile}\"");

      commandLine.Append(" --service-output");

      if (config.IsOverwriteWorkspace)
        commandLine.Append(" --overwrite");

      if (config.IsOpenDotMemory)
        commandLine.Append(" --open-dotmemory");

      Func<bool> apiReadyFunc;
      if (config.DoNotUseApi)
      {
        Trace.Info("DotMemory.RunConsole: do not use API");
        apiReadyFunc = null;
      }
      else
      {
        Trace.Info("DotMemory.RunConsole: use API");
        apiReadyFunc = () => (MemoryProfiler.GetFeatures() & MemoryFeatures.Ready) == MemoryFeatures.Ready;
        commandLine.Append(" --use-api");
      }

      if (config.OtherArguments != null)
        commandLine.Append(' ').Append(config.OtherArguments);

      Trace.Info("DotMemory.RunConsole:\n  runner = `{0}`\n  arguments = `{1}`", runnerPath, commandLine);

      var consoleProfiler = new ConsoleProfiler(
        runnerPath,
        commandLine.ToString(),
        MessageServicePrefix,
        CltPresentableName,
        apiReadyFunc
        );

      Trace.Verbose("DotMemory.RunConsole: Runner started.");

      return new Session(consoleProfiler, workspaceFile, config.Timeout);
    }