logging module's documentation lies?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ludvig.ericson@gmail.com

    logging module's documentation lies?

    Quote from the docs:

    FORMAT = "%(asctime)-15s %(clientip)s %(user)-8s %(message)s"
    logging.basicCo nfig(format=FOR MAT)
    d = {'clientip': '192.168.0.1', 'user': 'fbloggs'}
    logging.warning ("Protocol problem: %s", "connection reset",
    extra=d)

    would print something like

    2006-02-08 22:20:02,165 192.168.0.1 fbloggs Protocol problem:
    connection reset

    If we try to run that exact example, which doesn't seem logically
    flawed in any way:
    >>import logging
    >>FORMAT = "%(asctime)-15s %(clientip)s %(user)-8s %(message)s"
    >>logging.basic Config(format=F ORMAT)
    >>d = {'clientip': '192.168.0.1', 'user': 'fbloggs'}
    >>logging.warni ng("Protocol problem: %s", "connection reset",
    extra=d)
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/lib/python2.5/site-packages/logging/__init__.py",
    line 1266, in warning
    apply(root.warn ing, (msg,)+args, kwargs)
    File "/usr/lib/python2.5/site-packages/logging/__init__.py",
    line 969, in warning
    apply(self._log , (WARNING, msg, args), kwargs)
    TypeError: _log() got an unexpected keyword argument 'extra'

    I tried using **d instead, no show. I tried extra=d in Python 2.4, no
    show. I tried **d in Python 2.4, no show.

    So, my question unto the lot of you is: Do the docs for the logging
    module lie to me?

    URL: http://docs.python.org/lib/module-logging.html
  • Matimus

    #2
    Re: logging module's documentation lies?

    On Jun 24, 2:35 pm, "ludvig.eric... @gmail.com"
    <ludvig.eric... @gmail.comwrote :
    Quote from the docs:
    >
        FORMAT = "%(asctime)-15s %(clientip)s %(user)-8s %(message)s"
        logging.basicCo nfig(format=FOR MAT)
        d = {'clientip': '192.168.0.1', 'user': 'fbloggs'}
        logging.warning ("Protocol problem: %s", "connection reset",
    extra=d)
    >
    would print something like
    >
        2006-02-08 22:20:02,165 192.168.0.1 fbloggs  Protocol problem:
    connection reset
    >
    If we try to run that exact example, which doesn't seem logically
    flawed in any way:
    >
        >>import logging
        >>FORMAT = "%(asctime)-15s %(clientip)s %(user)-8s %(message)s"
        >>logging.basic Config(format=F ORMAT)
        >>d = {'clientip': '192.168.0.1', 'user': 'fbloggs'}
        >>logging.warni ng("Protocol problem: %s", "connection reset",
    extra=d)
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
          File "/usr/lib/python2.5/site-packages/logging/__init__.py",
    line 1266, in warning
            apply(root.warn ing, (msg,)+args, kwargs)
          File "/usr/lib/python2.5/site-packages/logging/__init__.py",
    line 969, in warning
            apply(self._log , (WARNING, msg, args), kwargs)
        TypeError: _log() got an unexpected keyword argument 'extra'
    >
    I tried using **d instead, no show. I tried extra=d in Python 2.4, no
    show. I tried **d in Python 2.4, no show.
    >
    So, my question unto the lot of you is: Do the docs for the logging
    module lie to me?
    >
    URL:http://docs.python.org/lib/module-logging.html
    From the documentation: `Changed in version 2.5: extra was added.`

    Documentation never lies, authors do. Or, in this case, don't.

    Matt

    Comment

    Working...