logging

Spiderweb uses the standard library's logging module. Every SpiderwebRouter has a log attribute you can use for your own messages, and the framework logs its own events (startup checks, server start/stop, unhandled exceptions) through it.

from spiderweb import SpiderwebRouter

app = SpiderwebRouter()
app.log.info("custom message from my app")

frameworks, logging, and you

As a library, Spiderweb does not call logging.basicConfig() -- it never modifies the root logger or installs handlers on it. The framework logger (spiderweb.main) carries its own stream handler at INFO level, so you still see messages like Run startup checks... out of the box, but your application's logging configuration is entirely yours to own.

If you configure logging in your own app, Spiderweb's messages will also propagate to your root handlers as usual:

import logging

logging.basicConfig(level=logging.DEBUG, format="%(levelname)s %(name)s: %(message)s")

from spiderweb import SpiderwebRouter

app = SpiderwebRouter()

using your own logger

Pass any logging.Logger to the router with the log parameter. This replaces the default framework logger for all of the app's messages:

import logging

from spiderweb import SpiderwebRouter

my_logger = logging.getLogger("myapp")
my_logger.setLevel(logging.DEBUG)
handler = logging.FileHandler("myapp.log")
my_logger.addHandler(handler)

app = SpiderwebRouter(log=my_logger)

what gets logged

Level Examples
INFO startup checks, server start/stop on the dev server
WARNING static/media dirs set while debug=False
ERROR unhandled view exceptions (with traceback), aborted connections