Sha256: 61ace83acfecbd3c584daeeba2d239757b7c00331ff312cd182dc9d94cb7db1c

Contents?: true

Size: 1.29 KB

Versions: 6803

Compression:

Stored size: 1.29 KB

Contents

# encoding: utf-8
# frozen_string_literal: true
module Ethon

  # Contains logging behaviour.
  module Loggable

    # Get the logger.
    #
    # @note Will try to grab Rails' logger first before creating a new logger
    #   with stdout.
    #
    # @example Get the logger.
    #   Loggable.logger
    #
    # @return [ Logger ] The logger.
    def logger
      return @logger if defined?(@logger)
      @logger = rails_logger || default_logger
    end

    # Set the logger.
    #
    # @example Set the logger.
    #   Loggable.logger = Logger.new($stdout)
    #
    # @param [ Logger ] logger The logger to set.
    #
    # @return [ Logger ] The new logger.
    def logger=(logger)
      @logger = logger
    end

    private

    # Gets the default Ethon logger - stdout.
    #
    # @example Get the default logger.
    #   Loggable.default_logger
    #
    # @return [ Logger ] The default logger.
    def default_logger
      logger = Logger.new($stdout)
      logger.level = Logger::INFO
      logger
    end

    # Get the Rails logger if it's defined.
    #
    # @example Get Rails' logger.
    #   Loggable.rails_logger
    #
    # @return [ Logger ] The Rails logger.
    def rails_logger
      defined?(::Rails) && ::Rails.respond_to?(:logger) && ::Rails.logger
    end
  end
  extend Loggable
end

Version data entries

6,803 entries across 6,801 versions & 24 rubygems

Version Path
ory-client-0.0.1.alpha109 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
avalara_sdk-2.4.26 vendor/bundle/ruby/2.6.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
ory-client-0.0.1.alpha108 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
ory-oathkeeper-client-0.38.23.beta1 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
ory-oathkeeper-client-0.38.22.beta1 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
ory-client-0.0.1.alpha107 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
ory-hydra-client-1.11.7 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
ory-client-0.0.1.alpha106 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
ory-hydra-client-1.11.6 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
ory-keto-client-0.8.0.alpha1 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
ory-client-0.0.1.alpha105 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
ory-client-0.0.1.alpha104 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
ory-client-0.0.1.alpha103 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
ory-hydra-client-1.11.5 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
cloudsmith-api-1.30.0 vendor/bundle/ruby/2.6.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
ory-client-0.0.1.alpha101 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
ory-client-0.0.1.alpha100 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
ory-hydra-client-1.11.4 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
ory-client-0.0.1.alpha99 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb
ory-client-0.0.1.alpha98 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/lib/ethon/loggable.rb