Jeffrey Britton wrote:
Hi,

An alternative is to subclass FileHandler with a handler customized for your
app.

class AppFileHandler(FileHandler):
  def __init__(filename):
     if not os.path.isabs(filename):
        filename = os.path.join(os.environ['APPDATA'], 'whateverdir',
filename)
     FileHandler.__init__(self, filename, 'w')

[handler_appFileHandler]
class=AppFileHandler
level=DEBUG
formatter=simpleFormatter
args=('foo.log')


JM

Thanks,

This is great, but how does parser get the definition for AppFileHandler?

This could potentially solve my next problem.
I am using the logging listener and sending new log configurations to
it via a socket.
I don't know how to pass a dictionary to the parser in this scenario.
So, if AppFileHandler can get me around this problem that would be great.
I don't really know I'm not using config files. By looking at logging/config.py, the class is given that way:
klass = 'AppFileHandler'
klass = eval(klass, vars(logging))

So by simply writing
logging.AppFileHandler = AppFileHandler
you would "register" you custom class as a logging attriute and should be able to use it in your config files.

JM
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to