Vinay Sajip added the comment:
The problem appears to be in PyYAML, not logging. Note the content of the
attribute dictionaries in the following script:
import logging
import logging.handlers
from pprint import pprint
import yaml
# Option 1 - OK
h1 = logging.handlers.RotatingFileHandler(filename = "test.log", maxBytes =
262144, backupCount = 3)
h2 = yaml.load("""
!!python/object/new:logging.handlers.RotatingFileHandler
kwds:
filename: test.log
maxBytes: 262144
backupCount: 3
""")
h3 = logging.FileHandler('test.log')
h4 = yaml.load("""
!!python/object/new:logging.FileHandler
kwds:
filename: test.log
""")
print('RotatingFileHandler using code: %s' % type(h1))
pprint(h1.__dict__)
print('RotatingFileHandler using YAML: %s' % type(h2))
pprint(h2.__dict__)
print('FileHandler using code: %s' % type(h3))
pprint(h3.__dict__)
print('FileHandler using YAML: %s' % type(h4))
pprint(h4.__dict__)
which prints
RotatingFileHandler using code: <class 'logging.handlers.RotatingFileHandler'>
{'_name': None,
'backupCount': 3,
'baseFilename': '/home/vinay/projects/scratch/test.log',
'encoding': None,
'filters': [],
'formatter': None,
'level': 0,
'lock': <_RLock owner=None count=0>,
'maxBytes': 262144,
'mode': 'a',
'stream': <open file '/home/vinay/projects/scratch/test.log', mode 'a' at
0x1a9f150>}
RotatingFileHandler using YAML: <class 'logging.handlers.RotatingFileHandler'>
{}
FileHandler using code: <class 'logging.FileHandler'>
{'_name': None,
'baseFilename': '/home/vinay/projects/scratch/test.log',
'encoding': None,
'filters': [],
'formatter': None,
'level': 0,
'lock': <_RLock owner=None count=0>,
'mode': 'a',
'stream': <open file '/home/vinay/projects/scratch/test.log', mode 'a' at
0x1a9f1e0>}
FileHandler using YAML: <class 'logging.FileHandler'>
{}
I suggest that you:
(a) Consider logging an issue with PyYAML.
(b) Consider using dictConfig(), which is available in Python 2.7 amd also
available for older Pythons through
http://code.google.com/p/logutils/
----------
assignee: -> vinay.sajip
resolution: -> invalid
status: open -> pending
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue15616>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com