Permalink
Browse files

-Updated lager config

-Created Array Attributes for Lager Log Files.
-Added an Array and an array search to the library helper. When processing config, sometimes there is a need for a keyless cofig line.  This array and array search enabled the generation.
-removed needless casts in config.rb. Still not totally sure what those are for.
  • Loading branch information...
1 parent 80b3312 commit a69d096ac825a6cc1e35fc4bbdf97b016b2bc7d9 @densone committed Dec 6, 2011
Showing with 22 additions and 26 deletions.
  1. +1 −1 attributes/default.rb
  2. +4 −16 attributes/lager.rb
  3. +16 −4 libraries/riak_template_helper.rb
  4. +0 −5 recipes/config.rb
  5. +1 −0 templates/default/app.config.erb
View
2 attributes/default.rb
@@ -25,5 +25,5 @@
include_attribute "riak::sasl"
include_attribute "riak::err"
include_attribute "riak::luwak"
-#include_attribute "riak::lager"
+include_attribute "riak::lager"
include_attribute "riak::sysmon"
View
20 attributes/lager.rb
@@ -23,20 +23,8 @@
default.riak.lager.crash_log_msg_size = 65536
default.riak.lager.crash_log_size = 10485760
default.riak.lager.error_logger_redirect = true
-default.riak.lager.handlers.lagerfile_backend =
-
-#Lager Error Log Params
-default.riak.lager.handlers.error_log.name = "/var/log/riak/error.log"
-default.riak.lager.handlers.error_log.type = :error
-default.riak.lager.handlers.error_log.size = 10485760
-default.riak.lager.handlers.error_log.date_format = "$D0"
-default.riak.lager.handlers.error_log.rotate_every = 5
-
-#Lager Console Log Params.
-default.riak.lager.handlers.console_log = "/var/log/riak/error.log"
-default.riak.lager.handlers.console_log.type = :console
-default.riak.lager.handlers.console_log.size = 10485760
-default.riak.lager.handlers.console_log.date_format = "$D0"
-default.riak.lager.handlers.console_log.rotate_every = 5
-
+#The following two attributes are KEYLESS.
+#They hold these values:[NAME,LOG_LEVEL,SIZE,DATE_FORMAT,ROTATION_TO_KEEP]
+default.riak.lager.handlers.lager_file_backend.lager_error_log = ["/var/log/riak/error.log", :error, 10485760, "$D0", 5]
+default.riak.lager.handlers.lager_file_backend.lager_console_log = ["/var/log/riak/console.log", :info, 10485760, "$D0", 5]
View
20 libraries/riak_template_helper.rb
@@ -31,7 +31,7 @@ def value_to_erlang(v, depth=1)
to_erlang_config(v, depth+1)
when String
"\"#{v}\""
- when Array
+ when Array
"[" << v.map {|i| value_to_erlang(i) }.join(", ") << "]"
else
v.to_s
@@ -43,12 +43,24 @@ def to_erlang_config(hash, depth = 1)
padding = ' ' * depth
parent_padding = ' ' * (depth-1)
values = hash.map do |k,v|
- "{#{k}, #{value_to_erlang(v, depth)}}"
+ if KEYLESS_ATTRIBUTES.include?(k)
+ "{" << v.map {|i| "#{value_to_erlang(i, depth)}"}.join(", ") << "}"
+ else
+ "{#{k}, #{value_to_erlang(v, depth)}}"
+ end
end.join(",\n#{padding}")
"[\n#{padding}#{values}\n#{parent_padding}]"
end
-
+
+ #There are several configurations that are not key/value. They should be added to KEYLESS_ATTRIBUTES.
+ #A sample of this wold be the lager configuration.
+ #{"{{platform_log_dir}}/error.log", error, 10485760, "$D0", 5}
+ KEYLESS_ATTRIBUTES = ['lager_error_log','lager_console_log']
+
+ #Remove these configs. This will make sure package and erlang vms are not processed into the riak app.config.
RIAK_REMOVE_CONFIGS = ['package', 'erlang']
+
+
RIAK_TRANSLATE_CONFIGS = {
'core' => 'riak_core',
'kv' => 'riak_kv',
@@ -124,7 +136,7 @@ def prepare_app_config(riak)
"smp" => "-smp",
"env_vars" => "-env"
}
-
+
def prepare_vm_args(config)
config.map do |k,v|
key = RIAK_VM_ARGS[k.to_s]
View
5 recipes/config.rb
@@ -39,11 +39,6 @@
node.riak.kernel.delete(:inet_dist_listen_max)
end
-#erlang error logger warnings
-node.riak.erlang.error_logger_warnings = (node.riak.erlang.error_logger_warnings).to_s.to_sym
-
-# lager. rb
-node.riak.lager.handlers.lager_console_backend = (node.riak.lager.handlers.lager_console_backend).to_s.to_sym
# kv.rb
node.riak.kv.storage_backend = (node.riak.kv.storage_backend).to_s.to_sym
View
1 templates/default/app.config.erb
@@ -1 +1,2 @@
<%= to_erlang_config(prepare_app_config(node[:riak])) -%>.
+

0 comments on commit a69d096

Please sign in to comment.