Пример #1
0
        public static void StartManuelCategoryExport()
        {
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine(">>>> Kangaroo Demo: Manuel export");
            Console.ResetColor();

            // Create kangaroostore instance
            KangarooStore <Exception> kangaroo = new KangarooStore <Exception>();

            // Create kangaroo export handler
            KangarooExporter <Exception, string> exporter = new KangarooExceptionExporter();

            // Add converter
            exporter.Converter = new KangarooConvertExcpetionToString();

            // Add filter
            exporter.Filter = (x) =>
            {
                return(x is ArgumentException);
            };

            // Add exporter
            exporter.Worker = new KangarooExportWorkerStringToConsole();

            // Add exporter to kangaroo store
            kangaroo.AddExporter(exporter, MyEnum.Debug);

            Console.WriteLine($">> Add an exception!");
            kangaroo.AddData(new ArgumentException("Fatal bug!"), MyEnum.Fatal);
            kangaroo.AddData(new ArgumentException("Normal bug!"), MyEnum.Debug);

            Console.WriteLine(">> Start export!");
            kangaroo.StartManualExport();
            Console.WriteLine(">> END DEMO");
        }
Пример #2
0
        public void KangarooStoreTestMethodStartManualExport()
        {
            KangarooStore <Exception>            kangaroo = new KangarooStore <Exception>();
            KangarooExporter <Exception, string> exporter = new KangarooExceptionExporter();

            exporter.Converter = new KangarooConvertExcpetionToString();
            exporter.Filter    = (x) =>
            {
                return(x is NullReferenceException);
            };
            exporter.Worker = new KangarooExportWorkerStringToConsole();
            kangaroo.AddExporter(exporter);
            kangaroo.AddExporter(exporter, MyEnum.Debug);

            // Log the exception without specifying a category
            kangaroo.AddData(new Exception());
            // Log the exception with a specific category
            kangaroo.AddData(new Exception(), MyEnum.Debug);

            kangaroo.StartManualExport();
        }