Class: Log4r::AzureOutputter

Inherits:
Outputter
  • Object
show all
Defined in:
lib/log4r/outputter/azure_outputter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_name, hash = {}) ⇒ AzureOutputter

Returns a new instance of AzureOutputter.



15
16
17
18
19
20
# File 'lib/log4r/outputter/azure_outputter.rb', line 15

def initialize(_name, hash={})
  super(_name, hash)
  validate(hash)
  @batched_records = []
  @hostname = (`hostname -f`).chomp # For some strange reason, Socket.gethostname seems to get inserted as a Byte[] Array into the Azure Table? I can't figure it out, so I'm using this ugly hack instead.
end

Instance Attribute Details

#batch_countObject

Returns the value of attribute batch_count.



11
12
13
# File 'lib/log4r/outputter/azure_outputter.rb', line 11

def batch_count
  @batch_count
end

#batched_recordsObject

Returns the value of attribute batched_records.



12
13
14
# File 'lib/log4r/outputter/azure_outputter.rb', line 12

def batched_records
  @batched_records
end

#last_recordObject

Returns the value of attribute last_record.



13
14
15
# File 'lib/log4r/outputter/azure_outputter.rb', line 13

def last_record
  @last_record
end

#partition_keyObject

Returns the value of attribute partition_key.



10
11
12
# File 'lib/log4r/outputter/azure_outputter.rb', line 10

def partition_key
  @partition_key
end

#tableObject (readonly)

Returns the value of attribute table.



9
10
11
# File 'lib/log4r/outputter/azure_outputter.rb', line 9

def table
  @table
end

#varsObject (readonly)

Returns the value of attribute vars.



8
9
10
# File 'lib/log4r/outputter/azure_outputter.rb', line 8

def vars
  @vars
end

Instance Method Details

#flushObject

Need to handle transient failure…



23
24
25
26
27
28
29
30
31
# File 'lib/log4r/outputter/azure_outputter.rb', line 23

def flush
  Logger.log_internal { "Inserting #{@batch_count} records into #{@table}" }
  batch = Azure::Table::Batch::new @table, @partition_key
  @batched_records.each do |record|
    batch.insert record["RowKey"], record.reject { |k| k == "RowKey" }
  end
  result = @azure_table.execute_batch batch
  @batched_records = []
end