Message167880
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/ |
|
Date |
User |
Action |
Args |
2012-08-10 15:37:20 | vinay.sajip | set | recipients:
+ vinay.sajip, jordipf |
2012-08-10 15:37:20 | vinay.sajip | set | messageid: <1344613040.81.0.856319228806.issue15616@psf.upfronthosting.co.za> |
2012-08-10 15:37:20 | vinay.sajip | link | issue15616 messages |
2012-08-10 15:37:19 | vinay.sajip | create | |
|