Em Sunday 09 December 2007 01:13:09 Ben Sizer escreveu:

>  - what does a typical quick-started project make for you? I can see
> the entries in dev.cfg and log.cfg, but what objects are actually
> created, and in which module/namespace? Is it several objects, or one
> object (called 'log'? It's not clear) where the output is piped to
> each of the various handlers?

It is a log object in the namespace supplied on the configuration files you 
mentioned.

For example, for a "testing123" project, you'll have, on dev_cfg:

 [logging]

[[loggers]]
[[[testing123]]]
level='DEBUG'
qualname='testing123'
handlers=['debug_out']


Then you can create your handlers on your code by using, on the beginning of 
your file:

        import logging
        log = logging.getLogger('testing123')

        class YourClass(Controller):
            ...


log will be a global variable, accessible everywhere within the module.  I 
usually change this for:

        import logging
        log = logging.getLogger('testing123.module_name')

So that I have more context on the logged message.

>  - the start of the doc recommends explicitly creating a log object,
> but I don't know how (and if) this corresponds to anything in the
> config files above. And it seems a little odd for the doc to recommend
> this method when a quick-started project seems to come with stuff
> predefined. How do I access the predefined stuff?

As above.  You don't have a log object until you get it.  What TG does is 
initializing one with the definitions you supplied, but you still have to get 
it.  If you don't use the one initialized on dev.cfg/prod.cfg then you have 
to create your own as stated in the docs and using the logging documentation. 



-- 
Jorge Godoy      <[EMAIL PROTECTED]>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to