#866: config.py logging enhancement
---------------------------------+------------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: anonymous
Type: enhancement | Status: new
Priority: normal | Milestone: 1.0b1
Component: TurboGears | Version: 0.9a6
Severity: normal | Keywords: logging
---------------------------------+------------------------------------------
This enhancement will expose all loggers contained in the logging package.
The motivation was to expose !RotatingFileHandler and
!TimedRotatingFileHandler.
I'm not convinced that the implicit tupple structure of args is ideal, it
seems prone to errors. On the other hand, I've got no better suggestion at
the moment.
{{{
import logging
import logging.handlers
def _get_handlers(handlers, formatters):
for key, handler in handlers.items():
kw = {}
try:
cls = handler.get("class")
args = handler.get("args", tuple())
level = handler.get("level", None)
try:
cls = getattr(sys.modules['logging'],cls)
except AttributeError:
try:
cls = getattr(sys.modules['logging.handlers'],cls)
except AttributeError,err:
raise ConfigError("Specified class in handler %s is
not a recognizable logger name" % key)
try:
handler_obj = cls(*eval(args))
except IOError,err:
raise ConfigError("Missing or wrong argument to %s in
handler %s -> %s "%(cls.__name__,key,err))
except TypeError,err:
raise ConfigError("Wrong format for arguments to %s in
handler %s -> %s"%(cls.__name__,key,err))
if level:
level = eval(level, logging.__dict__)
handler_obj.setLevel(level)
except KeyError:
raise ConfigError("No class specified for logging handler %s"
% key)
formatter = handler.get("formatter", None)
if formatter:
try:
formatter = formatters[formatter]
except KeyError:
raise ConfigError("Handler %s references unknown "
"formatter %s" % (key, formatter))
handler_obj.setFormatter(formatter)
handlers[key] = handler_obj
}}}
--
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/866>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Tickets" 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-tickets
-~----------~----~----~----~------~----~------~--~---