refactor

when making a book, can write log to 'file' other than stderr.
when making a book, the result can be output to memory