← Back to team overview

fenics team mailing list archive

Re: Logging in Python

 

On Tue, Mar 18, 2008 at 10:37:38AM -0500, Matthew Knepley wrote:
> On Tue, Mar 18, 2008 at 10:34 AM, Anders Logg <logg@xxxxxxxxx> wrote:
> > On Sun, Mar 16, 2008 at 04:50:07PM +0100, Martin Sandve Alnæs wrote:
> >  > I highly recommend that all Python projects in FEniCS use the module
> >  > "logging" that comes with Python from version 2.3. It is very simple
> >  > and very flexible, in particular for creating cross-module logs. For
> >  > the most basic usage, look at output.py and the tests in UFL.
> >  >
> >  > Basic tutorial (good site for handy python modules):
> >  > http://blog.doughellmann.com/2007/05/pymotw-logging.html
> >  >
> >  > Reference:
> >  > http://docs.python.org/lib/module-logging.html
> >
> >  Sounds good, but the big problem is more likely to coordinate logging
> >  from C++ (DOLFIN) and Python. Is there a nice solution for this?
> 
> As long as whole lines are always written, and the file is line buffered, I
> think writing from two different file descriptors should be fine. The nice
> thing would be to replicate the format in C++.
> 
>    Matt

Even if the file is stdout?

The format looks surprisingly similar to what we have implemented:

  logging.debug    --> dolfin::dolfin_debug
  logging.info     --> dolfin::message
  logging.warning  --> dolfin::warning
  logging.error    --> dolfin::error

(Maybe not so surprising since these are fairly obvious names.)

Anyway, it would be easy for us to move to something else (or modify
the behavior so it's identical to the logging module).

-- 
Anders


Follow ups

References