Class: Jatai::Commands::Logs
Constant Summary collapse
- DEFAULT_TAIL =
100
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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jatai/commands/logs.rb', line 8 def execute( = {}) require_auth! slug = app_slug tail = .fetch("tail", DEFAULT_TAIL).to_s logs = api.get("/api/v1/apps/#{slug}/logs", params: { tail: tail }) if logs.nil? || logs.empty? info("Nenhum log disponÃvel.") return end logs.each do |entry| = entry["timestamp"] source = entry["source"] level = entry["level"] = entry["message"] level_str = case level when "error" then pastel.red(level) when "warn" then pastel.yellow(level) when "info" then pastel.green(level) else pastel.dim(level || "log") end puts "#{pastel.dim()} #{pastel.cyan(source)} [#{level_str}] #{}" end rescue Api::Client::ApiError => e error("Erro: #{e.}") end |