Home > OS >  I want my heroku bot to log into a txt file
I want my heroku bot to log into a txt file

Time:08-22

I know Heroku has an ephemeral hard drive and I dont want to lose my log file so I uploaded my bot to GitHub as a private repo and linked to Heroku. But it didnt write any thing to log file and it has been working for two days. Can you edit GitHub files during runtime or I need different approach.

def log(line):
  file_object = open("log.txt", "a")
  file_object.write(line)

CodePudding user response:

In order to edit GitHub files, you need to use the GitHub API (https://docs.github.com/en/rest). There are plenty of python packages that have been written for the GitHub API, so you shouldn’t need to send raw requests. (Bear in mind that this probably isn’t the best way of storing data).

  • Related