diff --git a/hshetl/loaders.py b/hshetl/loaders.py index 6324758ce74ec97fb45a8bb2790f3fcdb5065400..5e871e28a9db39f723290141a686ba165abf913d 100644 --- a/hshetl/loaders.py +++ b/hshetl/loaders.py @@ -382,10 +382,10 @@ class LdapLoader(AbstractLoader): attributes = modlist.modifyModlist(old_entity_dict, entity_dict) try: if self.dry: - logging.info('Would modify dn {} with {} '.format(dn, str(attributes))) + logging.info('Would modify dn {} with {} '.format(dn, self._generate_modify_logging(attributes, old_entity_dict, entity_dict))) else: connection.modify_s(dn, attributes) - logging.info('Modified dn {} with {} '.format(dn, str(attributes))) + logging.info('Modified dn {} with {} '.format(dn, self._generate_modify_logging(attributes, old_entity_dict, entity_dict))) except Exception, e: logging.warn('Update failed for dn \'' + dn + '\': ' + str(e)) @@ -438,3 +438,14 @@ class LdapLoader(AbstractLoader): elif element == None: data[key] = '' return data + + def _generate_modify_logging(self, attributes, old, new): + '''Generates a nicer representation of the executed query than str(attributes) would''' + changed_attributes = [] + output = '' + for operation in attributes: + if operation[1] not in changed_attributes: + changed_attributes.append(operation[1]) + for attribute in changed_attributes: + output += attribute + ': ' + old[attribute] + ' -> ' + new[attribute] + ', ' + return output[:-2]