Log, count and warn deprecations via configurable io stream

Make `warn_deprecation` use a configurable `DeprecationIO` object which defaults to writing to $stderr.
This counts the number of deprecations and warns about them at the end of each run.

This is a proposed implementation for #616 and alternate to #853

I should mention I based this off the last stable release, as the current master breaks for me?