make logging to sentry optional
disentangle api processing logic from text output
Add JSON output mode, and fix all lint errors in main.py.