theochem / horton

HORTON: Helpful Open-source Research TOol for N-fermion systems
http://theochem.github.io/horton/
GNU General Public License v3.0
92 stars 40 forks source link

Print messages directly, no logger #244

Open matt-chan opened 7 years ago

matt-chan commented 7 years ago

In order to remove the Log object, we need to print messages directly to stdout.

This is straightforward except that we will then need to have a way of sorting messages by verbosity. The approach we are taking is to prepend messages with a known string (ie 5:) that contains information about verbosity. Higher numbers mean more verbose messages. Users could then grep messages directly (ie. "I want all messages with prefixes less than 5). Or we could later redirect stdout to a streamIO and parse the numbers ourselves. In either case, this would take place at the level of glue-code or higher.

matt-chan commented 7 years ago

One challenge with this approach is when printing things like Numpy arrays, or other multi-line objects from non-HORTON code.

There are two solutions I can think of: One is to modify the grep so that un-prefixed output retains the same level as the last prefix. Another solution is to print to a streamIO, modify the output with the correct prefixes, and then pass it to stdout. In either case, it's a small change which can be deferred for later.

PaulWAyers commented 7 years ago

I like getting rid of the logger; I think this is more-or-less what Toon had recommended earlier. He had talked about passing a log object as an argument also, but I guess this may be preferable; it is more straightforward I think.