[Tutor] python logging module: two handlers writing to the same file - okay?

Kent Johnson kent37 at tds.net
Mon Dec 17 12:44:55 CET 2007


Hans Fangohr wrote:
> FYI: The reason for wanting to use two different file formats is this:
> we have a somewhat larger project (http://nmag.soton.ac.uk) where we
> combine high-level Python code with low-level Objective Caml code (and
> a number of libraries). We would like to use the Python-logging module
> to log all sorts of messages coming from various parts of the code. In
> particular, we find having the line number (and function name if the
> python version provides this) useful information in the log messages
> (which can bedone for Python code issueing log messages). However,
> this information cannot be obtained from the OCaml code; thus we do
> not want to waste space in the log messages, and therefore we'd like
> to use different formatters.

Perhaps you could write a formatter that holds two different format 
strings and selects between them based on whether the line number is 
available.

Kent


More information about the Tutor mailing list