class GoogleLogger::Configuration

Public Class Methods

new() click to toggle source

Creates a new instance with default configuration values

# File lib/google_logger/configuration.rb, line 19
def initialize
  @async = true
  @resource_type = 'gae_app'
  @resource_labels = {}
  @secret_params = %i[password]
  @secret_param_value = '<SECRET_PARAM>'
  @log_locally = false
  @backtrace_length = 10
end

Public Instance Methods

validate!() click to toggle source
# File lib/google_logger/configuration.rb, line 29
def validate!
  if @log_locally
    validate_local_logger
  else
    validate_credentials
  end
end

Private Instance Methods

raise_invalid!(message) click to toggle source
# File lib/google_logger/configuration.rb, line 56
def raise_invalid!(message)
  raise InvalidConfigurationError, message
end
validate_credentials() click to toggle source
# File lib/google_logger/configuration.rb, line 50
def validate_credentials
  return unless @project_id.nil? || @project_id == '' || @credentials.nil? || @credentials == ''

  raise_invalid!('"project_id" and "credentials" cannot be blank')
end
validate_local_logger() click to toggle source
# File lib/google_logger/configuration.rb, line 39
def validate_local_logger
  raise_invalid!('"local_logger" must be provided if "log_locally" is set to "true"') if local_logger.nil?

  log_levels = GoogleLogger::Loggers::LocalLogger::SEVERITY_MAPPING.values.uniq + [:unknown]

  # make sure the logger responds to logger methods
  log_levels.each do |log_level|
    raise_invalid!("\"local_logger\" must respond to \"#{log_level}\"") unless local_logger.respond_to?(log_level)
  end
end