Repository: Kinto/kinto

Issue:
Variables not rendered when using logging_color_formater.ColorFormatter 
```[formatter_color]
class = logging_color_formatter.ColorFormatter
```

It seems that the message parameters are not rendered:

```
Serving on http://localhost:8888
Created new connection %r 
Connection %r checked out from pool 
Connection %r being returned to pool 
Connection %s rollback-on-return%s 
Connection %r checked out from pool 
Connection %r being returned to pool 
Connection %s rollback-on-return%s 
Connection %r checked out from pool 
Connection %r being returned to pool 
Connection %s rollback-on-return%s 
```

If I comment out the class I have the proper expected messages:

```
Created new connection <connection object at 0x7fcc6bf36768; dsn: 'password=xxxxxxxx host=localhost dbname=postgres user=postgres', closed: 0>
Connection <connection object at 0x7fcc6bf36768; dsn: 'password=xxxxxxxx host=localhost dbname=postgres user=postgres', closed: 0> checked out from pool
Connection <connection object at 0x7fcc6bf36768; dsn: 'password=xxxxxxxx host=localhost dbname=postgres user=postgres', closed: 0> being returned to pool
Connection <connection object at 0x7fcc6bf36768; dsn: 'password=xxxxxxxx host=localhost dbname=postgres user=postgres', closed: 0> rollback-on-return
```



Discussion:

Resolving patch:
diff --git a/kinto/core/authorization.py b/kinto/core/authorization.py
--- a/kinto/core/authorization.py
+++ b/kinto/core/authorization.py
@@ -99,7 +99,8 @@ def permits(self, context, principals, permission):
                 allowed = context.check_permission(principals, bound_perms)
 
         if not allowed:
-            logger.warn("Permission not granted.",
+            logger.warn("Permission %r on %r not granted to %r.",
+                        permission, object_id, principals[0],
                         extra=dict(userid=principals[0], uri=object_id, perm=permission))
 
         return allowed
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -22,7 +22,7 @@ def read_file(filename):
     'cornice_swagger >= 0.5',
     'jsonschema',
     'jsonpatch',
-    'logging-color-formatter',
+    'logging-color-formatter >= 1.0.1',  # Message interpolations.
     'python-dateutil',
     'pyramid > 1.8',
     'pyramid_multiauth >= 0.8',  # User on policy selected event.


Test patch:
diff --git a/tests/core/test_authorization.py b/tests/core/test_authorization.py
--- a/tests/core/test_authorization.py
+++ b/tests/core/test_authorization.py
@@ -187,9 +187,12 @@ def test_permits_logs_authz_failures(self):
         self.context.check_permission.return_value = False
         with mock.patch('kinto.core.authorization.logger') as mocked:
             self.authz.permits(self.context, self.principals, 'dynamic')
-        mocked.warn.assert_called_with('Permission not granted.',
-                                       extra=dict(perm='read', uri='/articles/43/comments/2',
-                                                  userid='portier:yourself'))
+        userid = 'portier:yourself'
+        object_id = '/articles/43/comments/2'
+        perm = 'read'
+        mocked.warn.assert_called_with('Permission %r on %r not granted to %r.',
+                                       perm, object_id, userid,
+                                       extra=dict(perm=perm, uri=object_id, userid=userid))
 
     def test_permits_refers_to_context_to_check_permissions(self):
         self.context.check_permission.return_value = True