Sha256: 85c53d0393dc6225da6f044ee6cff135e93afde3ef0fd967dd300e34596de57c

Contents?: true

Size: 799 Bytes

Versions: 3

Compression:

Stored size: 799 Bytes

Contents

# frozen_string_literal: true

module MrLogaLoga
  # == Description
  #
  # Instance methods to be attached when including the main module.
  #
  # @api private
  module InstanceMethods
    def loga_context
      { class_name: self.class.name }
    end

    # A shorthand method to use in your classes
    def logger
      if loga_loga.is_a?(MrLogaLoga::Logger)
        MrLogaLoga::LoggerProxy.new(loga_loga, -> { loga_context })
      else
        loga_loga
      end
    end

    # Define the underlying logger to be used. Overwrite this to use a specific logger instance
    def loga_loga
      @loga_loga ||= if defined?(Rails.logger)
                       Rails.logger
                     else
                       MrLogaLoga.configuration.logger
                     end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mr_loga_loga-0.1.5 lib/mr_loga_loga/instance_methods.rb
mr_loga_loga-0.1.4 lib/mr_loga_loga/instance_methods.rb
mr_loga_loga-0.1.3 lib/mr_loga_loga/instance_methods.rb