示例#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 static void StartAutomaticMax5ItemsExport()
        {
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine(">>>> Kangaroo Demo: Automatic export MAX 5 items");
            Console.ResetColor();

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

            // 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);

            for (int i = 0; i < 7; i++)
            {
                Console.WriteLine($">> Add {i + 1}. exception!");
                kangaroo.AddData(new ArgumentException($"This is an exception message! {i}"));
            }

            Console.WriteLine(">> END DEMO");
        }
        public void TimeBasedExport_5Exported_Ok()
        {
            // Create kangaroostore instance
            KangarooStore <Exception> kangaroo = new KangarooStore <Exception>(new KangarooSettings(TimeSpan.FromSeconds(1)));

            // Create kangaroo export handler
            KangarooExporter <Exception, string> exporter = KangarooExporterExceptionString.Object;

            // Add exporter to kangaroo store
            kangaroo.AddExporter(exporter);

            for (int i = 0; i < 7; i++)
            {
                Console.WriteLine($">> Add {i + 1}. exception!");
                kangaroo.AddData(new ArgumentException($"This is an exception message! {i}"));
            }

            Task.Delay(1100).Wait();

            Console.WriteLine(">> END DEMO");

            kangaroo.StopTimebasedExport();

            KangrooExportWorker.Verify(x => x.Export(It.IsAny <string[]>()), Times.Once());
        }
示例#4
0
        public void KangarooStoreTestMethodAddData()
        {
            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);
        }
示例#5
0
        public static void StartTimebasedExport()
        {
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine(">>>> Kangaroo Demo: Automatic export afte 1 sec");
            Console.ResetColor();

            // Create kangaroostore instance
            KangarooStore <Exception> kangaroo = new KangarooStore <Exception>(new KangarooSettings(TimeSpan.FromSeconds(1)));

            // 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);

            for (int i = 0; i < 7; i++)
            {
                Console.WriteLine($">> Add {i + 1}. exception!");
                kangaroo.AddData(new ArgumentException($"This is an exception message! {i}"));
            }

            Task.Delay(1100).Wait();

            Console.WriteLine(">> END DEMO");

            kangaroo.StopTimebasedExport();
        }