groupon/urbanairship — pull request #16 by chaslemley (2012-07-24 17:03:44+00:00)
Title: Attempting to call logger.error when logger is nil

We are seeing this error when a request timeout occurs:

```
NoMethodError: undefined method `error' for nil:NilClass

[GEM_ROOT]/gems/urbanairship-2.0.0/lib/urbanairship.rb:71:in `rescue in do_request'
[GEM_ROOT]/gems/urbanairship-2.0.0/lib/urbanairship.rb:55:in `do_request'
[GEM_ROOT]/gems/urbanairship-2.0.0/lib/urbanairship.rb:35:in `push'
```

I noticed that the rescue handler was attempting to call `logger.error`, but we are not setting logger in our initializer (inside a Rails 3.1 app). We have remedied the issue by setting the logger.

However, I did notice that there was defensive code around this in the `log_request_and_response` method, so I've added something similar to the `do_request` method.