Sha256: 55d474a8eb50ffd1e519df25804f342b5f288d6fdc75cd14e1196dd0a093f1d5

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

class RFlow
  module Components
    module Log
      module Extensions
        module LogExtension
          def self.extended(base_data)
            base_data.data_object ||= {'timestamp' => 0, 'level' => 'INFO', 'text' => ''}
          end

          def timestamp; data_object['timestamp']; end
          def timestamp=(new_timestamp); data_object['timestamp'] = new_timestamp; end
          def level; data_object['level']; end
          def level=(new_level); data_object['level'] = new_level; end
          def text; data_object['text']; end
          def text=(new_text); data_object['text'] = new_text; end
        end
      end

      SCHEMA_DIRECTORY = ::File.expand_path(::File.join(::File.dirname(__FILE__), '..', '..', '..', 'schema'))

      SCHEMA_FILES = {
        'log.avsc' => 'RFlow::Message::Data::Log',
      }

      SCHEMA_FILES.each do |file_name, data_type_name|
        schema_string = ::File.read(::File.join(SCHEMA_DIRECTORY, file_name))
        RFlow::Configuration.add_available_data_type data_type_name, 'avro', schema_string
      end

      RFlow::Configuration.add_available_data_extension('RFlow::Message::Data::Log',
                                                        RFlow::Components::Log::Extensions::LogExtension)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rflow-1.3.0 lib/rflow/components/log.rb
rflow-1.3.0a1 lib/rflow/components/log.rb
rflow-1.2.0 lib/rflow/components/log.rb