Sha256: 8880e303fb5cfcb31fdd3abe1b1f105ef77087cca27c99d56b1d9191de283a67

Contents?: true

Size: 878 Bytes

Versions: 13

Compression:

Stored size: 878 Bytes

Contents

require 'flydata/helper/base_action'
require 'flydata/util/file_util'
require 'flydata/api_client'

module Flydata
  module Helper
    module Action
      class SendLogs <  BaseAction
        include Util::FileUtil

        DEFAULT_NUM_OF_LINES = 100

        def initialize(config)
          super
          @api_client = ApiClient.instance
        end

        def execute(opts = {})
          num_of_lines = DEFAULT_NUM_OF_LINES
          action_id = opts[:id]
          begin
            num_of_lines = opts[:config_hash][:num_of_lines].to_i
          rescue
            # Use default number of lines if config is nil, mal-formed etc
          end
          log_info("Sending logs - num_of_lines:#{num_of_lines}")
          tailed_lines = tail(FLYDATA_LOG, num_of_lines)
          @api_client.agent.send_logs(action_id, tailed_lines)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
flydata-0.8.10.2 lib/flydata/helper/action/send_logs.rb
flydata-0.8.10.1 lib/flydata/helper/action/send_logs.rb
flydata-0.8.9.11 lib/flydata/helper/action/send_logs.rb
flydata-0.8.10 lib/flydata/helper/action/send_logs.rb
flydata-0.8.9 lib/flydata/helper/action/send_logs.rb
flydata-0.8.8 lib/flydata/helper/action/send_logs.rb
flydata-0.8.7 lib/flydata/helper/action/send_logs.rb
flydata-0.8.6 lib/flydata/helper/action/send_logs.rb
flydata-0.8.5 lib/flydata/helper/action/send_logs.rb
flydata-0.8.4 lib/flydata/helper/action/send_logs.rb
flydata-0.8.3 lib/flydata/helper/action/send_logs.rb
flydata-0.8.2 lib/flydata/helper/action/send_logs.rb
flydata-0.8.1 lib/flydata/helper/action/send_logs.rb