Sha256: 7b696b14b665be0289d49ed4edfe0be19617b788ba84a50b36386c680ddd2262

Contents?: true

Size: 896 Bytes

Versions: 1

Compression:

Stored size: 896 Bytes

Contents

# frozen_string_literal: true

require "semantic_logger"

module PUNK
  include SemanticLogger::Loggable

  def self.profile_info(name, **kwargs)
    logger.info "Started #{name}", kwargs.sanitize.inspect
    logger.measure_info("Completed #{name}") { logger.tagged(name) { yield } }
  end

  def self.profile_debug(name, **kwargs)
    logger.debug "Started #{name}", kwargs.sanitize.inspect
    logger.measure_debug("Completed #{name}") { logger.tagged(name) { yield } }
  end

  def self.profile_trace(name, **kwargs)
    logger.trace "Started #{name}", kwargs.sanitize.inspect
    logger.measure_trace("Completed #{name}") { logger.tagged(name) { yield } }
  end

  SemanticLogger.default_level =
    case PUNK.store.args.task
    when "console", "script"
      :info
    when "spec"
      :debug
    else
      :trace
    end
  SemanticLogger.add_appender(io: $stdout, formatter: :color)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
punk-0.4.1 lib/punk/core/logger.rb