Module: Couchbase

Defined in:
lib/couchbase/utils.rb,
lib/couchbase/scope.rb,
lib/couchbase/bucket.rb,
lib/couchbase/errors.rb,
lib/couchbase/logger.rb,
lib/couchbase/subdoc.rb,
lib/couchbase/cluster.rb,
lib/couchbase/options.rb,
lib/couchbase/version.rb,
lib/couchbase/collection.rb,
lib/couchbase/management.rb,
lib/couchbase/utils/time.rb,
lib/couchbase/diagnostics.rb,
lib/couchbase/protostellar.rb,
lib/couchbase/view_options.rb,
lib/couchbase/authenticator.rb,
lib/couchbase/configuration.rb,
lib/couchbase/query_options.rb,
lib/couchbase/datastructures.rb,
lib/couchbase/key_value_scan.rb,
lib/couchbase/mutation_state.rb,
lib/couchbase/search_options.rb,
lib/couchbase/config_profiles.rb,
lib/couchbase/json_transcoder.rb,
lib/couchbase/cluster_registry.rb,
lib/couchbase/transcoder_flags.rb,
lib/couchbase/analytics_options.rb,
lib/couchbase/binary_collection.rb,
lib/couchbase/collection_options.rb,
lib/couchbase/protostellar/retry.rb,
lib/couchbase/protostellar/scope.rb,
lib/couchbase/protostellar/bucket.rb,
lib/couchbase/protostellar/client.rb,
lib/couchbase/raw_json_transcoder.rb,
lib/couchbase/protostellar/cluster.rb,
lib/couchbase/protostellar/request.rb,
lib/couchbase/protostellar/timeouts.rb,
lib/couchbase/raw_binary_transcoder.rb,
lib/couchbase/raw_string_transcoder.rb,
lib/couchbase/protostellar/generated.rb,
lib/couchbase/management/user_manager.rb,
lib/couchbase/protostellar/collection.rb,
lib/couchbase/protostellar/management.rb,
lib/couchbase/binary_collection_options.rb,
lib/couchbase/management/bucket_manager.rb,
lib/couchbase/protostellar/retry/action.rb,
lib/couchbase/protostellar/retry/reason.rb,
lib/couchbase/protostellar/error_handling.rb,
lib/couchbase/utils/stdlib_logger_adapter.rb,
lib/couchbase/datastructures/couchbase_map.rb,
lib/couchbase/datastructures/couchbase_set.rb,
lib/couchbase/protostellar/connect_options.rb,
lib/couchbase/utils/generic_logger_adapter.rb,
lib/couchbase/datastructures/couchbase_list.rb,
lib/couchbase/management/collection_manager.rb,
lib/couchbase/management/view_index_manager.rb,
lib/couchbase/protostellar/retry/strategies.rb,
lib/couchbase/protostellar/timeout_defaults.rb,
lib/couchbase/datastructures/couchbase_queue.rb,
lib/couchbase/management/query_index_manager.rb,
lib/couchbase/protostellar/binary_collection.rb,
lib/couchbase/protostellar/request_behaviour.rb,
lib/couchbase/protostellar/request_generator.rb,
lib/couchbase/management/search_index_manager.rb,
lib/couchbase/protostellar/response_converter.rb,
lib/couchbase/protostellar/retry/orchestrator.rb,
lib/couchbase/protostellar/request_generator/kv.rb,
lib/couchbase/management/analytics_index_manager.rb,
lib/couchbase/protostellar/generated/kv/v1/kv_pb.rb,
lib/couchbase/protostellar/response_converter/kv.rb,
lib/couchbase/protostellar/request_generator/admin.rb,
lib/couchbase/protostellar/request_generator/query.rb,
lib/couchbase/management/scope_search_index_manager.rb,
lib/couchbase/protostellar/request_generator/search.rb,
lib/couchbase/protostellar/response_converter/admin.rb,
lib/couchbase/protostellar/response_converter/query.rb,
lib/couchbase/protostellar/generated/view/v1/view_pb.rb,
lib/couchbase/protostellar/management/bucket_manager.rb,
lib/couchbase/protostellar/response_converter/search.rb,
lib/couchbase/protostellar/generated/query/v1/query_pb.rb,
lib/rails/generators/couchbase/config/config_generator.rb,
lib/couchbase/management/collection_query_index_manager.rb,
lib/couchbase/protostellar/retry/strategies/best_effort.rb,
lib/couchbase/protostellar/generated/search/v1/search_pb.rb,
lib/couchbase/protostellar/management/collection_manager.rb,
lib/couchbase/protostellar/request_generator/admin/query.rb,
lib/couchbase/protostellar/generated/kv/v1/kv_services_pb.rb,
lib/couchbase/protostellar/management/query_index_manager.rb,
lib/couchbase/protostellar/request_generator/admin/bucket.rb,
lib/couchbase/protostellar/response_converter/admin/query.rb,
lib/couchbase/protostellar/generated/routing/v1/routing_pb.rb,
lib/couchbase/protostellar/response_converter/admin/bucket.rb,
lib/couchbase/protostellar/generated/admin/query/v1/query_pb.rb,
lib/couchbase/protostellar/generated/view/v1/view_services_pb.rb,
lib/couchbase/protostellar/request_generator/admin/collection.rb,
lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_pb.rb,
lib/couchbase/protostellar/generated/admin/search/v1/search_pb.rb,
lib/couchbase/protostellar/generated/analytics/v1/analytics_pb.rb,
lib/couchbase/protostellar/response_converter/admin/collection.rb,
lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_pb.rb,
lib/couchbase/protostellar/generated/query/v1/query_services_pb.rb,
lib/couchbase/protostellar/generated/search/v1/search_services_pb.rb,
lib/couchbase/protostellar/generated/routing/v1/routing_services_pb.rb,
lib/couchbase/protostellar/generated/transactions/v1/transactions_pb.rb,
lib/couchbase/protostellar/management/collection_query_index_manager.rb,
lib/couchbase/protostellar/generated/admin/query/v1/query_services_pb.rb,
lib/couchbase/protostellar/generated/admin/collection/v1/collection_pb.rb,
lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_services_pb.rb,
lib/couchbase/protostellar/generated/admin/search/v1/search_services_pb.rb,
lib/couchbase/protostellar/generated/analytics/v1/analytics_services_pb.rb,
lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_services_pb.rb,
lib/couchbase/protostellar/generated/transactions/v1/transactions_services_pb.rb,
lib/couchbase/protostellar/generated/admin/collection/v1/collection_services_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/scope.rb,
/code/couchbase-ruby-client/lib/couchbase/utils.rb,
/code/couchbase-ruby-client/lib/couchbase/bucket.rb,
/code/couchbase-ruby-client/lib/couchbase/errors.rb,
/code/couchbase-ruby-client/lib/couchbase/logger.rb,
/code/couchbase-ruby-client/lib/couchbase/subdoc.rb,
/code/couchbase-ruby-client/lib/couchbase/cluster.rb,
/code/couchbase-ruby-client/lib/couchbase/options.rb,
/code/couchbase-ruby-client/lib/couchbase/version.rb,
/code/couchbase-ruby-client/lib/couchbase/collection.rb,
/code/couchbase-ruby-client/lib/couchbase/management.rb,
/code/couchbase-ruby-client/lib/couchbase/utils/time.rb,
/code/couchbase-ruby-client/lib/couchbase/diagnostics.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar.rb,
/code/couchbase-ruby-client/lib/couchbase/view_options.rb,
/code/couchbase-ruby-client/lib/couchbase/authenticator.rb,
/code/couchbase-ruby-client/lib/couchbase/configuration.rb,
/code/couchbase-ruby-client/lib/couchbase/query_options.rb,
/code/couchbase-ruby-client/lib/couchbase/datastructures.rb,
/code/couchbase-ruby-client/lib/couchbase/key_value_scan.rb,
/code/couchbase-ruby-client/lib/couchbase/mutation_state.rb,
/code/couchbase-ruby-client/lib/couchbase/search_options.rb,
/code/couchbase-ruby-client/lib/couchbase/config_profiles.rb,
/code/couchbase-ruby-client/lib/couchbase/json_transcoder.rb,
/code/couchbase-ruby-client/lib/couchbase/cluster_registry.rb,
/code/couchbase-ruby-client/lib/couchbase/transcoder_flags.rb,
/code/couchbase-ruby-client/lib/couchbase/analytics_options.rb,
/code/couchbase-ruby-client/lib/couchbase/binary_collection.rb,
/code/couchbase-ruby-client/lib/couchbase/collection_options.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/retry.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/scope.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/bucket.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/client.rb,
/code/couchbase-ruby-client/lib/couchbase/raw_json_transcoder.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/cluster.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/request.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/timeouts.rb,
/code/couchbase-ruby-client/lib/couchbase/raw_binary_transcoder.rb,
/code/couchbase-ruby-client/lib/couchbase/raw_string_transcoder.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated.rb,
/code/couchbase-ruby-client/lib/couchbase/management/user_manager.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/collection.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/management.rb,
/code/couchbase-ruby-client/lib/couchbase/binary_collection_options.rb,
/code/couchbase-ruby-client/lib/couchbase/management/bucket_manager.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/retry/action.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/retry/reason.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/error_handling.rb,
/code/couchbase-ruby-client/lib/couchbase/utils/stdlib_logger_adapter.rb,
/code/couchbase-ruby-client/lib/couchbase/datastructures/couchbase_map.rb,
/code/couchbase-ruby-client/lib/couchbase/datastructures/couchbase_set.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/connect_options.rb,
/code/couchbase-ruby-client/lib/couchbase/utils/generic_logger_adapter.rb,
/code/couchbase-ruby-client/lib/couchbase/datastructures/couchbase_list.rb,
/code/couchbase-ruby-client/lib/couchbase/management/collection_manager.rb,
/code/couchbase-ruby-client/lib/couchbase/management/view_index_manager.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/retry/strategies.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/timeout_defaults.rb,
/code/couchbase-ruby-client/lib/couchbase/datastructures/couchbase_queue.rb,
/code/couchbase-ruby-client/lib/couchbase/management/query_index_manager.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/binary_collection.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/request_behaviour.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/request_generator.rb,
/code/couchbase-ruby-client/lib/couchbase/management/search_index_manager.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/response_converter.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/retry/orchestrator.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/request_generator/kv.rb,
/code/couchbase-ruby-client/lib/couchbase/management/analytics_index_manager.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/kv/v1/kv_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/response_converter/kv.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/request_generator/admin.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/request_generator/query.rb,
/code/couchbase-ruby-client/lib/couchbase/management/scope_search_index_manager.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/request_generator/search.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/response_converter/admin.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/response_converter/query.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/view/v1/view_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/management/bucket_manager.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/response_converter/search.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/query/v1/query_pb.rb,
/code/couchbase-ruby-client/lib/rails/generators/couchbase/config/config_generator.rb,
/code/couchbase-ruby-client/lib/couchbase/management/collection_query_index_manager.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/retry/strategies/best_effort.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/search/v1/search_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/management/collection_manager.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/request_generator/admin/query.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/kv/v1/kv_services_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/management/query_index_manager.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/request_generator/admin/bucket.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/response_converter/admin/query.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/routing/v1/routing_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/response_converter/admin/bucket.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/admin/query/v1/query_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/view/v1/view_services_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/request_generator/admin/collection.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/admin/search/v1/search_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/analytics/v1/analytics_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/response_converter/admin/collection.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/query/v1/query_services_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/search/v1/search_services_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/routing/v1/routing_services_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/transactions/v1/transactions_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/management/collection_query_index_manager.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/admin/query/v1/query_services_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/admin/collection/v1/collection_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_services_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/admin/search/v1/search_services_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/analytics/v1/analytics_services_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_services_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/transactions/v1/transactions_services_pb.rb,
/code/couchbase-ruby-client/lib/couchbase/protostellar/generated/admin/collection/v1/collection_services_pb.rb

Overview

frozen_string_literal: true

Defined Under Namespace

Modules: ConfigProfiles, Datastructures, Error, Generators, Management, Options, Utils Classes: BinaryCollection, Bucket, CertificateAuthenticator, Cluster, ClusterRegistry, Collection, Configuration, DiagnosticsResult, JsonTranscoder, LookupInSpec, MutateInSpec, MutationState, MutationToken, PasswordAuthenticator, PingResult, PrefixScan, RangeScan, RawBinaryTranscoder, RawJsonTranscoder, RawStringTranscoder, SamplingScan, ScanTerm, Scope, SearchFacet, SearchFacetResult, SearchMetaData, SearchMetrics, SearchQuery, SearchRequest, SearchResult, SearchRow, SearchRowLocation, SearchRowLocations, SearchSort, VectorQuery, VectorSearch

Constant Summary collapse

VERSION =

Version of the library and all bundled dependencies

Examples:

Display version (Couchbase::BUILD_INFO contains more details)

$ ruby -rcouchbase -e 'pp Couchbase::VERSION'
{:sdk=>"3.4.0", :ruby_abi=>"3.1.0", :revision=>"416fe68e6029ec8a4c40611cf6e6b30d3b90d20f"}
{}

Class Method Summary collapse

Class Method Details

.log_levelSymbol

Get current log level

Returns:

  • (Symbol)

    current log level



43
44
45
# File 'lib/couchbase/logger.rb', line 43

def self.log_level
  Backend.get_log_level
end

.log_level=(level) ⇒ void

Note:

The level might be also be set with environment variable COUCHBASE_BACKEND_LOG_LEVEL

This method returns an undefined value.

Set log level

Parameters:

  • level (Symbol)

    new log level.

    Allowed levels (in order of decreasing verbosity):

    • :trace

    • :debug

    • :info (default)

    • :warn

    • :error

    • :critical

    • :off



36
37
38
# File 'lib/couchbase/logger.rb', line 36

def self.log_level=(level)
  Backend.set_log_level(level)
end

.loggerObject

Return logger associated with the library



48
49
50
# File 'lib/couchbase/logger.rb', line 48

def self.logger
  @logger # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
end

.set_logger(logger, adapter_class: nil, verbose: false, level: :info) ⇒ Object

Associate logger with the library

The log messages, that are generated by extension might come with out of order timestamps, in order to reduce number of switches between Ruby and Native code.

Examples:

Specify custom logger and limit core messages to debug level

Couchbase.set_logger(Logger.new(STDERR), level: :debug)

Parameters:

  • logger (Logger)

    an object implementing logging interface, e.g. stdlib Logger, or something that responds to “level”-methods like #debug, #error, etc.

  • adapter_class (Class) (defaults to: nil)

    custom implementation of the logger adapter interface between extension and ruby code. See Couchbase::Utils::StdlibLoggerAdapter and Couchbase::Utils::GenericLoggerAdapter

  • verbose (Boolean) (defaults to: false)

    if true, the message will also include source code location, where the message was generated (if available)

  • level (Symbol) (defaults to: :info)

    log level, see log_level= for allowed values

Since:

  • 3.4.0



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/couchbase/logger.rb', line 69

def self.set_logger(logger, adapter_class: nil, verbose: false, level: :info)
  @logger = logger # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
  if @logger.nil? # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
    Backend.install_logger_shim(nil)
    return
  end
  shim =
    if adapter_class
      adapter_class
    elsif logger.is_a?(::Logger)
      require "couchbase/utils/stdlib_logger_adapter"
      Utils::StdlibLoggerAdapter
    else
      require "couchbase/utils/generic_logger_adapter"
      Utils::GenericLoggerAdapter
    end
  Backend.install_logger_shim(shim.new(logger, verbose: verbose), level)
end