Sha256: a0375ef761566af30fcccc47411c78802bc1fafec87c40125eb9327f327cb35d

Contents?: true

Size: 600 Bytes

Versions: 13

Compression:

Stored size: 600 Bytes

Contents

# frozen_string_literal: true

module ServiceSkeleton
  module LoggingHelpers
    private

    def log_exception(ex, progname = nil)
      #:nocov:
      progname ||= "#{self.class.to_s}##{caller_locations(2, 1).first.label}"

      logger.error(progname) do
        explanation = if block_given?
          yield
        else
          nil
        end

        (["#{explanation}#{explanation ? ": " : ""}#{ex.message} (#{ex.class})"] + ex.backtrace).join("\n  ")
      end
      #:nocov:
    end

    def logloc
      loc = caller_locations.first
      "#{self.class}##{loc.label}"
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
service_skeleton-2.2.0 lib/service_skeleton/logging_helpers.rb
service_skeleton-2.1.0 lib/service_skeleton/logging_helpers.rb
service_skeleton-1.0.5 lib/service_skeleton/logging_helpers.rb
service_skeleton-2.0.2 lib/service_skeleton/logging_helpers.rb
service_skeleton-2.0.1 lib/service_skeleton/logging_helpers.rb
service_skeleton-2.0.0 lib/service_skeleton/logging_helpers.rb
service_skeleton-1.0.4 lib/service_skeleton/logging_helpers.rb
service_skeleton-0.0.0.1.ENOTAG lib/service_skeleton/logging_helpers.rb
service_skeleton-1.0.3 lib/service_skeleton/logging_helpers.rb
service_skeleton-1.0.2 lib/service_skeleton/logging_helpers.rb
service_skeleton-1.0.1 lib/service_skeleton/logging_helpers.rb
service_skeleton-0.0.0.49.g47046b9 lib/service_skeleton/logging_helpers.rb
service_skeleton-0.0.0.48.g4a40599 lib/service_skeleton/logging_helpers.rb