Sha256: 28a1db82042185ac4efdfb2035509bb4f227d24fad8e361ef389c8b56cfa8333

Contents?: true

Size: 647 Bytes

Versions: 2

Compression:

Stored size: 647 Bytes

Contents

# frozen_string_literal: true

require 'pp'
require 'log_marker/version'
require 'log_marker/config'

module LogMarker
  MARK_METHODS = %w(p pp puts)

  MARK_METHODS.each do |name|
    define_method("#{name}!") do |*args|
      logging_with_marker do
        send(name, *args)
      end
    end
  end

  def logging_with_marker(&block)
    puts marker

    result = block.call

    puts marker.reverse

    result
  end

  def marker
    [
      LogMarker.marker.respond_to?(:call) ? LogMarker.marker.call : LogMarker.marker.to_s,
      "\n" * 5
    ]
  end

  def ml(*args)
    send(LogMarker.ml_alias, *args)
  end
end

Object.include LogMarker

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
log_marker-0.1.2 lib/log_marker.rb
log_marker-0.1.1 lib/log_marker.rb