Module: Scribe
- Defined in:
- lib/scribe-logger.rb,
lib/scribe_logger/scribe.rb,
lib/scribe_logger/version.rb,
lib/scribe_logger/scribe_connection.rb
Defined Under Namespace
Classes: ScribeConnection
Constant Summary collapse
- VERSION =
"0.1.0"
- @@default_config =
{ :scribe_host => '127.0.0.1', :scribe_port => 1464, :noscribe => false, # Set this to true if you dont want to log to scribe-logger. :tzone => 'Kolkata', :evented => false, }
Class Method Summary collapse
Class Method Details
.loggers(config) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/scribe_logger/scribe.rb', line 12 def loggers(config) config = merge_defaults(config) scribe_connection = connected_scribe(config) database = YAML.load(open(config[:schema_uri]).read) hostname = IO.popen('hostname').read.strip loggers = database['tables'].map do |table_name, table_def| columns = [] table_def['columns'].each do |col_name, col_def| args = [col_name] + col_def.values_at('default', 'type', 'partition') columns << ActiveRecord::ConnectionAdapters::HiveColumn.new(*args) end = { :database => config[:database] || database['name'], :table => table_name, :columns => columns, :noscribe => config[:noscribe], :tzone => config[:tzone], :writes_to_legacy_scribe => database['writes_to_legacy_scribe'] || false, :hostname => hostname, } logger_name = "log_#{table_name.singularize.underscore}" logger_proc = make_logger_proc(scribe_connection, ) [logger_name, logger_proc] end Module.new { loggers.each do |name, proc| define_method(name, proc) module_function(name) end } end |