Sha256: c43828f701422460a5dbb7dabb247cb1bfe6d715307d630c856ce96bd97a9ee7

Contents?: true

Size: 774 Bytes

Versions: 1

Compression:

Stored size: 774 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)
        loga_loga.context { 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

1 entries across 1 versions & 1 rubygems

Version Path
mr_loga_loga-0.2.0 lib/mr_loga_loga/instance_methods.rb