Logging

Pykka uses Python’s standard logging module for logging debug messages and any unhandled exceptions in the actors. All log messages emitted by Pykka are issued to the logger named pykka, or a sub-logger of it.

Log levels

Pykka logs at several different log levels, so that you can filter out the parts you’re not interested in:

CRITICAL (highest)

This level is only used by the debug helpers in pykka.debug.

ERROR

Exceptions raised by an actor that are not captured into a reply future are logged at this level.

WARNING

Unhandled messages and other potential programming errors are logged at this level.

INFO

Exceptions raised by an actor that are captured into a reply future are logged at this level. If the future result is used elsewhere, the exceptions is reraised there too. If the future result isn’t used, the log message is the only trace of the exception happening.

To catch bugs earlier, it is recommended to show log messages this level during development.

DEBUG (lowest)

Every time an actor is started or stopped, and registered or unregistered in the actor registry, a message is logged at this level.

In summary, you probably want to always let log messages at WARNING and higher through, while INFO should also be kept on during development.

Log handlers

Out of the box, Pykka is set up with logging.NullHandler as the only log record handler. This is the recommended approach for logging in libraries, so that the application developer using the library will have full control over how the log messages from the library will be exposed to the application’s users.

In other words, if you want to see the log messages from Pykka anywhere, you need to add a useful handler to the root logger or the logger named pykka to get any log output from Pykka.

The defaults provided by logging.basicConfig() is enough to get debug log messages from Pykka:

import logging
logging.basicConfig(level=logging.DEBUG)