abstract out error logging a bit

just spitting things to stderr isn't always going to be good enough, so
let's at least provide one place to change that when necessary
remove some duplication