Skip to content

Commit

Permalink
Tag logs with "[hiera_backend]"
Browse files Browse the repository at this point in the history
  • Loading branch information
quixoten committed Mar 3, 2014
1 parent cf3ac02 commit 811ae35
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/hiera/backend/eyaml_backend.rb
Expand Up @@ -13,7 +13,7 @@ class Eyaml_backend
attr_reader :extension

def initialize(cache = nil)
Hiera.debug("Hiera eYAML backend starting")
debug("Hiera eYAML backend starting")

@cache = cache || Filecache.new
@extension = Config[:eyaml][:extension] || "eyaml"
Expand All @@ -24,10 +24,10 @@ def lookup(key, scope, order_override, resolution_type)

parse_options(scope)

Hiera.debug("Looking up #{key} in eYAML backend")
debug("Looking up #{key} in eYAML backend")

Backend.datasources(scope, order_override) do |source|
Hiera.debug("Looking for data source #{source}")
debug("Looking for data source #{source}")
eyaml_file = Backend.datafile(:eyaml, scope, source, extension) || next

next unless File.exists?(eyaml_file)
Expand All @@ -43,7 +43,7 @@ def lookup(key, scope, order_override, resolution_type)
# multiple times if the resolution type is array or hash but that
# should be expected as the logging will then tell the user ALL the
# places where the key is found.
Hiera.debug("Found #{key} in #{source}")
debug("Found #{key} in #{source}")

# for array resolution we just append to the array whatever
# we find, we then goes onto the next file and keep adding to
Expand Down Expand Up @@ -71,9 +71,13 @@ def lookup(key, scope, order_override, resolution_type)

private

def debug(message)
Hiera.debug("[eyaml_backend]: #{message}")
end

def decrypt(data)
if encrypted?(data)
Hiera.debug("Attempting to decrypt")
debug("Attempting to decrypt")

parser = Eyaml::Parser::ParserFactory.hiera_backend_parser
tokens = parser.parse(data)
Expand Down Expand Up @@ -117,7 +121,7 @@ def parse_options(scope)
Config[:eyaml].each do |key, value|
parsed_value = Backend.parse_string(value, scope)
Eyaml::Options[key] = parsed_value
Hiera.debug("Set option: #{key} = #{parsed_value}")
debug("Set option: #{key} = #{parsed_value}")
end

Eyaml::Options[:source] = "hiera"
Expand Down

0 comments on commit 811ae35

Please sign in to comment.