Erle Robotics Python Networking Gitbook Free

Daemons and Logging

A daemon is a computer program that runs as a background process, rather than being under the direct control of an interactive user. You can also install python-daemon from the Package, and its code will let your server program become a daemon entirely on its own power.

Another useful thing is the modern logging module, which can write to syslog, files, network sockets, or anything in between. The simplest pattern is to place something like this at the top of each of your daemon’s source files:

import logging
log = logging.getLogger(__name__)

Then your code can generate messages very simply:

log.error('the system is down')