[Python-Dev] A new way to configure logging

Olemis Lang olemis at gmail.com
Wed Oct 7 18:26:42 CEST 2009

On Wed, Oct 7, 2009 at 10:49 AM, Vinay Sajip <vinay_sajip at yahoo.co.uk> wrote:
> Olemis Lang <olemis <at> gmail.com> writes:
>> This kind of problems is similar to the one mentioned in another
>> thread about modifying config options after executing commands. In
>> that case I mentioned that the same dict-like interface also holds for
>> WinReg and so on ...
>> So thinking big (yes ! I have a big head ! ) I think that the best
>> approach in this case is to build an adaptation (simple) layer on top
>> of ConfigParser, JSON, WinReg, PyCode, YAML, ... and build specific
>> extensions for these formats . Perhaps the proper interfaces are
>> already there (e.g. `dict`, `shelve` ) and I'm just blind and looking
>> somewhere else ;o)
> Sorry, you've lost me :-)

Never mind . I was just trying to say that using `dict`, an adapter
could be implemented (if not already there ;o) for multiple formats
like the ones I mentioned above and the solution would cover many
config formats ... and also I was saying that I was not sure about
whether this is correct , I mean for *ANY* config formats, but
definitely will work for many ;o)

>> >        import copy
>> >        self.config = copy.deepcopy(config)
>> Why ?
> So I'm free to mutate self.config as I see fit.

why not to let the user do it if he | she thinks so. I mean if
somebody supplies in a temporary mapping that can be written then why
to spend that time cloning the dict ? If the function has
side-effects, well just document it ;o)

>> extension is cool ... what's the point about adding the new method
>> instead of using `DictConfigurator` directly ?
> When you say "the new method", if you mean "configure" - the pattern is so that
> a subclass can override __init__ and do additional setup before configure() is
> called.

Sorry I was confused. I was talking about `dictConfig` *FUNCTION* (to
be added to logging.config ... isn't it ? ;o). I mean if dictConfig is
sematically equivalent to a simple `dc.configure` why to add such
function ?

PS: Not a big problem anyway ;o)



Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Looking for a technique to create flexible, graphical dashboards ...
- http://feedproxy.google.com/~r/TracGViz-full/~3/71kRhT34BgU/43789

More information about the Python-Dev mailing list