Replay log on flushing.
Inheritance: ILoggerListener
Exemple #1
0
        private static int ExecSubCommand(string[] args)
        {
            var consoleLogListener = new ConsoleLogListener();
            var replayListener = new ReplayLogListener();
            replayListener.AddListener(consoleLogListener);
            Logger.RegisterListener(replayListener);

            CommandController controller = null;
            ISubCommand command;
            try
            {
                controller = ArgsParser.Instance.Parse(args);
                command = controller.Create();
            }
            catch (System.IO.FileNotFoundException fe)
            {
                Logger.LogError(fe.Message);
                return 1;
            }
            catch (OptionParserException e)
            {
                Logger.LogError(e.Message);
                if (controller != null)
                {
                    Console.WriteLine(controller.GetHelpText());
                }
                return 1;
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.ToString());
                if (controller != null)
                {
                    Console.WriteLine(controller.GetHelpText());
                }
                return 1;
            }

            if (!(command is ILoggable))
            {
                replayListener.Replay = false;
            }

            var context = new SubCommandRunningContext();
            try
            {
                command.Exec(context);
                return 0;
            }
            catch (DocfxException de)
            {
                Logger.LogError(de.Message);
                return 1;
            }
            catch (Exception e)
            {
                Logger.LogError(e.ToString());
                return 1;
            }
        }
Exemple #2
0
        private static int ExecSubCommand(string[] args)
        {
            var consoleLogListener = new ConsoleLogListener();
            var replayListener = new ReplayLogListener();
            replayListener.AddListener(consoleLogListener);
            Logger.RegisterListener(replayListener);

            CommandController controller = null;
            ISubCommand command;
            try
            {
                controller = ArgsParser.Instance.Parse(args);
                command = controller.Create();
            }
            catch (System.IO.FileNotFoundException fe)
            {
                Logger.LogError(fe.Message);
                return 1;
            }
            catch (Exception e) when (e is OptionParserException || e is InvalidOptionException)
            {
                Logger.LogError(e.Message);
                if (controller != null)
                {
                    Console.WriteLine(controller.GetHelpText());
                }
                return 1;
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.ToString());
                if (controller != null)
                {
                    Console.WriteLine(controller.GetHelpText());
                }
                return 1;
            }

            replayListener.Replay = command.AllowReplay;

            var context = new SubCommandRunningContext();
            try
            {
                ThreadPool.SetMinThreads(4, 4);
                using (new PerformanceScope("executing", LogLevel.Info))
                {
                    command.Exec(context);
                }

                return 0;
            }
            catch (DocumentException de)
            {
                Logger.LogError(de.Message);
                return 1;
            }
            catch (DocfxException de)
            {
                Logger.LogError(de.Message);
                return 1;
            }
            catch (Exception e)
            {
                Logger.LogError(e.ToString());
                return 1;
            }
        }