diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-12-07 21:55:23 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-12-07 21:55:23 +0200 |
commit | 1e8201519a3aacea78b803cfd4e382005834f5d2 (patch) | |
tree | b92e22f0663064187b1eec8423b8cbae70ecd8ca | |
parent | c6a36c9af240a63b34c6518914ee4418e550e407 (diff) | |
download | apifw-1e8201519a3aacea78b803cfd4e382005834f5d2.tar.gz |
Fix: use of dict logger
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | apifw/bottleapp.py | 32 |
2 files changed, 19 insertions, 14 deletions
@@ -7,6 +7,7 @@ This file summarizes changes between releases of `apifw`. Version 0.29+git, not yet released ---------------------------------- +* Fixed using of supplised dict logger. Version 0.29, released 2017-12-07 ---------------------------------- diff --git a/apifw/bottleapp.py b/apifw/bottleapp.py index 9a907f0..377e49e 100644 --- a/apifw/bottleapp.py +++ b/apifw/bottleapp.py @@ -15,7 +15,6 @@ import json -import logging import re import time @@ -79,9 +78,9 @@ class BottleAuthorizationPlugin: self.iss = None self.aud = None self._authz_routes = set() - self._logger = lambda **kwags: None + self._logger = lambda log, **kwargs: None - def set_logger(self, logger): + def set_dict_logger(self, logger): self._logger = logger def set_token_signing_public_key(self, pubkey): @@ -97,13 +96,17 @@ class BottleAuthorizationPlugin: key = self.route_key(route) if route.get('needs-authorization', True): self._authz_routes.add(key) - self._logger( - msg_type='info', msg_text='Route does DOES need authorization', - route=key) + self._logger({ + 'msg_type': 'info', + 'msg_text': 'Route does DOES need authorization', + 'route': key, + }) else: - self._logger( - msg_type='info', msg_text='Route does NOT need authorization', - route=key) + self._logger({ + 'msg_type': 'info', + 'msg_text': 'Route does NOT need authorization', + 'route': key, + }) def route_key(self, route): # route can be a dict (from find_missing_route), or a @@ -172,11 +175,12 @@ class BottleAuthorizationPlugin: route_scope = self.get_scope_for_route(route['method'], route['rule']) if route_scope in scopes: return True - self._logger( - msg_type='error', - msg_text='Route scope is NOT in scopes', - route_scope=route_scope, - scopes=scopes) + self._logger({ + 'msg_type': 'error', + 'msg_text': 'Route scope is NOT in scopes', + 'route_scope': route_scope, + 'scopes': scopes, + }) return False def get_scope_for_route(self, method, rule): |