Can someone show me an example of logging client-side events in JavaScript to AppEngine’s server-side Python logging module? I’d like to log events of the same five severity levels, but from client-side code, not just server-side code as is described in the App Engine logging docs.
If there’s a built-in handler for logging, excellent. If not and I must write a server-side handler, I would love to see an example.
For those that are curious, I’m trying to build a UI entirely in the browser that only communicates with the server for data. It would be nice to log things that happen in the browser that wouldn’t otherwise trigger a call to the server.
The JavaScript isn’t too complicated. Here is a JavaScript module modeled after Python’s
loggingmodule. It uses jQuery to POST the log message to the server at URLs like/log/debugor/log/info.To use it, simply make calls like
logging.info("log message here").The server-side Python code to handle these requests isn’t complicated. Here is the URL mapping.
And here is the logging handler.