Class: Jatai::Commands::LogsExport

Inherits:
Base
  • Object
show all
Defined in:
lib/jatai/commands/logs_export.rb

Instance Method Summary collapse

Methods inherited from Base

#api, #app_slug, #error, #info, #pastel, #project_config, #require_auth!, #success

Instance Method Details

#execute(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/jatai/commands/logs_export.rb', line 6

def execute(options = {})
  require_auth!
  slug = app_slug

  format = options.fetch("format", "json")
  params = { export_format: format }
  params[:since] = options["since"] if options["since"]
  params[:until] = options["until"] if options["until"]
  params[:level] = options["level"] if options["level"]

  result = api.get("/api/v1/apps/#{slug}/logs/export", params: params)

  case result
  when Array
    puts JSON.pretty_generate(result)
  when Hash
    puts JSON.pretty_generate(result)
  when String
    puts result
  else
    puts result
  end
rescue Api::Client::ApiError => e
  error("Erro: #{e.message}")
end