Refactored to accept a `formatFn` for logging.

Also, fixed file.contents size calculation. Buffer.byteLength assumes
'utf-8' encoding, which produces inaccurate results for files that have
been compressed (e.g. gzip).