Sha256: 7b51820c2425cb20a59b746ef0100d9563daa073090e9f6febe1b26cfbf42167

Contents?: true

Size: 896 Bytes

Versions: 14

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

14 entries across 14 versions & 1 rubygems

Version Path
punk-0.3.6 lib/punk/core/logger.rb
punk-0.3.5 lib/punk/core/logger.rb
punk-0.3.4 lib/punk/core/logger.rb
punk-0.3.3 lib/punk/core/logger.rb
punk-0.3.2 lib/punk/core/logger.rb
punk-0.3.1 lib/punk/core/logger.rb
punk-0.2.0 lib/punk/core/logger.rb
punk-0.1.4 lib/punk/core/logger.rb
punk-0.1.3 lib/punk/core/logger.rb
punk-0.1.2 lib/punk/core/logger.rb
punk-0.1.0 lib/punk/core/logger.rb
punk-0.0.3 lib/punk/core/logger.rb
punk-0.0.2 lib/punk/core/logger.rb
punk-0.0.1 lib/punk/core/logger.rb