Chapter 09/circuit-oneops-1-master/components/cookbooks/cassandra/libraries/cassandra_util.rb
# Merge log4j property file with the config provided
Merge log4j property file with the config provided
Merge log4j property file with the config provided
def merge_log4j_directives(log4j_file, cfg)
      Chef::Log.info "Log4j file: #{log4j_file}, log4j directive entries: #{cfg}"
      bak_file = log4j_file.sub('.properties', '_template.properties')
      File.rename(log4j_file, bak_file)
      log_props = load_properties(bak_file)
      cfg.each_key { |key|
        val = parse_json(cfg[key])
        log_props[key] = val
      }
      Chef::Log.info "Merged cassandra log4j : #{log_props.to_yaml}"
      File.open(log4j_file, 'w') { |f|
        log_props.each {|key,value| f.puts "#{key}=#{value}\n" }
        Chef::Log.info "Saved Log4j config to #{log4j_file}"
      }
  end
def merge_log4j_directives ( log4j_file , cfg ) Chef :: Log . info "Log4j file: #{log4j_file}, log4j directive entries: #{cfg}" bak_file = log4j_file . sub ( '.properties' , '_template.properties' ) File . rename ( log4j_file , bak_file ) log_props = load_properties ( bak_file ) cfg . each_key { | key | val = parse_json ( cfg [ key ] ) log_props [ key ] = val } Chef :: Log . info "Merged cassandra log4j : #{log_props.to_yaml}" File . open ( log4j_file , 'w' ) { | f | log_props . each { | key , value | f . puts "#{key}=#{value}\n" } Chef :: Log . info "Saved Log4j config to #{log4j_file}" } end
Merge log4j property file with the config provided
Merge log4j property file with the config provided
# Always backup
log4j_file
<not_specific>
cfg
<not_specific>