Пример #1
0
        public static void Main(string[] args)
        {
            var logger = new Logger.Logger();

            logger.Trace("Message");
            logger.Fatal("Fatal");

            var myClass = new MyClass("Ivan", 25);

            logger.Track(myClass);

            Console.WriteLine("OK");
            Console.ReadKey();
        }
Пример #2
0
        private static void Main(string[] args)
        {
            var logger = new Logger.Logger();

            try {
                // parse cli options
                var request = Parser.Default.ParseArguments <DracoOption>(args)
                              .MapResult(
                    o => o.Build(), e => throw new DracoParseFailedException());


                using var cts = new CancellationTokenSource();
                var token = cts.Token;
                Console.CancelKeyPress += (sender, eventArgs) => {
                    eventArgs.Cancel = true;
                    cts.Cancel();
                };
                logger.Warn("Press Ctrl+C to cancel");


                // start process
                Spinner.Start("Ptolemy.Draco ", spin => {
                    using var draco = new Draco(token, request);
                    // print logs to stdout
                    var d = draco.Log.Subscribe(s => logger.Info(s));
                    try {
                        draco.Run();
                        spin.Info("Completed");
                    }
                    catch (Exception) {
                        spin.Fail("Failed");
                    }
                    finally {
                        d.Dispose();
                    }
                });
            }
            catch (DracoException e) {
                logger.Error($"{e}");
            }
            catch (DracoParseFailedException) {
            }
            catch (Exception e) {
                logger.Fatal($"{e}");
            }
        }