Add debug logging

- Added debug logging on all failure cases.
- Added `behindProxy` option for better IP reporting on the debug logging.