Skip to content

Commit

Permalink
Merge pull request Kinto#580 from mozilla-services/560-log-redis-errors
Browse files Browse the repository at this point in the history
Fix Redis error traces not being logged (fixes Kinto#560)
  • Loading branch information
Natim committed Nov 17, 2015
2 parents 4e41a69 + addb1d1 commit a92f14e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ This document describes changes between each past release.
- Fix Service CORS not being set when plugins are included
- Fix crash with Redis backend if record parent/id is unicode (fixes #556)
- Fix principals of permission backend not being plugged by default (#573)
- Fix Redis error traces not being logged (#560)

**Internal changes**

Expand Down
3 changes: 2 additions & 1 deletion cliquet/storage/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import redis
from six.moves.urllib import parse as urlparse

from cliquet import utils
from cliquet import utils, logger
from cliquet.storage import (
exceptions, DEFAULT_ID_FIELD,
DEFAULT_MODIFIED_FIELD, DEFAULT_DELETED_FIELD)
Expand All @@ -17,6 +17,7 @@ def wrapped(*args, **kwargs):
try:
return func(*args, **kwargs)
except redis.RedisError as e:
logger.exception(e)
raise exceptions.BackendError(original=e)
return wrapped

Expand Down
9 changes: 9 additions & 0 deletions cliquet/tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,15 @@ def test_get_all_handle_expired_values(self):
with mocked_mget:
self.storage.get_all(**self.storage_kw) # not raising

def test_errors_logs_stack_trace(self):
self.client_error_patcher.start()

with mock.patch('cliquet.storage.logger.exception') as exc_handler:
with self.assertRaises(exceptions.BackendError):
self.storage.get_all(**self.storage_kw)

self.assertTrue(exc_handler.called)


@skip_if_no_postgresql
class PostgreSQLStorageTest(StorageTest, unittest.TestCase):
Expand Down

0 comments on commit a92f14e

Please sign in to comment.