/// <summary>
        /// Sets up and issues the LogsharkRequest to the LogsharkController.
        /// </summary>
        public void Execute()
        {
            if (commandLineOptions.ListPlugins)
            {
                try
                {
                    LogsharkController.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;
            }
        }
Exemple #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);
            }
        }
        /// <summary>
        /// Sets up and issues the Request to the LogsharkController.
        /// </summary>
        /// <returns>0 if execution was successful; non-zero value otherwise.</returns>
        /// <param name="target">The location of the logset we want to test</param>
        /// <param name="postgresDatabaseName">The name of the postgres db we are creating</param>
        /// <param name="startLocalMongo">A bool to start a local instance of mongo or use whats defined in the app config</param>
        /// <param name="localMongoPort">The port that the local instance of mongo is running on (if being used)</param>
        /// <param name="forceParse">If we want to force parse the logset for the run</param>
        /// <param name="dropMongoDbPostRun">If we want to drop the mongo db post run</param>
        public LogsharkRunContext ProcessLogset(string target, string postgresDatabaseName, bool startLocalMongo = true, int localMongoPort = 27017, bool forceParse = true, bool dropMongoDbPostRun = false)
        {
            var pluginSet = new HashSet <string> {
                "none"
            };

            LogsharkRequest request = BuildLogsharkRequest(target, configuration, null, postgresDatabaseName, forceParse, startLocalMongo, localMongoPort, dropMongoDbPostRun, false, pluginSet, new List <string>(), Environment.CurrentDirectory);

            // Run application.
            LogsharkRequestProcessor requestProcessor = new LogsharkRequestProcessor();

            return(requestProcessor.ProcessRequest(request));
        }