How to execute print command in google engine?

I am developing a Google engine, and I want to print the values ​​that are sent to the server from a browser. When I insert print commands into my handlers, nothing is printed on the console on which the local server is running!

How do I get around this?

Gough

+4
source share
5 answers

Instead of print values, use the logging module. This is usually a good practice, as it means that you can leave it in a convenient debugging release, even when you are working.

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

By default, dev_appserver.py will not display messages below the INFO logging level, but you can run dev_appserver.py with the --debug flag, and then you can see the output from the lower level logging.DEBUG and scatter various entries in your code, for example:

 logging.debug("some helpful debug info") 

If you leave them as soon as your application is operational, they will be visible in your application’s administrative area in the logs section.

+8
source

As @Chris Farmiloe said, you should use the registration module. Google appengine by default supports the logging modlue function. You can see the different log levels for your applications in the appengine console. The registration module is useful in a production environment. Where you can see all your magazines. For general use of information

 logging.info('This is just for information') 
+1
source
 self.response.out.write("Hallo World") 
0
source

Using the Go language (I don't know if this works with other languages), you can do it through the appengine.Context.Debugf function https://developers.google.com/appengine/docs/go/reference#Context

 func yourfunction (r *http.Request){ c := appengine.NewContext(r) c.Debugf("%v\n","Your message") .... } 

You may need to set the minimum processing level on the development server:

 dev_appserver.py --log_level debug [your application] 
0
source

When I need a quick and dirty way to print out some information, I do this:

 assert False, "Helpful information" 

after receiving the necessary information, I delete the line.

-1
source

Source: https://habr.com/ru/post/1347078/


All Articles