Sha256: b2d37c1734e8f3a17934fca4cab894d83e3c5618ec88cfc77a648a57cfaf611a

Contents?: true

Size: 1.35 KB

Versions: 15

Compression:

Stored size: 1.35 KB

Contents

module NexusCli
  # @author Kyle Allan <kallan@riotgames.com>
  module LoggingActions
    
    # Gets information about the current logging
    # levels in Nexus.
    # 
    # 
    # @return [String] a String of JSON representing the current logging levels of Nexus
    def get_logging_info
      response = nexus.get(nexus_url("service/local/log/config"), :header => DEFAULT_ACCEPT_HEADER)
      case response.status
      when 200
        return response.content
      else
        raise UnexpectedStatusCodeException.new(response.status)
      end
    end


    # Sets the logging level of Nexus to one of
    # "INFO", "DEBUG", or "ERROR".
    # 
    # @param  level [String] the logging level to set
    # 
    # @return [Boolean] true if the logging level has been set, false otherwise
    def set_logger_level(level)
      raise InvalidLoggingLevelException unless ["INFO", "DEBUG", "ERROR"].include?(level.upcase)
      response = nexus.put(nexus_url("service/local/log/config"), :body => create_logger_level_json(level), :header => DEFAULT_CONTENT_TYPE_HEADER)
      case response.status
      when 200
        return true
      else
        raise UnexpectedStatusCodeException.new(response.status)
      end
    end

    private

    def create_logger_level_json(level)
      params = {:rootLoggerLevel => level.upcase}
      JSON.dump(:data => params)
    end
  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
nexus_cli_sb-4.0.4 lib/nexus_cli/mixins/logging_actions.rb
nexus_cli_sb-4.0.2 lib/nexus_cli/mixins/logging_actions.rb
nexus_cli_nx-4.1.3 lib/nexus_cli/mixins/logging_actions.rb
nexus_cli_nx-4.1.2 lib/nexus_cli/mixins/logging_actions.rb
nexus_cli-4.1.1 lib/nexus_cli/mixins/logging_actions.rb
nexus_cli-4.1.0 lib/nexus_cli/mixins/logging_actions.rb
nexus_cli-4.0.3 lib/nexus_cli/mixins/logging_actions.rb
nexus_cli-4.0.2 lib/nexus_cli/mixins/logging_actions.rb
nexus_cli-4.0.1 lib/nexus_cli/mixins/logging_actions.rb
nexus_cli-4.0.0 lib/nexus_cli/mixins/logging_actions.rb
nexus_cli-4.0.0.beta1 lib/nexus_cli/mixins/logging_actions.rb
nexus_cli-3.0.0 lib/nexus_cli/mixins/logging_actions.rb
nexus_cli-2.0.2 lib/nexus_cli/mixins/logging_actions.rb
nexus_cli-2.0.1 lib/nexus_cli/mixins/logging_actions.rb
nexus_cli-2.0.0 lib/nexus_cli/mixins/logging_actions.rb