untested code for emitting warnings and errors as JSON and slight changes to messages in text mode