Support for a configurable logging threshold.

Adds support for filtering log messages by a configurable threshold, so
that only logs above the threshold are reported.  This is mainly useful
for restricting logs to only show errors, without the performance
penalty and noise required when logging everything.

A small amount of refactoring is done so simplify the logging and more
levels can easily be added by simply adding a class constant with the
level.