Class: Log4r::AzureOutputter
- Inherits:
-
Outputter
- Object
- Outputter
- Log4r::AzureOutputter
- Defined in:
- lib/log4r/outputter/azure_outputter.rb
Instance Attribute Summary collapse
-
#batch_count ⇒ Object
Returns the value of attribute batch_count.
-
#batched_records ⇒ Object
Returns the value of attribute batched_records.
-
#last_record ⇒ Object
Returns the value of attribute last_record.
-
#partition_key ⇒ Object
Returns the value of attribute partition_key.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
-
#vars ⇒ Object
readonly
Returns the value of attribute vars.
Instance Method Summary collapse
-
#flush ⇒ Object
Need to handle transient failure…
-
#initialize(_name, hash = {}) ⇒ AzureOutputter
constructor
A new instance of AzureOutputter.
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_count ⇒ Object
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_records ⇒ Object
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_record ⇒ Object
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_key ⇒ Object
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 |
#table ⇒ Object (readonly)
Returns the value of attribute table.
9 10 11 |
# File 'lib/log4r/outputter/azure_outputter.rb', line 9 def table @table end |
#vars ⇒ Object (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
#flush ⇒ Object
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 |