I'm surprised at the apparent consensus that the only solution is to
re-implement "verbose" by some totally different method. I came across this
issue before and I found a perfectly acceptable fix, which I didn't bother
to make a ticket for because I didn't know if anyone else cared about this
issue until I saw this thread.

The current implementation of "verbose" controls which messages to show
according to the name of the Python module containing the code; and it
extracts the module name from the Python interpreter state. Unfortunately,
this doesn't play well with Cython modules, so if verbose is called from
Cython code, it ends up going back up the call stack until it finds a
Python module. Because Sage's matrix algebra routines have lots of
diagnostic messages built in (definitely a Good Thing), and they are almost
all implemented in Cython, this often leads to a slew of unwanted messages
about matrix arithmetic, as in Daniel's example.

The solution I found was simply to add an optional extra argument to
"verbose", specifying a string to use in place of the auto-detected module
name (extending a mechanism that's already there for the function name);
and then to grep through the Cython files in the Sage library, adjusting a
few dozen calls to "verbose" to give the module name explicitly each time.
This worked perfectly.

I'd be happy to make a ticket for this, if others agree that it's
preferable to reinventing the wheel.

David

On 26 August 2016 at 18:27, Daniel Krenn <kr...@aon.at> wrote:

> On 2016-08-09 19:31, William Stein wrote:
> >     The only good way is to rip out the "verbose" thing and replace it
> >     with the Python logging module. Then its easy to have different
> >     loggers for your code and for the flint interface, and make them log
> >     in different levels and/or different output streams.
> >
> > You don't have rip out verbose and replace it.  Just switch to using
> > the built in Python logging module for what you're doing.   We should
> > also reimplement verbose on top of pythons built in logging module
> > (probably just a few lines of code to do that).  I'm very surprised
> > nobody has done this already.
>
> I've started this at
>   https://trac.sagemath.org/ticket/21349
>
> Daniel
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-devel+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-devel@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to