Sha256: 94498dcc12f193f11832e36f1f70290ce62760addaca7a67d4f70876e45f033b
Contents?: true
Size: 761 Bytes
Versions: 7
Compression:
Stored size: 761 Bytes
Contents
# frozen_string_literal: true module GoogleDistanceMatrix # Logger class for Google Distance Matrix class Logger PREFIXES = %w[google_distance_matrix].freeze LEVELS = %w[fatal error warn info debug].freeze attr_reader :backend def initialize(backend = nil) @backend = backend end LEVELS.each do |level| define_method level do |*args| options = args.extract_options!.with_indifferent_access msg = args.first tags = PREFIXES.dup.concat Array.wrap(options[:tag]) backend&.public_send level, tag_msg(msg, tags) end end private def tag_msg(msg, tags) msg_buffer = tags.map { |tag| "[#{tag}]" } msg_buffer << msg msg_buffer.join ' ' end end end
Version data entries
7 entries across 7 versions & 1 rubygems