The simplest way to use the logging module is to call functions directly from it, without creating a logger object.
import logging
logging.error('xxx')
This global logger can be configured via the logging.basicConfig() call:
import logging
logging.basicConfig(format='-- %(message)s --')
logging.error('xxx') # -- xxx --
Due to its global nature, basicConfig has some limitation. First, only the first call actually does something, any further calls of basicConfig are entirely ignored. Second, any function that writes a log message calls basicConfig, so you must configure logging before logging any messages:
import logging
logging.error('xxx') # ERROR:root:xxx
logging.basicConfig(format='-- %(message)s --')
logging.error('xxx') # ERROR:root:xxx