Esempio n. 1
0
 internal IndentToken(MyLog log, LoggingOptions options)
 {
     Debug.Assert(log != null);
     m_log = log;
     m_options = options;
     m_log.IncreaseIndent(options);
 }
Esempio n. 2
0
        private void Disable()
        {
            oldLogResponses = AWSConfigs.LoggingConfig.LogResponses;
            AWSConfigs.LoggingConfig.LogResponses = ResponseLoggingOption.Never;

            oldLogMetrics = AWSConfigs.LoggingConfig.LogMetrics;
            AWSConfigs.LoggingConfig.LogMetrics = false;

            oldLogTo = AWSConfigs.LoggingConfig.LogTo;
            AWSConfigs.LoggingConfig.LogTo = LoggingOptions.None;
        }
Esempio n. 3
0
        public void Configure(IApplicationBuilder app, IApplicationEnvironment env)
        {
            var certFile = env.ApplicationBasePath + "\\idsrv3test.pfx";

            var test = Clients.HeaderFormatExample();

            app.Map("/core", core =>
            {
                var factory = InMemoryFactory.Create(Users.Get(), Clients.Get(), Scopes.Get());
                var loggingOptions = new LoggingOptions();
                loggingOptions.EnableHttpLogging = true;
                loggingOptions.IncludeSensitiveDataInLogs = true;
                LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());

                var idsrvOptions = new IdentityServerOptions
                {
                    LoggingOptions = loggingOptions,
                    Factory = factory,
                    RequireSsl = false,
                    SigningCertificate = new X509Certificate2(certFile, "idsrv3test"),
                    CorsPolicy = CorsPolicy.AllowAll
                };
                core.UseIdentityServer(idsrvOptions);
            });

            app.Map("/api", api =>
            {
                api.UseOAuthBearerAuthentication(options =>
                    {
                        options.AutomaticAuthentication = true;
                        options.Authority = "http://localhost:35718/core/connect/authorize";
                        options.MetadataAddress = "http://localhost:35718/core/.well-known/openid-configuration";
                        options.TokenValidationParameters.ValidAudience = "http://localhost:35718/core/resources";
                    });

                api.UseMvc();
            });

            app.UseStaticFiles();
            app.UseErrorPage(ErrorPageOptions.ShowAll);
        }
Esempio n. 4
0
            protected TestModelBuilder(TestHelpers testHelpers)
            {
                Log = new List <(LogLevel, EventId, string)>();
                var options = new LoggingOptions();

                options.Initialize(new DbContextOptionsBuilder().EnableSensitiveDataLogging(false).Options);
                var validationLogger = new DiagnosticsLogger <DbLoggerCategory.Model.Validation>(
                    new ListLoggerFactory(Log, l => l == DbLoggerCategory.Model.Validation.Name),
                    options,
                    new DiagnosticListener("Fake"));
                var modelLogger = new DiagnosticsLogger <DbLoggerCategory.Model>(
                    new ListLoggerFactory(Log, l => l == DbLoggerCategory.Model.Name),
                    options,
                    new DiagnosticListener("Fake"));

                var contextServices = testHelpers.CreateContextServices();

                ModelBuilder = new ModelBuilder(new CompositeConventionSetBuilder(contextServices.GetRequiredService <IEnumerable <IConventionSetBuilder> >().ToList())
                                                .AddConventions(new CoreConventionSetBuilder(
                                                                    contextServices.GetRequiredService <CoreConventionSetBuilderDependencies>().With(modelLogger))
                                                                .CreateConventionSet()));

                ModelValidator = new ModelValidator(new ModelValidatorDependencies(validationLogger, modelLogger));
            }
Esempio n. 5
0
        private void ConfigureLoggers()
        {
            LoggingOptions logging = AWSConfigs.LoggingConfig.LogTo;

            foreach (InternalLogger il in loggers)
            {
                if (il is InternalLog4netLogger)
                {
                    il.IsEnabled = (logging & LoggingOptions.Log4Net) == LoggingOptions.Log4Net;
                }
#if BCL
                if (il is InternalSystemDiagnosticsLogger)
                {
                    il.IsEnabled = (logging & LoggingOptions.SystemDiagnostics) == LoggingOptions.SystemDiagnostics;
                }
#endif
#if PCL
                if (il is InternalConsoleLogger)
                {
                    il.IsEnabled = (logging & LoggingOptions.SystemDiagnostics) == LoggingOptions.SystemDiagnostics;
                }
#endif
            }
        }
Esempio n. 6
0
        public override void Convert(Stream input, IResultLogWriter output, LoggingOptions loggingOptions)
        {
            input = input ?? throw new ArgumentNullException(nameof(input));

            output = output ?? throw new ArgumentNullException(nameof(output));

            output.Initialize(id: null, automationId: null);

            TSLintLog tsLintLog = logReader.ReadLog(input);

            Tool tool = new Tool
            {
                Name = "TSLint"
            };

            output.WriteTool(tool);

            var results = new List <Result>();

            foreach (TSLintLogEntry entry in tsLintLog)
            {
                results.Add(CreateResult(entry));
            }

            var fileInfoFactory = new FileInfoFactory(MimeType.DetermineFromFileExtension, loggingOptions);
            Dictionary <string, FileData> fileDictionary = fileInfoFactory.Create(results);

            if (fileDictionary?.Any() == true)
            {
                output.WriteFiles(fileDictionary);
            }

            output.OpenResults();
            output.WriteResults(results);
            output.CloseResults();
        }
Esempio n. 7
0
        private void ConfigureLoggers()
        {
            LoggingOptions logging = AWSConfigs.LoggingConfig.LogTo;

            foreach (InternalLogger il in loggers)
            {
                if (il is InternalLog4netLogger)
                {
                    il.IsEnabled = (logging & LoggingOptions.Log4Net) == LoggingOptions.Log4Net;
                }
#if BCL
                if (il is InternalSystemDiagnosticsLogger)
                {
                    il.IsEnabled = (logging & LoggingOptions.SystemDiagnostics) == LoggingOptions.SystemDiagnostics;
                }
#endif
#if UNITY
                if (il is UnityDebugLogger)
                {
                    il.IsEnabled = (logging & LoggingOptions.UnityLogger) == LoggingOptions.UnityLogger;
                }
#endif
#if __ANDROID__ || __IOS__
                if (il is InternalConsoleLogger)
                {
                    il.IsEnabled = (logging & LoggingOptions.SystemDiagnostics) == LoggingOptions.SystemDiagnostics;
                }
#endif
#if PCL
                if (il is InternalFileLogger)
                {
                    il.IsEnabled = (logging & LoggingOptions.File) == LoggingOptions.File;
                }
#endif
            }
        }
Esempio n. 8
0
        private static LoggingOptions GetLoggingSetting()
        {
            string value = GetConfig(LoggingKey);

            if (string.IsNullOrEmpty(value))
            {
                return(LoggingOptions.None);
            }

            string[] settings = value.Split(validSeparators, StringSplitOptions.RemoveEmptyEntries);
            if (settings == null || settings.Length == 0)
            {
                return(LoggingOptions.None);
            }

            LoggingOptions totalSetting = LoggingOptions.None;

            foreach (string setting in settings)
            {
                LoggingOptions l = ParseEnum <LoggingOptions>(setting);
                totalSetting |= l;
            }
            return(totalSetting);
        }
Esempio n. 9
0
        /// <summary>
        /// Осуществляет перечисление сборок в папке <see cref="LibraryDirectory"/>.
        /// </summary>
        /// <param name="callbackAfterLoad">Если задано, то вызывается для сборки, если callbackBeforeLoad не задано или возвратило true.</param>
        /// <param name="callbackBeforeLoad">Если задано, то вызывается для каждой найденной сборки. Если возвращает false, то обработка этоЙ сборки прекращается.</param>
        /// <param name="enumerateAttrs">Указывает, какие библиотеки следует включить в перечисление.</param>
        /// <param name="nameForLogging"></param>
        /// <param name="tasksAllowed"></param>
        public static void Enumerate(Action <Assembly> callbackAfterLoad, Func <string, bool> callbackBeforeLoad = null, EnumerateAttrs enumerateAttrs = EnumerateAttrs.ExcludeMicrosoft | EnumerateAttrs.ExcludeSystem, string nameForLogging = null, bool tasksAllowed = false)
        {
            var measure = new MeasureTime();

            try
            {
                var dddddd = new Reflection.LibraryEnumerator(callbackAfterLoad, callbackBeforeLoad, enumerateAttrs, GlobalAssemblyFilter, LoggingOptions, nameForLogging, tasksAllowed);
                dddddd.Enumerate();
            }
            catch (Exception)
            {
            }
            finally
            {
                if (!_isFirstFullEnumeration)
                {
                    _isFirstFullEnumeration = true;
                    if (LoggingOptions.HasFlag(eLoggingOptions.EnumerationSummaryFirstRun))
                    {
                        Debug.WriteLine("LibraryEnumeratorFactory.Enumerate: First enumeration ends with {0}ms", measure.Calculate().TotalMilliseconds);
                    }
                }
            }
        }
Esempio n. 10
0
            protected TestModelBuilder(TestHelpers testHelpers)
            {
                var options = new LoggingOptions();

                options.Initialize(new DbContextOptionsBuilder().EnableSensitiveDataLogging(false).Options);
                ValidationLoggerFactory = new ListLoggerFactory(l => l == DbLoggerCategory.Model.Validation.Name);
                ValidationLogger        = new DiagnosticsLogger <DbLoggerCategory.Model.Validation>(
                    ValidationLoggerFactory,
                    options,
                    new DiagnosticListener("Fake"),
                    testHelpers.LoggingDefinitions,
                    new NullDbContextLogger());

                ModelLoggerFactory = new ListLoggerFactory(l => l == DbLoggerCategory.Model.Name);
                var modelLogger = new DiagnosticsLogger <DbLoggerCategory.Model>(
                    ModelLoggerFactory,
                    options,
                    new DiagnosticListener("Fake"),
                    testHelpers.LoggingDefinitions,
                    new NullDbContextLogger());

                ModelBuilder = testHelpers.CreateConventionBuilder(modelLogger, ValidationLogger);
                TestHelpers  = testHelpers;
            }
        /// <summary>Convert a Clang plist report into the SARIF format.</summary>
        /// <exception cref="ArgumentNullException">Thrown when one or more required arguments are null.</exception>
        /// <param name="input">CLang log file stream.</param>
        /// <param name="output">Result log writer.</param>
        /// <param name="loggingOptions">Logging options that configure output.</param>
        public override void Convert(Stream input, IResultLogWriter output, LoggingOptions loggingOptions)
        {
            // ToDo remove this comment after all issues are resolved.
            // Rodney is tasked with bringing Clang analyzer results into the SARIF fold.
            // Once this work is complete, he can close the following task:
            // http://twcsec-tfs01:8080/tfs/DefaultCollection/SecDevTools/_workitems#_a=edit&id=13409
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            try
            {
                XmlReaderSettings settings = new XmlReaderSettings
                {
                    IgnoreWhitespace = true,
                    DtdProcessing    = DtdProcessing.Ignore,
                    XmlResolver      = null
                };

                var results = new List <Result>();

                using (XmlReader xmlReader = XmlReader.Create(input, settings))
                {
                    xmlReader.MoveToContent();
                    xmlReader.ReadStartElement(ClangSchemaStrings.PlistName);
                    if (xmlReader.NodeType == XmlNodeType.Element)
                    {
                        using (var pListReader = xmlReader.ReadSubtree())
                        {
                            this.ReadPlist(pListReader, results);
                        }
                    }
                }

                var tool = new Tool
                {
                    Name = "Clang"
                };

                var fileInfoFactory = new FileInfoFactory(MimeType.DetermineFromFileExtension, loggingOptions);
                Dictionary <string, FileData> fileDictionary = fileInfoFactory.Create(results);

                output.Initialize(id: null, automationId: null);

                output.WriteTool(tool);
                if (fileDictionary != null && fileDictionary.Count > 0)
                {
                    output.WriteFiles(fileDictionary);
                }

                output.OpenResults();
                output.WriteResults(results);
                output.CloseResults();
            }
            finally
            {
                _files = null;
            }
        }
Esempio n. 12
0
 public LogCastModule(LoggingOptions options)
     : base(options)
 {
 }
Esempio n. 13
0
 public bool LogFlag(LoggingOptions option)
 {
     return((m_loggingOptions & option) != 0);
 }
Esempio n. 14
0
        private void ValidateLoggerForExclusiveOption(SarifLogger logger, LoggingOptions loggingOptions)
        {
            switch (loggingOptions)
            {
            case LoggingOptions.None:
            {
                logger.ComputeFileHashes.Should().BeFalse();
                logger.OverwriteExistingOutputFile.Should().BeFalse();
                logger.PersistEnvironment.Should().BeFalse();
                logger.PersistFileContents.Should().BeFalse();
                logger.PrettyPrint.Should().BeFalse();
                logger.Verbose.Should().BeFalse();
                break;
            }

            case LoggingOptions.ComputeFileHashes:
            {
                logger.ComputeFileHashes.Should().BeTrue();
                logger.OverwriteExistingOutputFile.Should().BeFalse();
                logger.PersistEnvironment.Should().BeFalse();
                logger.PersistFileContents.Should().BeFalse();
                logger.PrettyPrint.Should().BeFalse();
                logger.Verbose.Should().BeFalse();
                break;
            }

            case LoggingOptions.OverwriteExistingOutputFile:
            {
                logger.ComputeFileHashes.Should().BeFalse();
                logger.OverwriteExistingOutputFile.Should().BeTrue();
                logger.PersistEnvironment.Should().BeFalse();
                logger.PersistFileContents.Should().BeFalse();
                logger.PrettyPrint.Should().BeFalse();
                logger.Verbose.Should().BeFalse();
                break;
            }

            case LoggingOptions.PersistEnvironment:
            {
                logger.ComputeFileHashes.Should().BeFalse();
                logger.OverwriteExistingOutputFile.Should().BeFalse();
                logger.PersistEnvironment.Should().BeTrue();
                logger.PersistFileContents.Should().BeFalse();
                logger.PrettyPrint.Should().BeFalse();
                logger.Verbose.Should().BeFalse();
                break;
            }

            case LoggingOptions.PersistFileContents:
            {
                logger.ComputeFileHashes.Should().BeFalse();
                logger.OverwriteExistingOutputFile.Should().BeFalse();
                logger.PersistEnvironment.Should().BeFalse();
                logger.PersistFileContents.Should().BeTrue();
                logger.PrettyPrint.Should().BeFalse();
                logger.Verbose.Should().BeFalse();
                break;
            }

            case LoggingOptions.PrettyPrint:
            {
                logger.ComputeFileHashes.Should().BeFalse();
                logger.OverwriteExistingOutputFile.Should().BeFalse();
                logger.PersistEnvironment.Should().BeFalse();
                logger.PersistFileContents.Should().BeFalse();
                logger.PrettyPrint.Should().BeTrue();
                logger.Verbose.Should().BeFalse();
                break;
            }

            case LoggingOptions.Verbose:
            {
                logger.ComputeFileHashes.Should().BeFalse();
                logger.OverwriteExistingOutputFile.Should().BeFalse();
                logger.PersistEnvironment.Should().BeFalse();
                logger.PersistFileContents.Should().BeFalse();
                logger.PrettyPrint.Should().BeFalse();
                logger.Verbose.Should().BeTrue();
                break;
            }

            case LoggingOptions.All:
            {
                logger.ComputeFileHashes.Should().BeTrue();
                logger.OverwriteExistingOutputFile.Should().BeTrue();
                logger.PersistEnvironment.Should().BeTrue();
                logger.PersistFileContents.Should().BeTrue();
                logger.PrettyPrint.Should().BeTrue();
                logger.Verbose.Should().BeTrue();
                break;
            }

            default:
            {
                throw new ArgumentException();
            }
            }
        }
Esempio n. 15
0
 public IndentToken IndentUsing(LoggingOptions options = LoggingOptions.NONE)
 {
     return new IndentToken(this, options);
 }
Esempio n. 16
0
 public static bool Includes(this LoggingOptions loggingOptions, LoggingOptions otherLoggingOptions)
 {
     return((loggingOptions & otherLoggingOptions) == otherLoggingOptions);
 }
Esempio n. 17
0
 public bool LogFlag(LoggingOptions option)
 {
     return (m_loggingOptions & option) != 0;
 }
Esempio n. 18
0
 public void WriteLine(string message, LoggingOptions option)
 {
     WriteLine(message);
 }
Esempio n. 19
0
        private void InitializeTasks()
        {
            long               a0 = CensusPackage.CertificateContext;
            X509Certificate    a1 = CensusPackage.CertificateObject;
            bool               a2 = CensusPackage.CheckSignatureOnLoad;
            string             a3 = CensusPackage.CheckpointFileName;
            DTSCheckpointUsage a4 = CensusPackage.CheckpointUsage;
            Configurations     a5 = CensusPackage.Configurations;
            DateTime           a6 = CensusPackage.CreationDate;
            string             a7 = CensusPackage.CreatorComputerName;
            string             a8 = CensusPackage.CreatorName;
            Connections        a9 = CensusPackage.Connections;
            IDTSEvents         b0 = CensusPackage.DesignEvents;
            string             b1 = CensusPackage.DesignTimeProperties;
            string             b2 = CensusPackage.DumpDescriptor;
            bool               b3 = CensusPackage.DumpOnAnyError;
            bool               b4 = CensusPackage.EnableConfigurations;
            bool               b5 = CensusPackage.EnableDump;
            bool               b6 = CensusPackage.EncryptCheckpoints;
            DtsErrors          b7 = CensusPackage.Errors;
            Executables        b8 = CensusPackage.Executables;
            ExtendedProperties b9 = CensusPackage.ExtendedProperties;
            bool               c0 = CensusPackage.FailPackageOnFailure;
            bool               c1 = CensusPackage.HasExpressions;
            bool               c2 = CensusPackage.IgnoreConfigurationsOnLoad;
            bool               c3 = CensusPackage.InteractiveMode;
            LogProviders       c4 = CensusPackage.LogProviders;
            int  c5 = CensusPackage.MaxConcurrentExecutables;
            bool c6 = CensusPackage.OfflineMode;

            //var c7 = CensusPackage.PackagePassword;
            DTSPriorityClass      c8 = CensusPackage.PackagePriorityClass;
            DTSPackageType        c9 = CensusPackage.PackageType;
            PackageUpgradeOptions d0 = CensusPackage.PackageUpgradeOptions;
            Parameters            d1 = CensusPackage.Parameters;
            PrecedenceConstraints d2 = CensusPackage.PrecedenceConstraints;
            IDTSProject100        d3 = CensusPackage.Project;
            DtsProperties         d4 = CensusPackage.Properties;
            DTSProtectionLevel    d5 = CensusPackage.ProtectionLevel;
            bool                 d6  = CensusPackage.SafeRecursiveProjectPackageExecution;
            bool                 d7  = CensusPackage.SaveCheckpoints;
            bool                 d8  = CensusPackage.SuppressConfigurationWarnings;
            bool                 d9  = CensusPackage.UpdateObjects;
            int                  e0  = CensusPackage.VersionBuild;
            string               e1  = CensusPackage.VersionComments;
            string               e2  = CensusPackage.VersionGUID;
            int                  e3  = CensusPackage.VersionMajor;
            int                  e4  = CensusPackage.VersionMinor;
            DtsWarnings          e5  = CensusPackage.Warnings;
            string               e6  = CensusPackage.CreationName;
            bool                 e7  = CensusPackage.DebugMode;
            bool                 e8  = CensusPackage.DelayValidation;
            string               e9  = CensusPackage.Description;
            bool                 f0  = CensusPackage.Disable;
            bool                 f1  = CensusPackage.DisableEventHandlers;
            DtsEventHandlers     f2  = CensusPackage.EventHandlers;
            EventInfos           f3  = CensusPackage.EventInfos;
            int                  f4  = CensusPackage.ExecutionDuration;
            DTSExecResult        f5  = CensusPackage.ExecutionResult;
            DTSExecStatus        f6  = CensusPackage.ExecutionStatus;
            bool                 f7  = CensusPackage.FailParentOnFailure;
            bool                 f8  = CensusPackage.FailParentOnFailure;
            Variables            f9  = CensusPackage.Variables;
            VariableDispenser    g0  = CensusPackage.VariableDispenser;
            DTSTransactionOption g1  = CensusPackage.TransactionOption;
            bool                 g2  = CensusPackage.SuspendRequired;
            DateTime             g3  = CensusPackage.StopTime;
            DateTime             g4  = CensusPackage.StartTime;
            ISite                g5  = CensusPackage.Site;
            DtsContainer         g6  = CensusPackage.Parent;
            string               g7  = CensusPackage.Name;
            int                  g8  = CensusPackage.MaximumErrorCount;
            LoggingOptions       g9  = CensusPackage.LoggingOptions;
            DTSLoggingMode       h0  = CensusPackage.LoggingMode;
            LogEntryInfos        h1  = CensusPackage.LogEntryInfos;
            int                  h2  = CensusPackage.LocaleID;
            IsolationLevel       h3  = CensusPackage.IsolationLevel;
            bool                 h4  = CensusPackage.IsDefaultLocaleID;
            string               h5  = CensusPackage.ID;
            object               h6  = CensusPackage.ForcedExecutionValue;
            bool                 h7  = CensusPackage.ForceExecutionValue;
            DTSForcedExecResult  h8  = CensusPackage.ForceExecutionResult;

            Console.WriteLine();
        }
Esempio n. 20
0
 public ReformattingVisitor(LoggingOptions loggingOptions)
 {
     _loggingOptions = loggingOptions;
 }
Esempio n. 21
0
        public int Run(ConvertOptions convertOptions, IFileSystem fileSystem = null)
        {
            if (fileSystem == null)
            {
                fileSystem = new FileSystem();
            }

            try
            {
                if (string.IsNullOrEmpty(convertOptions.OutputFilePath))
                {
                    convertOptions.OutputFilePath = convertOptions.InputFilePath + SarifConstants.SarifFileExtension;
                }

                if (fileSystem.DirectoryExists(convertOptions.OutputFilePath))
                {
                    Console.Error.WriteLine(
                        string.Format(
                            CultureInfo.CurrentCulture,
                            "The output path '{0}' is a directory.",
                            convertOptions.OutputFilePath));
                    return(FAILURE);
                }

                if (!ValidateOptions(convertOptions, fileSystem))
                {
                    return(FAILURE);
                }

                LoggingOptions loggingOptions = LoggingOptions.None;

                OptionallyEmittedData dataToInsert = convertOptions.DataToInsert.ToFlags();

                if (convertOptions.PrettyPrint)
                {
                    loggingOptions |= LoggingOptions.PrettyPrint;
                }
                ;

                if (convertOptions.Force)
                {
                    loggingOptions |= LoggingOptions.OverwriteExistingOutputFile;
                }
                ;

                new ToolFormatConverter().ConvertToStandardFormat(
                    convertOptions.ToolFormat,
                    convertOptions.InputFilePath,
                    convertOptions.OutputFilePath,
                    loggingOptions,
                    dataToInsert,
                    convertOptions.PluginAssemblyPath);

                if (convertOptions.NormalizeForGitHubDsp)
                {
                    SarifLog sarifLog;

                    JsonSerializer serializer = new JsonSerializer()
                    {
                        Formatting = convertOptions.PrettyPrint ? Formatting.Indented : 0,
                    };

                    using (JsonTextReader reader = new JsonTextReader(new StreamReader(convertOptions.OutputFilePath)))
                    {
                        sarifLog = serializer.Deserialize <SarifLog>(reader);
                    }

                    var visitor = new GitHubDspIngestionVisitor();
                    visitor.VisitSarifLog(sarifLog);

                    using (FileStream stream = File.Create(convertOptions.OutputFilePath))
                        using (StreamWriter streamWriter = new StreamWriter(stream))
                            using (JsonTextWriter writer = new JsonTextWriter(streamWriter))
                            {
                                serializer.Serialize(writer, sarifLog);
                            }
                }
            }
            catch (Exception ex) when(!Debugger.IsAttached)
            {
                Console.WriteLine(ex);
                return(FAILURE);
            }

            return(SUCCESS);
        }
Esempio n. 22
0
        public int Run(ConvertOptions convertOptions, IFileSystem fileSystem = null)
        {
            if (fileSystem == null)
            {
                fileSystem = new FileSystem();
            }

            try
            {
                if (string.IsNullOrEmpty(convertOptions.OutputFilePath))
                {
                    convertOptions.OutputFilePath = convertOptions.InputFilePath + ".sarif";
                }

                if (fileSystem.DirectoryExists(convertOptions.OutputFilePath))
                {
                    Console.Error.WriteLine(
                        string.Format(
                            CultureInfo.CurrentCulture,
                            "The output path '{0}' is a directory.",
                            convertOptions.OutputFilePath));
                    return(FAILURE);
                }

                if (!ValidateOptions(convertOptions, fileSystem))
                {
                    return(FAILURE);
                }

                LoggingOptions loggingOptions = LoggingOptions.None;

                OptionallyEmittedData dataToInsert = convertOptions.DataToInsert.ToFlags();

                if (convertOptions.PrettyPrint)
                {
                    loggingOptions |= LoggingOptions.PrettyPrint;
                }
                ;

                if (convertOptions.Force)
                {
                    loggingOptions |= LoggingOptions.OverwriteExistingOutputFile;
                }
                ;

                new ToolFormatConverter().ConvertToStandardFormat(
                    convertOptions.ToolFormat,
                    convertOptions.InputFilePath,
                    convertOptions.OutputFilePath,
                    loggingOptions,
                    dataToInsert,
                    convertOptions.PluginAssemblyPath);
            }
            catch (Exception ex) when(!Debugger.IsAttached)
            {
                Console.WriteLine(ex);
                return(FAILURE);
            }

            return(SUCCESS);
        }
Esempio n. 23
0
 /// <summary>
 /// Initializes a new instance of <see cref="HttpMessageInspector"/> class with the provided logging options
 /// </summary>
 public HttpMessageInspector(LoggingOptions options) : base(options)
 {
 }
Esempio n. 24
0
 private bool HasLoggingOptions(LoggingOptions loggingOptionsToCheckFor)
 {
     return((m_LoggingOptions & loggingOptionsToCheckFor) != 0);
 }
Esempio n. 25
0
        public void Filters_KestrelApplicationEvent_WithException_Filtered()
        {
            var sut = new LoggingOptions();

            Assert.Contains(sut.Filters, f => f.Filter("Microsoft.AspNetCore.Server.Kestrel", LogLevel.Critical, 13, new Exception()));
        }
Esempio n. 26
0
 public void IncreaseIndent(LoggingOptions option)
 {
     if (LogFlag(option))
     {
         IncreaseIndent();
     }
 }
 public LoggingActivityBuilder(ILoggingTarget target, string name, LoggingLevel level, LoggingOptions options)
 {
     _target  = target;
     _name    = name;
     _level   = level;
     _options = options;
 }
Esempio n. 28
0
        private static string GetLogFilePath(IHostEnvironment env, LoggingOptions options)
        {
            var defaultPath = env.IsDevelopment() ? $"{env.ContentRootPath}\\logs" : "C:\\logs";

            return(options.LogsPathSet ? options.LogsPath : defaultPath);
        }
Esempio n. 29
0
 public void WriteLine(string message, LoggingOptions option)
 {
     WriteLine(message);
 }
Esempio n. 30
0
 public abstract void Convert(Stream input, IResultLogWriter output, LoggingOptions loggingOptions);
Esempio n. 31
0
        /// <summary>
        /// Creates a new <Typ>ExecuteNavigator</Typ> object in memory and its representation in the database.
        /// </summary>
        /// <param name="store">A <Typ>LearningStore</Typ> object that references the database to use.</param>
        /// <param name="rootActivityId">The database identifier for the root activity (i.e. organization) of the activity tree to attempt.</param>
        /// <param name="learnerId">The database identifier for the learner information.</param>
        /// <param name="learnerAssignmentId">The database identifier for the learner assignment information. Only used in SLK.</param>
        /// <param name="loggingFlags">Flags specifying which actions to log.</param>
        /// <returns>A new <Typ>ExecuteNavigator</Typ> object.</returns>
        /// <exception cref="LearningStoreItemNotFoundException">Thrown if the learner ID or root activity ID is invalid, or if the package information cannot be found.</exception>
        static public ExecuteNavigator CreateExecuteNavigator(LearningStore store, long rootActivityId, long learnerId, long learnerAssignmentId, LoggingOptions loggingFlags)
        {
            ExecuteNavigator eNav = new ExecuteNavigator();

            LearningStoreJob job = store.CreateJob();

            // first add security
            Dictionary <string, object> securityParameters = new Dictionary <string, object>();

            securityParameters[Schema.CreateAttemptRight.RootActivityId] =
                new LearningStoreItemIdentifier(Schema.ActivityPackageItem.ItemTypeName, rootActivityId);
            securityParameters[Schema.CreateAttemptRight.LearnerId] =
                new LearningStoreItemIdentifier(Schema.UserItem.ItemTypeName, learnerId);
            job.DemandRight(Schema.CreateAttemptRight.RightName, securityParameters);
            job.DisableFollowingSecurityChecks();

            // first query for all information about the learner
            LearningStoreQuery query = store.CreateQuery(Schema.UserItem.ItemTypeName);

            query.AddColumn(Schema.UserItem.Id);
            query.AddColumn(Schema.UserItem.Name);
            query.AddColumn(Schema.UserItem.Language);
            query.AddColumn(Schema.UserItem.AudioCaptioning);
            query.AddColumn(Schema.UserItem.AudioLevel);
            query.AddColumn(Schema.UserItem.DeliverySpeed);
            query.AddCondition(Schema.UserItem.Id, LearningStoreConditionOperator.Equal,
                               new LearningStoreItemIdentifier(Schema.UserItem.ItemTypeName, learnerId));
            job.PerformQuery(query);

            // then query the package information
            query = store.CreateQuery(Schema.SeqNavActivityPackageView.ViewName);
            LearningStoreItemIdentifier rootId = new LearningStoreItemIdentifier(Schema.ActivityPackageItem.ItemTypeName, rootActivityId);

            query.AddColumn(Schema.SeqNavActivityPackageView.PackageId);
            query.AddColumn(Schema.SeqNavActivityPackageView.PackageFormat);
            query.AddColumn(Schema.SeqNavActivityPackageView.PackagePath);
            query.AddCondition(Schema.SeqNavActivityPackageView.Id, LearningStoreConditionOperator.Equal, rootId);
            job.PerformQuery(query);

            // then query for the activity tree
            query = store.CreateQuery(Schema.SeqNavActivityTreeView.ViewName);
            query.AddColumn(Schema.SeqNavActivityTreeView.DataModelCache);
            query.AddColumn(Schema.SeqNavActivityTreeView.ParentActivityId);
            query.AddColumn(Schema.SeqNavActivityTreeView.Id);
            query.AddColumn(Schema.SeqNavActivityTreeView.ObjectivesGlobalToSystem);
            query.AddCondition(Schema.SeqNavActivityTreeView.RootActivityId, LearningStoreConditionOperator.Equal, new LearningStoreItemIdentifier(Schema.ActivityPackageItem.ItemTypeName, rootActivityId));
            job.PerformQuery(query);

            DataTable d;  // used to store results of query
            ReadOnlyCollection <object> ids;

            // for this transaction we need to read from the activitypackageitem table and write new records to
            // the activityattemptitem and attemptitem tables
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.RepeatableRead;
            using (LearningStoreTransactionScope scope = new LearningStoreTransactionScope(options))
            {
                // execute the query
                ReadOnlyCollection <object> c = job.Execute();
                Utilities.Assert(c.Count == 3);

                if (((DataTable)c[0]).Rows.Count < 1)
                {
                    throw new LearningStoreItemNotFoundException(Resources.InvalidLearnerId);
                }
                if (((DataTable)c[1]).Rows.Count < 1)
                {
                    throw new LearningStoreItemNotFoundException(Resources.InvalidRootActivityId);
                }
                if (((DataTable)c[2]).Rows.Count < 1)
                {
                    throw new LearningStoreItemNotFoundException(Resources.InvalidRootActivityId);
                }

                d = (DataTable)c[0];  // save learner information

                string          learnerName          = (string)d.Rows[0][Schema.UserItem.Name];
                AudioCaptioning learnerCaption       = (AudioCaptioning)d.Rows[0][Schema.UserItem.AudioCaptioning];
                float           learnerAudioLevel    = (float)d.Rows[0][Schema.UserItem.AudioLevel];
                float           learnerDeliverySpeed = (float)d.Rows[0][Schema.UserItem.DeliverySpeed];
                string          learnerLanguage      = (string)d.Rows[0][Schema.UserItem.Language];

                d = (DataTable)c[1];  // save package information

                // we need to create the activity tree within the transaction because it may affect the data written
                // by means of the selection and randomization processes.

                eNav.m_packageFormat   = (PackageFormat)d.Rows[0][Schema.SeqNavActivityPackageView.PackageFormat];
                eNav.m_packageId       = ((LearningStoreItemIdentifier)d.Rows[0][Schema.SeqNavActivityPackageView.PackageId]).GetKey();
                eNav.m_packageLocation = (string)d.Rows[0][Schema.SeqNavActivityPackageView.PackagePath];
                eNav.m_store           = store;
                eNav.m_learnerId       = learnerId;
                eNav.m_loggingFlags    = loggingFlags;

                // we must set this here so that the Activity  constructor doesn't try and load missing info
                eNav.m_attemptItemInformationIsValid = true;

                d = (DataTable)c[2];  // save data to create activity tree later, when we are done with sql processing

                eNav.AddActivities(d, rootActivityId, learnerName, learnerLanguage, learnerCaption, learnerAudioLevel, learnerDeliverySpeed);

                /*
                 * // create activity objects and store them in a big dictionary
                 * foreach(DataRow row in d.Rows)
                 * {
                 *  Activity act = new Activity(eNav, ((LearningStoreItemIdentifier)row[Schema.SeqNavActivityTreeView.Id]).GetKey(),
                 *      ConvertLearningStoreXmlToXPathNavigator(row[Schema.SeqNavActivityTreeView.DataModelCache] as LearningStoreXml, true),
                 *      null, null, null, eNav.WrapAttachment, eNav.WrapAttachmentGuid, -1,
                 *      (bool)row[Schema.SeqNavActivityTreeView.ObjectivesGlobalToSystem], eNav.m_learnerId.ToString(System.Globalization.CultureInfo.InvariantCulture),
                 *      learnerName, learnerLanguage, learnerCaption, learnerAudioLevel, learnerDeliverySpeed);
                 *  eNav.m_activities[act.ActivityId] = act;
                 *  if(act.ActivityId == rootActivityId)
                 *  {
                 *      eNav.RootActivity = act;
                 *      if(!(row[Schema.SeqNavActivityTreeView.ParentActivityId] is DBNull))
                 *      {
                 *          throw new LearningStoreItemNotFoundException(Resources.InvalidRootActivityId);
                 *      }
                 *  }
                 * }
                 *
                 * // now that we have all the activities in a big dictionary, find all the parents to build the tree
                 * // in theory this could be done in the first loop if I sort the query by parentid, but that's making a lot
                 * // of assumptions about the structure of the database that I don't think are safe to make
                 * foreach(DataRow row in d.Rows)
                 * {
                 *  LearningStoreItemIdentifier parentId = row[Schema.SeqNavActivityTreeView.ParentActivityId] as LearningStoreItemIdentifier;
                 *  if (parentId != null)
                 *  {
                 *      long id = ((LearningStoreItemIdentifier)row[Schema.SeqNavActivityTreeView.Id]).GetKey();
                 *      eNav.m_activities[id].Parent = eNav.m_activities[parentId.GetKey()];
                 *      eNav.m_activities[parentId.GetKey()].AddChild(eNav.m_activities[id]);
                 *  }
                 * }
                 *
                 * // make sure children of each parent are in the right order, and set Previous and Next pointer correctly.
                 * eNav.SortActivityTree();
                 *
                 * // step through the activity tree searching for selection and randomization instructions
                 * // this must be done before the ActivityAttemptItems are saved because they may reorder
                 * // and potentially even remove children.
                 * Random rand = new Random();
                 * foreach(Activity a in eNav.Traverse)
                 * {
                 *  if(!a.IsLeaf)
                 *  {
                 *      // if there's a valid selection instruction, remove excess
                 *      // child activities randomly
                 *      if(a.Sequencing.SelectionTiming == RandomizationTiming.Once &&
                 *          a.Sequencing.RandomizationSelectCount > 0 &&
                 *          a.Sequencing.RandomizationSelectCount < a.Children.Count)
                 *      {
                 *          int selCount = a.Sequencing.RandomizationSelectCount;
                 *          for(int i = 0 ; i < a.Children.Count ; ++i)
                 *          {
                 *              if(rand.Next(a.Children.Count) < selCount)
                 *              {
                 *                  --selCount;
                 *              }
                 *              else
                 *              {
                 *                  a.RemoveChild(i);
                 *              }
                 *          }
                 *          a.SortChildren();
                 *      }
                 *
                 *      // if there's a valid randomization instruction, randomize order of the children
                 *      // of this activity
                 *      if((a.Sequencing.RandomizationTiming == RandomizationTiming.Once ||
                 *          a.Sequencing.RandomizationTiming == RandomizationTiming.OnEachNewAttempt) &&
                 *          a.Sequencing.ReorderChildren)
                 *      {
                 *          List<Activity> randlist = new List<Activity>();
                 *          while(a.Children.Count > 0)
                 *          {
                 *              int i = rand.Next(a.Children.Count);
                 *              randlist.Add((Activity)a.Children[i]);
                 *              a.RemoveChild(i);
                 *          }
                 *          for(int i = 0 ; i < randlist.Count ; ++i)
                 *          {
                 *              randlist[i].RandomPlacement = i;
                 *              a.AddChild(randlist[i]);
                 *          }
                 *          a.SortChildren();
                 *      }
                 *  }
                 * }
                 * */

                // create the attemptitem
                // fill in fields with no defaults
                job = store.CreateJob();
                job.DisableFollowingSecurityChecks();
                Dictionary <string, object> attempt = new Dictionary <string, object>();
                attempt[Schema.AttemptItem.RootActivityId] = new LearningStoreItemIdentifier(Schema.ActivityPackageItem.ItemTypeName, rootActivityId);
                attempt[Schema.AttemptItem.LearnerId]      = new LearningStoreItemIdentifier(Schema.UserItem.ItemTypeName, learnerId);
                if (learnerAssignmentId != 0)
                {
                    attempt[Schema.AttemptItem.LearnerAssignmentId] = new LearningStoreItemIdentifier("LearnerAssignmentItem", learnerAssignmentId);
                }
                attempt[Schema.AttemptItem.PackageId] = new LearningStoreItemIdentifier(Schema.PackageItem.ItemTypeName, eNav.m_packageId);
                eNav.m_attemptStartTime = DateTime.UtcNow;
                attempt[Schema.AttemptItem.StartedTimestamp]    = eNav.m_attemptStartTime;
                attempt[Schema.AttemptItem.LogDetailSequencing] = ((loggingFlags & LoggingOptions.LogDetailSequencing) == LoggingOptions.LogDetailSequencing);
                attempt[Schema.AttemptItem.LogFinalSequencing]  = ((loggingFlags & LoggingOptions.LogFinalSequencing) == LoggingOptions.LogFinalSequencing);
                attempt[Schema.AttemptItem.LogRollup]           = ((loggingFlags & LoggingOptions.LogRollup) == LoggingOptions.LogRollup);
                LearningStoreItemIdentifier attemptId = job.AddItem(Schema.AttemptItem.ItemTypeName, attempt, true);

                // create activityattemptitems for each activity in the tree
                foreach (Activity a in eNav.Traverse)
                {
                    Dictionary <string, object> activity = new Dictionary <string, object>();

                    // fill in everything that has no default
                    activity[Schema.ActivityAttemptItem.AttemptId]         = attemptId;
                    activity[Schema.ActivityAttemptItem.ActivityPackageId] = new LearningStoreItemIdentifier(Schema.ActivityPackageItem.ItemTypeName, a.ActivityId);
                    if (a.RandomPlacement >= 0)
                    {
                        activity[Schema.ActivityAttemptItem.RandomPlacement] = a.RandomPlacement;
                        // sibling activities are ordered by RandomPlacement first,
                        // then by OriginalPlacment; RandomPlacement is -1 for all siblings if not randomization occurs
                    }
                    job.AddItem(Schema.ActivityAttemptItem.ItemTypeName, activity, true);
                }
                ids = job.Execute();
                scope.Complete();
            }

            // fill in some vital data for the navigator
            eNav.m_attemptId = ((LearningStoreItemIdentifier)ids[0]).GetKey();
            int index = 1;

            foreach (Activity a in eNav.Traverse)
            {
                a.InternalActivityId = ((LearningStoreItemIdentifier)ids[index++]).GetKey();
            }

            return(eNav);
        }
 public override void Convert(Stream input, IResultLogWriter output, LoggingOptions loggingOptions)
 {
     throw new NotImplementedException();
 }
Esempio n. 33
0
 public RedfishLogger(ILogger <RedfishLogger> logger, IOptions <LoggingOptions> options)
 {
     _logger  = logger;
     _options = options.Value;
 }
Esempio n. 34
0
        public static bool LogFlag(LoggingOptions option)
        {
            long lValue = Convert.ToInt64(MyMwcFinalBuildConstants.LOGGING_OPTIONS);
            long lFlag = Convert.ToInt64(option);

            return (lValue & lFlag) != 0;
        }
Esempio n. 35
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="options">The <see cref="LoggingOptions"/>.</param>
 public SerilogProvider(LoggingOptions options)
 {
     this.Options = options ?? throw new ArgumentNullException(nameof(options));
 }
Esempio n. 36
0
 public LogCastModule()
     : this(LoggingOptions.Default())
 {
 }
Esempio n. 37
0
 public static void DecreaseIndent(LoggingOptions option)
 {
     if (LogFlag(option))
     {
         DecreaseIndent();
     }
 }
Esempio n. 38
0
 public IndentToken IndentUsing(LoggingOptions options = LoggingOptions.NONE)
 {
     return(new IndentToken(this, options));
 }
Esempio n. 39
0
 public static void WriteLine(string message, LoggingOptions option)
 {
     if (LogFlag(option))
     {
         WriteLine(message);
     }
 }
 public override void Convert(Stream input, IResultLogWriter output, LoggingOptions loggingOptions)
 {
 }