SetupClientAndFormatters(
            IEnumerable <LokiLabel> labels,
            IEnumerable <string> excludedLabels,
            ITextFormatter textFormatter,
            string outputTemplate,
            IHttpClient httpClient,
            LokiCredentials credentials)
        {
            var batchFormatter = new LokiBatchFormatter(labels, excludedLabels);
            var formatter      = textFormatter ?? new MessageTemplateTextFormatter(outputTemplate);
            var client         = httpClient ?? new DefaultLokiHttpClient();

            if (client is ILokiHttpClient lokiHttpClient)
            {
                lokiHttpClient.SetCredentials(credentials);
            }

            return((IBatchFormatter)batchFormatter, formatter, client);
        }
Exemplo n.º 2
0
        SetupClientAndFormatters(
            IEnumerable <LokiLabel> labels,
            LokiLabelFiltrationMode?filtrationMode,
            IEnumerable <string> filtrationLabels,
            ITextFormatter textFormatter,
            string outputTemplate,
            IHttpClient httpClient,
            LokiCredentials credentials)
        {
            var formatter        = textFormatter ?? new MessageTemplateTextFormatter(outputTemplate);
            var createLevelLabel = !(formatter is ILabelAwareTextFormatter labelAwareTextFormatter && labelAwareTextFormatter.ExcludeLevelLabel);
            var batchFormatter   = new LokiBatchFormatter(labels, filtrationMode, filtrationLabels, createLevelLabel);
            var client           = httpClient ?? new DefaultLokiHttpClient();

            if (client is ILokiHttpClient lokiHttpClient)
            {
                lokiHttpClient.SetCredentials(credentials);
            }

            return((IBatchFormatter)batchFormatter, formatter, client);
        }