private void InitializeOutputFile(TOptions analyzeOptions, TContext context, ISet <string> targets)
        {
            string            filePath          = analyzeOptions.OutputFilePath;
            AggregatingLogger aggregatingLogger = (AggregatingLogger)context.Logger;

            if (!string.IsNullOrEmpty(filePath))
            {
                InvokeCatchingRelevantIOExceptions
                (
                    () =>
                {
                    LogFilePersistenceOptions logFilePersistenceOptions = analyzeOptions.ConvertToLogFilePersistenceOptions();

                    OptionallyEmittedData dataToInsert = analyzeOptions.DataToInsert.ToFlags();
                    OptionallyEmittedData dataToRemove = analyzeOptions.DataToRemove.ToFlags();

                    SarifLogger sarifLogger;

                    if (analyzeOptions.SarifOutputVersion != SarifVersion.OneZeroZero)
                    {
                        sarifLogger = new SarifLogger(
                            analyzeOptions.OutputFilePath,
                            logFilePersistenceOptions,
                            dataToInsert,
                            dataToRemove,
                            tool: _tool,
                            run: null,
                            analysisTargets: targets,
                            invocationTokensToRedact: GenerateSensitiveTokensList(),
                            invocationPropertiesToLog: analyzeOptions.InvocationPropertiesToLog,
                            levels: analyzeOptions.Level,
                            kinds: analyzeOptions.Kind);
                    }
                    else
                    {
                        sarifLogger = new SarifOneZeroZeroLogger(
                            analyzeOptions.OutputFilePath,
                            logFilePersistenceOptions,
                            dataToInsert,
                            dataToRemove,
                            tool: _tool,
                            run: null,
                            analysisTargets: targets,
                            invocationTokensToRedact: GenerateSensitiveTokensList(),
                            invocationPropertiesToLog: analyzeOptions.InvocationPropertiesToLog,
                            levels: analyzeOptions.Level,
                            kinds: analyzeOptions.Kind);
                    }
                    _pathToHashDataMap = sarifLogger.AnalysisTargetToHashDataMap;
                    sarifLogger.AnalysisStarted();
                    aggregatingLogger.Loggers.Add(sarifLogger);
                },
                    (ex) =>
                {
                    Errors.LogExceptionCreatingLogFile(context, filePath, ex);
                    ThrowExitApplicationException(context, ExitReason.ExceptionCreatingLogFile, ex);
                }
                );
            }
        }
        private void InitializeOutputFile(TOptions analyzeOptions, TContext context, HashSet <string> targets)
        {
            string            filePath          = analyzeOptions.OutputFilePath;
            AggregatingLogger aggregatingLogger = (AggregatingLogger)context.Logger;

            if (!string.IsNullOrEmpty(filePath))
            {
                InvokeCatchingRelevantIOExceptions
                (
                    () =>
                {
                    LoggingOptions loggingOptions;
                    loggingOptions = analyzeOptions.ConvertToLoggingOptions();

                    OptionallyEmittedData dataToInsert = analyzeOptions.DataToInsert.ToFlags();
                    OptionallyEmittedData dataToRemove = analyzeOptions.DataToRemove.ToFlags();

                    // This code is required in order to support the obsolete ComputeFileHashes argument
                    // on the analyze command-line.
                    if (analyzeOptions.ComputeFileHashes)
                    {
                        dataToInsert |= OptionallyEmittedData.Hashes;
                    }

                    SarifLogger sarifLogger;

                    if (analyzeOptions.SarifOutputVersion != SarifVersion.OneZeroZero)
                    {
                        sarifLogger = new SarifLogger(
                            analyzeOptions.OutputFilePath,
                            loggingOptions,
                            dataToInsert,
                            dataToRemove,
                            tool: _tool,
                            run: null,
                            analysisTargets: targets,
                            invocationTokensToRedact: GenerateSensitiveTokensList(),
                            invocationPropertiesToLog: analyzeOptions.InvocationPropertiesToLog);
                    }
                    else
                    {
                        sarifLogger = new SarifOneZeroZeroLogger(
                            analyzeOptions.OutputFilePath,
                            loggingOptions,
                            dataToInsert,
                            dataToRemove,
                            tool: _tool,
                            run: null,
                            analysisTargets: targets,
                            invocationTokensToRedact: GenerateSensitiveTokensList(),
                            invocationPropertiesToLog: analyzeOptions.InvocationPropertiesToLog);
                    }
                    _pathToHashDataMap = sarifLogger.AnalysisTargetToHashDataMap;
                    sarifLogger.AnalysisStarted();
                    aggregatingLogger.Loggers.Add(sarifLogger);
                },
                    (ex) =>
                {
                    Errors.LogExceptionCreatingLogFile(context, filePath, ex);
                    ThrowExitApplicationException(context, ExitReason.ExceptionCreatingLogFile, ex);
                }
                );
            }
        }