예제 #1
0
        public LogSharkRunner(LogSharkConfiguration config, MetricsModule metricsModule, ILoggerFactory loggerFactory)
        {
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;

            _loggerFactory = loggerFactory;
            _logger        = loggerFactory.CreateLogger <LogSharkRunner>();

            _config = config;

            _processingNotificationsCollector = new ProcessingNotificationsCollector(_config.NumberOfErrorDetailsToKeep);

            if (_config.PublishWorkbooks)
            {
                var tableauServerInfo = new TableauServerInfo(
                    _config.TableauServerUrl,
                    _config.TableauServerSite,
                    _config.TableauServerUsername,
                    _config.TableauServerPassword,
                    _config.TableauServerTimeout);
                _publisherSettings = new PublisherSettings(
                    tableauServerInfo,
                    _config.GroupsToProvideWithDefaultPermissions,
                    _config.ApplyPluginProvidedTagsToWorkbooks,
                    _config.ParentProjectId,
                    _config.ParentProjectName);
            }
            _metricsModule = metricsModule;
        }
예제 #2
0
 public TableauLogsProcessor(
     LogSharkConfiguration config,
     IPluginManager pluginManager,
     IWriterFactory writerFactory,
     ILogTypeDetails logTypeDetails,
     IProcessingNotificationsCollector processingNotificationsCollector,
     ILoggerFactory loggerFactory)
 {
     _config         = config;
     _loggerFactory  = loggerFactory;
     _logger         = _loggerFactory.CreateLogger <TableauLogsProcessor>();
     _logTypeDetails = logTypeDetails;
     _pluginManager  = pluginManager;
     _processingNotificationsCollector = processingNotificationsCollector;
     _writerFactory = writerFactory;
 }
예제 #3
0
        public LogSharkRunner(LogSharkConfiguration config, MetricsModule metricsModule, ILoggerFactory loggerFactory)
        {
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;

            _loggerFactory = loggerFactory;
            _logger        = loggerFactory.CreateLogger <LogSharkRunner>();

            _config = config;

            _processingNotificationsCollector = new ProcessingNotificationsCollector(_config.NumberOfErrorDetailsToKeep);

            if (_config.PublishWorkbooks)
            {
                _publisherSettings = config.GetPublisherSettings();
            }

            _metricsModule = metricsModule;
        }
예제 #4
0
        private async Task <int> OnExecute()
        {
            var exeDir        = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(exeDir)
                                .AddJsonFile(Config ?? "config/LogSharkConfig.json", optional: false, reloadOnChange: false)
                                .Build();

            var loggerFactory = ConfigureLogging(configuration);
            var logger        = loggerFactory.CreateLogger <Program>();

            var clParameters = new LogSharkCommandLineParameters
            {
                AppendTo                   = AppendTo,
                DatabaseName               = SqlDbName,
                DatabaseConnectionString   = SqlDbConnectionString,
                DatabaseHost               = SqlDbHost,
                DatabasePassword           = SqlDbPassword,
                DatabaseUsername           = SqlDbUser,
                EmbedCredentialsOnPublish  = SqlEmbedCreds,
                ForceRunId                 = ForceRunId,
                LogSetLocation             = LogSetLocation,
                PublishWorkbooks           = PublishWorkbooks,
                RequestedPlugins           = RequestedPlugins,
                UserProvidedRunId          = RunId,
                RequestedWriter            = Writer,
                TableauServerUsername      = Username,
                TableauServerPassword      = Password,
                TableauServerSite          = Site,
                TableauServerUrl           = Url,
                WorkbookNameSuffixOverride = WorkbookNameSuffixOverride,
            };
            var config = new LogSharkConfiguration(clParameters, configuration, loggerFactory);

            var metricUploaderConfiguration = new MetricsUploaderConfiguration(config);
            var metricUploader = new MetricUploader(metricUploaderConfiguration, loggerFactory);
            var metricsConfig  = new MetricsConfig(metricUploader, config);
            var metricsModule  = new MetricsModule(metricsConfig, loggerFactory);

            try
            {
                if (ListPLugins)
                {
                    using (var pluginManager = new PluginManager(config, loggerFactory))
                    {
                        var plugins = string.Join("\n\t- ", pluginManager.GetKnownPluginNames());
                        Console.WriteLine($"Available plugins:\n\t- {plugins}");
                    }
                    return(EnvironmentController.SetExitCode(ExitCode.OK));
                }
                else if (string.IsNullOrWhiteSpace(LogSetLocation))
                {
                    Console.WriteLine("The LogSetLocation field is required.\nSpecify--help for a list of available options and commands.");
                    return(EnvironmentController.SetExitCode(ExitCode.ERROR));
                }
                else
                {
                    var runner     = new LogSharkRunner(config, metricsModule, loggerFactory);
                    var runSummary = await runner.Run();

                    EnvironmentController.SetExitCode(runSummary, false);

                    logger.LogInformation(runSummary.ToStringReport());
                }
            }
            finally
            {
                loggerFactory.Dispose();
                Thread.Sleep(200); // Otherwise logger does not write final message sometimes
            }

            return(Environment.ExitCode);
        }