This commit is contained in:
Dave Dash 2010-04-01 12:24:14 -07:00
Родитель 637aabd255
Коммит 7afa1558e3
2 изменённых файлов: 16 добавлений и 1 удалений

Просмотреть файл

@ -27,6 +27,16 @@ tree. It sets up sensible defaults, but you can twiddle with these settings:
import logging
LOG_LEVEL = logging.WARN
``LOG_FILTERS``
If this optional setting is set to a tuple, only log items matching strings
in said tuple will be displayed.
For example::
LOG_FILTERS = ('z.sphinx.', )
This will show you messages **only** that start with ``z.sphinx``.
``LOG_FORMAT``
This string controls what gets printed out for each log message. See the
default in ``log_settings.py``. The complete list of formatting options is

Просмотреть файл

@ -11,7 +11,8 @@ log = logging.getLogger('z')
level = settings.LOG_LEVEL
if settings.DEBUG:
fmt = '%(asctime)s %(name)s:%(levelname)s %(message)s :%(pathname)s:%(lineno)s'
fmt = ('%(asctime)s %(name)s:%(levelname)s %(message)s '
':%(pathname)s:%(lineno)s')
fmt = getattr(settings, 'LOG_FORMAT', fmt)
handler = logging.StreamHandler()
formatter = logging.Formatter(fmt, datefmt='%H:%M:%S')
@ -26,4 +27,8 @@ else:
log.setLevel(level)
handler.setLevel(level)
handler.setFormatter(formatter)
for f in getattr(settings, 'LOG_FILTERS', []):
handler.addFilter(logging.Filter(f))
log.addHandler(handler)