Beispiel #1
0
        /// <summary>
        /// Sets up and issues the LogsharkRequest to the LogsharkController.
        /// </summary>
        public void Execute()
        {
            if (commandLineOptions.ListPlugins)
            {
                try
                {
                    LogsharkRequestProcessor.PrintAvailablePlugins();
                    return;
                }
                catch (Exception ex)
                {
                    Log.FatalFormat("Unable to retrieve list of available plugins: {0}", ex.Message);
                    throw;
                }
            }

            try
            {
                LogsharkRequest          request          = BuildLogsharkRequest(commandLineOptions);
                LogsharkRequestProcessor requestProcessor = InitializeRequestProcessor();
                requestProcessor.ProcessRequest(request);
            }
            catch (Exception ex)
            {
                // Certain known exception types have already had their errors logged out by the core; we want to avoid duplicating error logging on these.
                if (!IsKnownExceptionType(ex))
                {
                    Log.Fatal(ex.GetFlattenedMessage());
                }

                Log.Debug(ex);
                throw;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Sets up and issues the <see cref="LogsharkRequest"/> to the <see cref="LogsharkRequestProcessor"/>.
        /// </summary>
        /// <returns>Exit code</returns>
        public ExitCode Execute(LogsharkCommandLineOptions commandLineOptions)
        {
            if (commandLineOptions.ListPlugins)
            {
                try
                {
                    LogsharkRequestProcessor.PrintAvailablePlugins();
                    return(ExitCode.Success);
                }
                catch (Exception ex)
                {
                    Log.FatalFormat($"Unable to retrieve list of available plugins: {ex.Message}");
                    return(ExitCode.ExecutionError);
                }
            }

            try
            {
                var request = BuildLogsharkRequest(commandLineOptions);

                var requestProcessor = new LogsharkRequestProcessor();
                var outcome          = requestProcessor.ProcessRequest(request);

                return(outcome.IsRunSuccessful.Equals(true) ? ExitCode.Success : ExitCode.ExecutionError);
            }
            catch (Exception ex)
            {
                Log.Debug(ex.GetFlattenedMessage());
                Log.Debug(ex.StackTrace);
                return(ExitCode.ExecutionError);
            }
        }