Sha256: 7ff92b443b898695f2e7ec18e8bd83a619ff581e54d62a006d004b3c3a3d28c9

Contents?: true

Size: 840 Bytes

Versions: 3

Compression:

Stored size: 840 Bytes

Contents

# frozen_string_literal: true

require_relative "utils"

module RubyNext
  class << self
    attr_accessor :silence_warnings
    attr_reader :debug_enabled

    def warn(msg)
      return if silence_warnings

      Kernel.warn msg
    end

    def debug_source(source, filepath = nil)
      return unless debug_enabled

      return if debug_filter && !filepath.include?(debug_filter)

      $stdout.puts Utils.source_with_lines(source, filepath)
    end

    def debug_enabled=(val)
      return if val.nil?

      @debug_enabled = !(val == "false" || val == "0")

      return unless debug_enabled

      return if val == "true" || val == "1"

      @debug_filter = val
    end

    private

    attr_reader :debug_filter
  end

  self.silence_warnings = ENV["RUBY_NEXT_WARN"] != "false"
  self.debug_enabled = ENV["RUBY_NEXT_DEBUG"]
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-next-core-0.6.0 lib/ruby-next/logging.rb
ruby-next-core-0.5.3 lib/ruby-next/logging.rb
ruby-next-core-0.5.2 lib/ruby-next/logging.rb