Skip to content

Commit

Permalink
Configure logging for all modules (#124)
Browse files Browse the repository at this point in the history
Even if no logging is active in modules, default configuration has been
set:

```
import ansible_collections.arista.cvp.plugins.module_utils.logger

MODULE_LOGGER = logging.getLogger('arista.cvp.cv_facts')
MODULE_LOGGER.info('Start cv_facts module execution')

[...]

MODULE_LOGGER.debug('*** Connected to CVP')
```
  • Loading branch information
titom73 committed Mar 7, 2020
1 parent c1d6252 commit 7a0ec96
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ def is_empty(module, container_name, facts, debug=False):
def is_container_empty(module, container_name, debug=False):
MODULE_LOGGER.debug('* is_container_empty - get_devices_in_container %s', container_name)
container_status = module.client.api.get_devices_in_container(container_name)
MODULE_LOGGER.debug('* is_container_empty - get_devices_in_container %s', str(container_status))
if container_status is not None:
if isIterable(container_status) and len(container_status) > 0:
logging.debug(
Expand Down Expand Up @@ -632,15 +633,16 @@ def delete_unused_containers(module, intended, facts, debug=False):
container_fact = get_container_facts(container_name=cvp_container, facts=facts)
# Check we have a result. Even if we should always have a match here.
if container_fact is not None:
logging.debug('* delete_unused_containers - %s', container_fact['name'])
MODULE_LOGGER.debug('* delete_unused_containers - %s', container_fact['name'])
response = None
try:
response = process_container(module=module,
container=container_fact['name'],
parent=container_fact['parentName'],
action='delete')
except: # noqa E722
logging.error("Unexpected error: %s", str(sys.exc_info()[0]))
MODULE_LOGGER.error(
"Unexpected error: %s", str(sys.exc_info()[0]))
continue
if response[0]:
count_container_deletion += 1
Expand Down

0 comments on commit 7a0ec96

Please sign in to comment.