Sha256: db279c2bebc2e57a454d51942620c84fe3205064788751a5de2c251d765d3881

Contents?: true

Size: 651 Bytes

Versions: 8

Compression:

Stored size: 651 Bytes

Contents

# frozen_string_literal: true

class Ultravisor
  module LoggingHelpers
    private

    attr_reader :logger

    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
          false
        end

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

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
service_skeleton-2.2.0 ultravisor/lib/ultravisor/logging_helpers.rb
service_skeleton-2.1.0 ultravisor/lib/ultravisor/logging_helpers.rb
service_skeleton-1.0.5 ultravisor/lib/ultravisor/logging_helpers.rb
service_skeleton-2.0.2 ultravisor/lib/ultravisor/logging_helpers.rb
service_skeleton-2.0.1 ultravisor/lib/ultravisor/logging_helpers.rb
service_skeleton-2.0.0 ultravisor/lib/ultravisor/logging_helpers.rb
service_skeleton-1.0.4 ultravisor/lib/ultravisor/logging_helpers.rb
service_skeleton-0.0.0.1.ENOTAG ultravisor/lib/ultravisor/logging_helpers.rb