Class: ProviderDSL::Log

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/provider_dsl/log.rb

Overview

A simple logger

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLog

Returns a new instance of Log.



10
11
12
13
14
15
# File 'lib/provider_dsl/log.rb', line 10

def initialize
  @log = []
  @confidential = []
  @callback = nil
  @debug = ENV['DSL_DEBUG'] == 'true'
end

Instance Attribute Details

#callbackObject

Returns the value of attribute callback.



8
9
10
# File 'lib/provider_dsl/log.rb', line 8

def callback
  @callback
end

#debug(message) ⇒ Object

Returns the value of attribute debug.



8
9
10
# File 'lib/provider_dsl/log.rb', line 8

def debug
  @debug
end

Instance Method Details

#confidential(regex) ⇒ Object



27
28
29
30
# File 'lib/provider_dsl/log.rb', line 27

def confidential(regex)
  @confidential << regex
  @confidential.uniq!
end

#log(message) ⇒ Object



17
18
19
20
21
# File 'lib/provider_dsl/log.rb', line 17

def log(message)
  @confidential.each { |regex| message.gsub!(regex, '******') }
  @log << message
  @callback.call(message) unless @callback.nil?
end

#to_sObject



32
33
34
# File 'lib/provider_dsl/log.rb', line 32

def to_s
  @log.join("\n")
end