Skip to content

Commit

Permalink
Merge "Fix isEnabledFor for compatibility with logging"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Aug 21, 2013
2 parents 075c871 + cfebb34 commit b6f6b57
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
39 changes: 18 additions & 21 deletions keystone/common/ldap/core.py
Expand Up @@ -514,24 +514,22 @@ def simple_bind_s(self, user, password):
def add_s(self, dn, attrs):
ldap_attrs = [(kind, [py2ldap(x) for x in safe_iter(values)])
for kind, values in attrs]
if LOG.isEnabledFor(LOG.debug):
sane_attrs = [(kind, values
if kind != 'userPassword'
else ['****'])
for kind, values in ldap_attrs]
LOG.debug(_('LDAP add: dn=%(dn)s, attrs=%(attrs)s') % {
'dn': dn, 'attrs': sane_attrs})
sane_attrs = [(kind, values
if kind != 'userPassword'
else ['****'])
for kind, values in ldap_attrs]
LOG.debug(_('LDAP add: dn=%(dn)s, attrs=%(attrs)s') % {
'dn': dn, 'attrs': sane_attrs})
return self.conn.add_s(dn, ldap_attrs)

def search_s(self, dn, scope, query, attrlist=None):
if LOG.isEnabledFor(LOG.debug):
LOG.debug(_(
'LDAP search: dn=%(dn)s, scope=%(scope)s, query=%(query)s, '
'attrs=%(attrlist)s') % {
'dn': dn,
'scope': scope,
'query': query,
'attrlist': attrlist})
LOG.debug(_(
'LDAP search: dn=%(dn)s, scope=%(scope)s, query=%(query)s, '
'attrs=%(attrlist)s') % {
'dn': dn,
'scope': scope,
'query': query,
'attrlist': attrlist})
if self.page_size:
res = self.paged_search_s(dn, scope, query, attrlist)
else:
Expand Down Expand Up @@ -591,12 +589,11 @@ def modify_s(self, dn, modlist):
else [py2ldap(x) for x in safe_iter(values)]))
for op, kind, values in modlist]

if LOG.isEnabledFor(LOG.debug):
sane_modlist = [(op, kind, (values if kind != 'userPassword'
else ['****']))
for op, kind, values in ldap_modlist]
LOG.debug(_('LDAP modify: dn=%(dn)s, modlist=%(modlist)s') % {
'dn': dn, 'modlist': sane_modlist})
sane_modlist = [(op, kind, (values if kind != 'userPassword'
else ['****']))
for op, kind, values in ldap_modlist]
LOG.debug(_('LDAP modify: dn=%(dn)s, modlist=%(modlist)s') % {
'dn': dn, 'modlist': sane_modlist})

return self.conn.modify_s(dn, ldap_modlist)

Expand Down
4 changes: 2 additions & 2 deletions keystone/common/wsgi.py
Expand Up @@ -396,7 +396,7 @@ class Debug(Middleware):

@webob.dec.wsgify(RequestClass=Request)
def __call__(self, req):
if LOG.isEnabledFor(LOG.debug):
if not hasattr(LOG, 'isEnabledFor') or LOG.isEnabledFor(LOG.debug):
LOG.debug('%s %s %s', ('*' * 20), 'REQUEST ENVIRON', ('*' * 20))
for key, value in req.environ.items():
LOG.debug('%s = %s', key, mask_password(value,
Expand All @@ -408,7 +408,7 @@ def __call__(self, req):
LOG.debug('')

resp = req.get_response(self.application)
if LOG.isEnabledFor(LOG.debug):
if not hasattr(LOG, 'isEnabledFor') or LOG.isEnabledFor(LOG.debug):
LOG.debug('%s %s %s', ('*' * 20), 'RESPONSE HEADERS', ('*' * 20))
for (key, value) in resp.headers.iteritems():
LOG.debug('%s = %s', key, value)
Expand Down

0 comments on commit b6f6b57

Please sign in to comment.