Class: ProviderDSL::Log
- Inherits:
-
Object
- Object
- ProviderDSL::Log
- Includes:
- Singleton
- Defined in:
- lib/provider_dsl/log.rb
Overview
A simple logger
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
-
#debug(message) ⇒ Object
Returns the value of attribute debug.
Instance Method Summary collapse
- #confidential(regex) ⇒ Object
-
#initialize ⇒ Log
constructor
A new instance of Log.
- #log(message) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Log
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
#callback ⇒ Object
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() @confidential.each { |regex| .gsub!(regex, '******') } @log << @callback.call() unless @callback.nil? end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/provider_dsl/log.rb', line 32 def to_s @log.join("\n") end |