I am looking for a way to use the ExtendedInterpolation functionality found in the configparser lib when loading in a ini file to Logging.config.FileConfig.
http://docs.python.org/3/library/configparser#configparser.ExtendedInterpolation
So if I have a ini file that looks like this:
[logSettings]
eventlogs=application
logfilepath=C:\Programs\dk_test\results\dklog_009.log
levelvalue=10
[formatters]
keys=dkeventFmt,dklogFmt
[handlers]
keys=dklogHandler
[handler_dklogHandler]
class=FileHandler
level=${logSettings:levelvalue}
formatter=dklogFmt
args=(${logSettings:logfilepath}, 'w')
[logger_dklog]
level=${logSettings:levelvalue}
handlers=dklogHandler
As you can see I am following the extended interpolation syntax by using the ${…} notation to reference a value in a different section. When calling the file like so logging.config.fileConfig(filepath), the eval’ing within the module always fails. In paticular on the eval’ing of the args option in the [handler_dklogHandler] section.
Is there a way to get around this? Thanks!
Note: Using Python 3.2
Decided to use force the interpolation over the file and save the result to another temp file. I use the temp file for the logconfig.
The function looks like this: