Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do execute print command in google app engine?

Am doing development on google app engine and i want to print out values that are sent to the server from the browser. When i insert the print commands in my handlers nothing get printed on the console running the local server!

How do i get around this?

Gath

like image 835
gath Avatar asked Feb 25 '23 14:02

gath


2 Answers

Rather than just printing out values, use the logging module. This is generally good practice anyway as it means you can potentially leave in some handy debug output even when you are running in production mode.

import logging
logging.error("This is an error message that will show in the console")

By default dev_appserver.py will not show any messages below logging-level INFO, but you can run dev_appserver.py with the --debug flag and then you will be able to see output from the lower logging.DEBUG level and scatter various logging calls in your code like:

logging.debug("some helpful debug info")

If you leave these in once your app is in production, then these will be visible in your app's admin area in the logs section.

like image 194
Chris Farmiloe Avatar answered Mar 04 '23 06:03

Chris Farmiloe


As @Chris Farmiloe suggested you should use the logging module . Google appengine by default supports logging modlue. You can see various levels of logs for your applications in appengine console. Logging module comes in handy in the production enviroment. Where you can see all your logs. For general info use

logging.info('This is just for information')
like image 25
Abdul Kader Avatar answered Mar 04 '23 04:03

Abdul Kader