Module: DebugMixin

Defined in:
lib/conjur/debify.rb

Overview

This is used to turn on DEBUG notices.

Constant Summary collapse

DEBUG =
ENV['DEBUG'].nil? ? true : ENV['DEBUG'].downcase == 'true'
DOCKER =
method :docker_debug

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.debug(*a) ⇒ Object



38
39
40
# File 'lib/conjur/debify.rb', line 38

def self.debug *a
  $stderr.puts *a if DEBUG
end

.debug_write(*a) ⇒ Object



46
47
48
# File 'lib/conjur/debify.rb', line 46

def self.debug_write *a
  $stderr.write *a if DEBUG
end

.docker_debug(*a) ⇒ Object

you can give this to various docker methods to print output if debug is on



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/conjur/debify.rb', line 51

def self.docker_debug *a
  if a.length == 2 && a[0].is_a?(Symbol)
    debug a.last
  else
    a.each do |line|
      begin
        line = JSON.parse(line)
        line.keys.each do |k|
          debug line[k]
        end
      rescue JSON::ParserError
        # Docker For Mac is spitting out invalid JSON, so just print
        # out the line if parsing fails.
        debug line
      end
    end
  end
end

Instance Method Details

#debug(*a) ⇒ Object



34
35
36
# File 'lib/conjur/debify.rb', line 34

def debug *a
  DebugMixin.debug *a
end

#debug_write(*a) ⇒ Object



42
43
44
# File 'lib/conjur/debify.rb', line 42

def debug_write *a
  DebugMixin.debug_write *a
end