The Subsetter class now uses a module-level 'log', and no longer uses
its own custom Logger. This has been removed, and its features replaced
by equivalents.
log.lapse() are replaced with Timer context manager/decorator (these should make clearer where the elapsed time starts/stops);
log.glyphs() is kept for convenience: it is bound dynamically to the logger instance instead of subclassing logging.Logger, as it's only
useful in here.
log.font() is replaced by `font.saveXML(sys.stdout)`.
A distinct sub-logger is configured for timing messages, to allow --timing option to be enabled independently from --verbose
Here I use logging.basicConfig to configure the root logger, and hence all the other loggers,
including fontTools'.
I could have used fontTools.configLogger as well (and get predefined formatter, etc.), but wanted
to show that one can also configure the fontTools logger using the built-in logging configuration
functions (e.g. basicConfig, config.dictConfig and config.fileConfig).
The default logger level for TTX is set to logging.INFO. Anything equal or above that level
will be logged. Anything below that will not.
If the -v option is passed, the threshold is lowered to logging.DEBUG.
If the -q option is passed, the threshold is increased to logging.WARNING.
All these debug messages were disabled, and I don't wish to re-enable them
while running TTX in verbose mode. So here I use a custom level less than
logging.DEBUGm to make sure they will be muted even when the logger's level
is equal to logging.DEBUG.
Previously, when TTX was run in verbose mode, the messages printed to the console would also show the time
each one was logged -- e.g. "blah blah (15:23:24)" -- using the 'debugmsg' function which is defined here.
Even though the logging package would allow to do the same thing (via 'datefmt' and "%(asctime)s"), I decided
drop this, as I think it's not very interesting...
I'll replace it with the overall elapsed time in seconds, in a follow-up commit.
Before this change, feaLib had assigned a lookup index at the same
time as compiling each lookup. For chains, the implicit assumption was
that the chain's targets would always come before the contexual chain.
Normally this was indeed the case, but feaLib (and also makeotf)
sometimes merge several chain targets into one single lookup,
and then this assumption was not true anymore.
In the new version, the lookups get compiled in a separate pass,
after assigning lookup indices.
https://github.com/behdad/fonttools/issues/463