Sha256: e801ee1809af184f684440f3daa5940ca5692439a37329fa3443b5d22899189c

Contents?: true

Size: 603 Bytes

Versions: 3

Compression:

Stored size: 603 Bytes

Contents

# frozen_string_literal: true

class ServiceSkeleton
  module LoggingHelpers
    private

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

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
service_skeleton-0.0.0.44.g75d07d7 lib/service_skeleton/logging_helpers.rb
service_skeleton-0.0.0.43.g678698a lib/service_skeleton/logging_helpers.rb
service_skeleton-0.0.0.41.g9507cda lib/service_skeleton/logging_helpers.rb