Sha256: 62f32ae62014c8f6e8459d04e2e8b90dd80bf2c28ed36276f3463ac6469f7784

Contents?: true

Size: 1.59 KB

Versions: 103

Compression:

Stored size: 1.59 KB

Contents

# encoding: utf-8
#
java_import org.apache.logging.log4j.core.LoggerContext

module LogStash
  module Api
    module Modules
      class Logging < ::LogStash::Api::Modules::Base
        # retrieve logging specific parameters from the provided settings
        #
        # return any unused configurations
        def handle_logging(settings)
          Hash[settings.map do |key, level|
            if key.start_with?("logger.")
              _, path = key.split("logger.")
              LogStash::Logging::Logger::configure_logging(level, path)
              nil
            else
              [key, level]
            end
          end]
        end

        put "/" do
          begin
            request.body.rewind
            req_body = LogStash::Json.load(request.body.read)
            remaining = handle_logging(req_body)
            unless remaining.empty?
              raise ArgumentError, I18n.t("logstash.web_api.logging.unrecognized_option", :option => remaining.keys.first)
            end
            respond_with({"acknowledged" => true})
          rescue ArgumentError => e
            status 400
            respond_with({"error" => e.message})
          end
        end

        get "/" do
          context = LogStash::Logging::Logger::get_logging_context
          if context.nil?
            status 500
            respond_with({"error" => "Logstash loggers were not initialized properly"})
          else
            loggers = context.getLoggers.map { |lgr| [lgr.getName, lgr.getLevel.name] }.sort
            respond_with({"loggers" => Hash[loggers]})
          end
        end
      end
    end
  end
end

Version data entries

103 entries across 100 versions & 12 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/api/modules/logging.rb