jamf / JAWA

Jamf Automation and Webhook Assistant
MIT License
133 stars 12 forks source link

Dev/logging #33

Closed matthewsphillips closed 2 years ago

matthewsphillips commented 2 years ago

Lock in logging changes. Logger init function and child spawner are now in bin/logger.py

Adding a child logger to nay py file in the project requires 3 lines of code:

from bin import logger
logthis = logger.setup_child_logger(__name__)
logthis.debug(f'this got logged by {__name__} child')

Then logging statements are the same syntax everywhere: logthis.info("Message to be logged.")

The app.py 'main' logger is defined with hard coded name of 'app' because (__name__) produced unwanted results.

child log statements reflect the hierarchy and filename they came from, so troubleshooting and is simplified. example log entries:

2022-05-16 11:22:37,533 - jawa.views.log_view - INFO - this got logged by views.log_view child
2022-05-16 11:22:37,536 - jawa.views.resource_view - INFO - this got logged by views.resource_view child
2022-05-16 11:22:37,539 - jawa.views.custom_webhook - DEBUG - this got logged by views.custom_webhook child
2022-05-16 11:22:37,541 - jawa.views.webhook_view - DEBUG - this got logged by views.webhook_view child