write heroku logs
require 'heroku-api'
heroku = Heroku::API.new(api_key: 'YOUR_API_KEY')
logs = heroku.get_logs('YOUR_APP_NAME')
puts logs.body
Explanation:
1. require 'heroku-api'
: This line imports the 'heroku-api' gem, allowing you to use its functionalities in your Ruby code.
heroku = Heroku::API.new(api_key: 'YOUR_API_KEY')
: Here, a new instance of the Heroku API is created and stored in the variableheroku
. You need to replace'YOUR_API_KEY'
with your actual Heroku API key.logs = heroku.get_logs('YOUR_APP_NAME')
: This line fetches the logs for a specific Heroku app. Replace'YOUR_APP_NAME'
with the name of the app whose logs you want to retrieve.puts logs.body
: This command prints the body of the logs to the console. Thelogs
variable contains the fetched logs, and.body
retrieves the content of the logs for display.
Note: Ensure you have the heroku-api
gem installed in your Ruby environment to use the Heroku::API
functionality. Additionally, replace 'YOUR_API_KEY'
and 'YOUR_APP_NAME'
with your actual API key and app name respectively.