where do print statements go after being deployed?

hi, do print statements print the deploy logs? and if so is there any special variable i have to activate to ensure it prints or will it print in every case?
29 Replies
Percy
Percy7mo ago
Project ID: b5b8b5dd-ede7-45e7-93a7-4b369707abc8
jimbobjunior
jimbobjunior7mo ago
b5b8b5dd-ede7-45e7-93a7-4b369707abc8
Brody
Brody7mo ago
as long as you are printing unbuffered to stdout / stderr the logs will show in the deployment logs
jimbobjunior
jimbobjunior7mo ago
do you happen to know why none of the print statements in teh following code are being printed in teh deploy logs?
jimbobjunior
jimbobjunior7mo ago
No description
jimbobjunior
jimbobjunior7mo ago
this is my build log:
No description
Brody
Brody7mo ago
not really, but why is your code pushing itself to github?
jimbobjunior
jimbobjunior7mo ago
because i want to update the code daily - i have a function called scrapeNews which I've commented out which will change the code base. i then want to push it every day the overarching issue is that its not seeming to push to github and im trying to figure out why - hence wanting print statements. i know my script is fine because when i run it locally it pushes to github + prints everything
Brody
Brody7mo ago
how about just use a database, you should not be doing what you're doing, it's extremely bad practice
jimbobjunior
jimbobjunior7mo ago
why is it bad practice?
Brody
Brody7mo ago
your code updating its own github repo, you are asking for trouble
jimbobjunior
jimbobjunior7mo ago
yes i see, i will move to a database later but i just want to get a functioning prototype for now and this is the last step
Brody
Brody7mo ago
alright is that function is ran by the cron scheduler and only cron?
jimbobjunior
jimbobjunior7mo ago
yeah
Brody
Brody7mo ago
then its only gonna be ran at that time, in the utc timezone
jimbobjunior
jimbobjunior7mo ago
yeah but its not running or if it is its not pushing to github but it works completely when i run it locally which is why im confused
Brody
Brody7mo ago
is it 11:46 UTC yet? the times you see here are not UTC
jimbobjunior
jimbobjunior7mo ago
yes the time is correct i know this because i run it locally like a minute before and it works
Brody
Brody7mo ago
do you live in the UTC timezone?
jimbobjunior
jimbobjunior7mo ago
no but the time is not the issue because i had deployed this code and left it up for an entire month while i was working on other projects... the function never ran
Brody
Brody7mo ago
oh i know!! you start the schedular inside this if block if __name__ == "__main__": but you are using gunicorn (good) when using gunicorn __name__ will not equal "__main__" so the scheduler will never start, start the scheduler outside of that if block
jimbobjunior
jimbobjunior7mo ago
let me try that!
Brody
Brody7mo ago
still keep the timezone stuff in mind tho, that stuff is still valid
jimbobjunior
jimbobjunior7mo ago
you were right once i moved the scheduler outside main it worked but i think there are major issues getting the git commands to work on the deployed machine... keeps saying directory isnt a git repo... i will look at moving teh content to a database
Brody
Brody7mo ago
it's not a git repo because there's no .git folder, this is automatically omitted when you push the repo to github
jimbobjunior
jimbobjunior7mo ago
is there any way aruond this?
Brody
Brody7mo ago
nope, that's how github works please for your own sake, store the data in a database
jimbobjunior
jimbobjunior7mo ago
hahaha alright thanks for all your help
Brody
Brody7mo ago
no problem!