Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7656133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:41:27+00:00 2026-05-31T12:41:27+00:00

Can someone show me an example of logging client-side events in JavaScript to AppEngine’s

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:41:29+00:00Added an answer on May 31, 2026 at 12:41 pm

    The JavaScript isn’t too complicated. Here is a JavaScript module modeled after Python’s logging module. It uses jQuery to POST the log message to the server at URLs like /log/debug or /log/info.

    // logging.js
    var logging = {};
    
    logging.log = function log(lvl, msg) {
      $.ajax({
        url: "/log/" + lvl,
        type: "POST",
        contentType: "text/plain",
        data: msg,
      });
    };
    
    logging.debug = function debug(msg) {
      logging.log("debug", msg);
    };
    
    logging.info = function info(msg) {
      logging.log("info", msg);
    };
    
    logging.warning = function warning(msg) {
      logging.log("warning", msg);
    };
    
    logging.error = function error(msg) {
      logging.log("error", msg);
    };
    
    logging.critical = function critical(msg) {
      logging.log("critical", msg);
    };
    
    return logging;
    

    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.

    # main.py (some stuff omitted for clarity)
    import logging
    import wsgiref.handlers
    from google.appengine.ext import webapp
    
    urlmap = [(r"/log/(.+)", handlers.LoggingHandler),]
    application = webapp.WSGIApplication(urlmap)
    wsgiref.handlers.CGIHandler().run(application)
    

    And here is the logging handler.

    # handlers.py
    import logging
    from google.appengine.ext import webapp
    
    class LoggingHandler(webapp.RequestHandler):
      def post(self, lvl):
        if lvl not in ("debug", "info", "warning", "error", "critical",):
          self.error(404)
          self.response.out.write("Unknown log level %s" % lvl)
          return
        msg = self.request.body
        getattr(logging, lvl)(msg)
        response = "Message logged: %s %s" % (lvl.upper(), msg))
        self.response.out.write(response)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone show an example of how to create multiple view change events in
Given the example below, can someone please show me how this could be called?
Can someone show a quick example on how to use NSTask and NSPipe in
Can someone show/point/help me to a resource for distributed development Git example or guide?
Can someone show me an example of setting canvas terminal and generating output as
Can someone show me an example which demonstrates the different behavior of these two
Can someone show me an example how to use getopts properly or any other
Can someone show me an example how to properly use the getRelativeDateTimeString() that is
Hi can someone show me an example of a multidimensional associative array in vb.net.
Using vanilla javascript or prototype can someone show me how I could run a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.