Exemple #1
0
        private static bool TrySetupFileLogger()
        {
            try
            {
                var filenameBaseInfo = new DatadogEnvironmentFileLogSinkFactory.FilenameBaseInfo(ProductFamily, Product, ComponentGroup);
                if (DatadogEnvironmentFileLogSinkFactory.TryCreateNewFileLogSink(filenameBaseInfo,
                                                                                 LoggingDemoLogGroupId,
                                                                                 preferredLogFileDirectory: null,
                                                                                 LogFileSizeBytes,
                                                                                 formatOptions: null,
                                                                                 out FileLogSink fileLogSink))
                {
                    RedirectLogs(fileLogSink, out s_logRedirections);
                    LogComposer.SetDebugLoggingEnabledBasedOnEnvironment();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                ConsoleWriteLine();
                ConsoleWriteLine($"Error setting up a file logger.");
                ConsoleWriteLine($"{ex}");
            }

            return(false);
        }
        private static bool TrySetupFileLogger()
        {
            try
            {
                var filenameBaseInfo = new DatadogEnvironmentFileLogSinkFactory.FilenameBaseInfo(ProductFamily, Product, ComponentGroup);
                if (DatadogEnvironmentFileLogSinkFactory.TryCreateNewFileLogSink(filenameBaseInfo,
                                                                                 ManagedLoaderLogGroupId,
                                                                                 preferredLogFileDirectory: null,
                                                                                 FileFormatOptions,
                                                                                 out FileLogSink fileLogSink))
                {
                    ILogSink logSink;
#pragma warning disable CS0162 // Unreachable code detected - intentional conditional using const bool
                    if (UseConsoleLogInAdditionToFileLog)
                    {
                        logSink = new AggregatedLogSink(SimpleConsoleLogSink.SingeltonInstance, fileLogSink);
                    }
                    else
                    {
                        logSink = fileLogSink;
                    }
#pragma warning restore CS0162 // Unreachable code detected

                    RedirectLogs(logSink, out s_logRedirections);
                    LogComposer.SetDebugLoggingEnabledBasedOnEnvironment();
                    return(true);
                }
            }
            catch
            { }

            return(false);
        }
Exemple #3
0
        public string Execute()
        {
            LogComposer.Clear();

            //for (var vSpaceDim = 3; vSpaceDim <= 3; vSpaceDim++)
            //{
            //    Frame = GaSymFrame.CreateEuclidean(vSpaceDim);

            //    //var randGen = new GMacRandomGenerator(10);
            //    //var mvA = randGen.GetSymbolicMultivector(Frame.GaSpaceDimension, "A");
            //    //var mvB = randGen.GetSymbolicMultivector(Frame.GaSpaceDimension, "B");
            //    var mvA = GaSymMultivector.CreateSymbolic(Frame.GaSpaceDimension, "A");
            //    var mvB = GaSymMultivector.CreateSymbolic(Frame.GaSpaceDimension, "B");

            //    var op1 = Frame.Rcp[mvA, mvB];
            //    var mv1 = mvA.ToMultivector();
            //    var mv2 = mvB.ToMultivector();

            //    var op2 = Frame.Rcp[mv1, mv2];
            //    //var diff = op1 - op2.ToHashMultivector();

            //    LogComposer
            //        .AppendHeader("Euclidean " + vSpaceDim, 2);

            //    LogComposer
            //        .AppendAtNewLine("Sparse A = ")
            //        .AppendLine(mvA.ToString());

            //    LogComposer
            //        .AppendAtNewLine("Sparse B = ")
            //        .AppendLine(mvB.ToString())
            //        .AppendLine();

            //    LogComposer
            //        .AppendAtNewLine("Tree A = ")
            //        .AppendLine(mv1.ToString());

            //    LogComposer
            //        .AppendAtNewLine("Tree B = ")
            //        .AppendLine(mv2.ToString())
            //        .AppendLine();

            //    LogComposer
            //        .AppendAtNewLine("Sparse A op B = ")
            //        .AppendLine(op1.ToString())
            //        .AppendLine();

            //    LogComposer
            //        .AppendAtNewLine("Tree A op B = ")
            //        .AppendLine(op2.ToString())
            //        .AppendLine();

            //    //LogComposer
            //    //    .AppendAtNewLine("Diff = ")
            //    //    .AppendLine(diff.ToString())
            //    //    .AppendLine();
            //}

            return(LogComposer.ToString());
        }
Exemple #4
0
        public string Execute()
        {
            LogComposer.Clear();

            var randGen = new GMacRandomGenerator(10);
            var mvList  = new List <GaSymMultivector>(10);


            for (var i = 0; i < 10; i++)
            {
                mvList.Add(randGen.GetSymMultivector(Frame.GaSpaceDimension));
            }

            //var mvA = GaMultivector.CreateSymbolic(Frame.GaSpaceDimension, "A");
            //var mvB = GaMultivector.CreateSymbolic(Frame.GaSpaceDimension, "B");

            var cacheMisses1 = SymbolicUtils.Cas.Connection.CacheMisses;
            var elapsedTime1 = SymbolicUtils.Cas.Connection.Stopwatch.Elapsed;

            var resultList = new List <GaSymMultivector>(mvList.Count * mvList.Count);

            foreach (var mv1 in mvList)
            {
                foreach (var mv2 in mvList)
                {
                    resultList.Add(Frame.Gp[mv1, mv2]);
                }
            }

            var cacheMisses2 = SymbolicUtils.Cas.Connection.CacheMisses;
            var elapsedTime2 = SymbolicUtils.Cas.Connection.Stopwatch.Elapsed;

            //LogComposer
            //    .AppendAtNewLine("A = ")
            //    .AppendLine(mvA.ToString());

            //LogComposer
            //    .AppendAtNewLine("B = ")
            //    .AppendLine(mvB.ToString())
            //    .AppendLine();

            //LogComposer
            //    .AppendAtNewLine("A gp B = ")
            //    .AppendLine(gp.ToString())
            //    .AppendLine();

            LogComposer
            .AppendAtNewLine("Symbolic Computations Count: ")
            .AppendLine(cacheMisses2 - cacheMisses1)
            .AppendAtNewLine("Symbolic Computations Time: ")
            .AppendLine(elapsedTime2 - elapsedTime1);

            return(LogComposer.ToString());
        }
        private static void RedirectLogs(ILogSink logSink, out IReadOnlyDictionary <Type, LogSourceNameCompositionLogSink> redirections)
        {
            LogComposer.RedirectLogs(logSink, out redirections);

            ConsoleWriteLine();
            ConsoleWriteLine($"Configured a total of {redirections.Count} redirections:");

            foreach (KeyValuePair <Type, LogSourceNameCompositionLogSink> redirection in redirections)
            {
                ConsoleWriteLine("{");
                ConsoleWriteLine($"    Logger Type:         \"{redirection.Key.FullName}\"");
                if (redirection.Value == null)
                {
                    ConsoleWriteLine($"    Destination:         Nothing will be logged");
                }
                else
                {
                    ConsoleWriteLine($"    Destination:         Log Sink Type:       \"{redirection.Value.DownstreamLogSink.GetType().Name}\"");
                    ConsoleWriteLine($"                         Log Component Group: \"{redirection.Value.LogSourcesGroupMoniker}\"");
                }

                ConsoleWriteLine("}");
            }
        }
        private static bool TrySetupFileLogger(IProductConfiguration config)
        {
            try
            {
                var filenameBaseInfo = new DatadogEnvironmentFileLogSinkFactory.FilenameBaseInfo(ProductFamily, Product, ComponentGroup);
                if (DatadogEnvironmentFileLogSinkFactory.TryCreateNewFileLogSink(
                        filenameBaseInfo,
                        LoggingDemoLogGroupId,
                        config?.Log_PreferredLogFileDirectory,
                        LogFileSizeBytes,
                        FileFormatOptions,
                        out FileLogSink fileLogSink))
                {
                    RedirectLogs(fileLogSink, out _logRedirections);

                    if (config != null)
                    {
                        LogComposer.IsDebugLoggingEnabled = config.Log_IsDebugEnabled;
                    }
                    else
                    {
                        LogComposer.SetDebugLoggingEnabledBasedOnEnvironment();
                    }

                    return(true);
                }
            }
            catch (Exception ex)
            {
                ConsoleWriteLine();
                ConsoleWriteLine("Error setting up a file logger.");
                ConsoleWriteLine($"{ex}");
            }

            return(false);
        }
 private static void RedirectLogs(ILogSink logSink, out IReadOnlyDictionary <Type, LogSourceNameCompositionLogSink> redirections)
 {
     LogComposer.RedirectLogs(logSink, out redirections);
 }
Exemple #8
0
        public string Execute()
        {
            LogComposer.Clear();

            //var randGen = new GMacRandomGenerator(10);
            //var mvA = randGen.GetSymbolicMultivector(Frame.GaSpaceDimension, "A");
            //var mvB = randGen.GetSymbolicMultivector(Frame.GaSpaceDimension, "B");
            var mvA = GaSymMultivector.CreateSymbolic(Frame.GaSpaceDimension, "A");
            var mvB = GaSymMultivector.CreateSymbolic(Frame.GaSpaceDimension, "B");

            LogComposer
            .AppendAtNewLine("A = ")
            .AppendLine(mvA.ToString());

            LogComposer
            .AppendAtNewLine("B = ")
            .AppendLine(mvB.ToString())
            .AppendLine();

            var coefSumsTable = GaSymMapBilinearCoefSums.CreateFromOuterProduct(Frame);

            LogComposer
            .AppendAtNewLine("A op B = ")
            .AppendLine(coefSumsTable[mvA, mvB].ToString())
            .AppendLine()
            .AppendLineAtNewLine("A op B Coef Sums:")
            .AppendLine(coefSumsTable.ToMarkdownTable());

            var mv1  = mvA.ToTreeMultivector();
            var mv2  = mvB.ToTreeMultivector();
            var opMv = mv1.Op(mv2);

            LogComposer
            .AppendAtNewLine("Tree: A = ")
            .AppendLine(mv1.ToTreeString())
            .AppendAtNewLine("Tree: B = ")
            .AppendLine(mv2.ToTreeString())
            .AppendAtNewLine("Tree: A op B = ")
            .AppendLine(opMv.ToTreeString())
            .AppendLine();

            coefSumsTable = Frame.Gp.ToCoefSumsMap();
            LogComposer
            .AppendAtNewLine("A gp B = ")
            .AppendLine(coefSumsTable[mvA, mvB].ToString())
            .AppendLine()
            .AppendLineAtNewLine("A gp B Coef Sums:")
            .AppendLine(coefSumsTable.ToMarkdownTable());

            var gpMv = mv1.EGp(mv2);

            LogComposer
            .AppendAtNewLine("Tree: A = ")
            .AppendLine(mv1.ToTreeString())
            .AppendAtNewLine("Tree: B = ")
            .AppendLine(mv2.ToTreeString())
            .AppendAtNewLine("Tree: A gp B = ")
            .AppendLine(gpMv.ToTreeString())
            .AppendLine();

            coefSumsTable = Frame.Sp.ToCoefSumsMap();
            LogComposer
            .AppendAtNewLine("A sp B = ")
            .AppendLine(coefSumsTable[mvA, mvB].ToString())
            .AppendLine()
            .AppendLineAtNewLine("A sp B Coef Sums:")
            .AppendLine(coefSumsTable.ToMarkdownTable());

            coefSumsTable = Frame.Lcp.ToCoefSumsMap();
            LogComposer
            .AppendAtNewLine("A lcp B = ")
            .AppendLine(coefSumsTable[mvA, mvB].ToString())
            .AppendLine()
            .AppendLineAtNewLine("A lcp B Coef Sums:")
            .AppendLine(coefSumsTable.ToMarkdownTable());

            return(LogComposer.ToString());
        }
Exemple #9
0
 /// <summary>
 /// This is used to get CSV logs.
 /// </summary>
 /// <param name="data">The SELF file.</param>
 /// <returns>CSV logs formatted with UTF8 and CRLF></returns>
 private byte[] GetCsv(byte[] data)
 {
     return(Encoding.UTF8.GetBytes(LogComposer.Compose(data)));
 }