With Pyjamas you can use full Python-style logging (Python's flexible event logging module has been ported to pyjs). Additional handlers allow you to display log messages in a dedicated div element in the HTML document, in the Web browser's error console, and with JavaScript's alert() function.

from pyjamas import logging
log = logging.getConsoleLogger()   # other loggers: Alert, Append, Print ...
...
log.error("Hello, here is an %s error", err_name)

For a good understanding of the logging module read the Python Logging HOWTO; most of it directly applies to Pyjamas. Additional Loggers provided by Pyjamas, and how you'd use them:

  1. AlertLogger: log = logging.getAlertLogger()
    shows a browser alert popup dialog for each log message.
  2. AppendLogger: log = logging.getAppendLogger()
    appends text to the end of the HTML document body. The div element holding the log messages can be accessed by its element ID ('logging_loggername', 'logging_pyjs' by default) for styling.
  3. ConsoleLogger: log = logging.getConsoleLogger()
    passes log messages on to the error console of Firebug/Chrome/Opera/IE8+ using the console logging functions.
  4. PrintLogger: log = logging.getPrintLogger()
    prints text to cerr, the default error output stream. This is a good choice when developing/testing with Pyjamas Desktop.
  5. NullLogger: log = logging.getLoggerForHandler(NullHandler())
    disable logging completely and safely. Import this handler with: from pyjamas.logging.handlers import NullHandler