Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapter logging interface #4161

Closed

Conversation

nathaniel-may
Copy link
Contributor

@nathaniel-may nathaniel-may commented Oct 28, 2021

waiting for #4137 to merge first

Description

Adapter maintainers currently use our old logging system. This exposes the new eventing system to them so that they have to make minimal changes to stay up-to-date for v1. Adapter maintainers will not have to touch every log call site to use the new system.

Checklist

  • I have signed the CLA
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change

@cla-bot cla-bot bot added the cla:yes label Oct 28, 2021
@nathaniel-may nathaniel-may changed the base branch from feature/structured-logging to first-pass-structured-logging October 28, 2021 20:16
@nathaniel-may nathaniel-may mentioned this pull request Oct 28, 2021
21 tasks
@iknox-fa iknox-fa self-requested a review October 28, 2021 22:00
Base automatically changed from first-pass-structured-logging to feature/structured-logging October 29, 2021 13:16
@nathaniel-may nathaniel-may force-pushed the adapter-logging-interface branch from 1d2ff5f to 98c692f Compare October 29, 2021 13:26
@nathaniel-may nathaniel-may marked this pull request as ready for review October 29, 2021 13:40
@nathaniel-may
Copy link
Contributor Author

commit history looks a little wonky which is probably because I rebased onto a different branch than the one I branched from. I'm gonna squash and merge anyway so it should be fine.

@nathaniel-may
Copy link
Contributor Author

I should probably add the exception log level here too.

@nathaniel-may nathaniel-may force-pushed the adapter-logging-interface branch from cc76621 to e35106d Compare October 29, 2021 20:14
@nathaniel-may
Copy link
Contributor Author

re-requesting prior approvals because I made a significant change since then.

def exception(
self,
msg: str,
exc_info: Any = True, # this default is what makes this method different
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this call out.

@nathaniel-may
Copy link
Contributor Author

Should this object have some kind of doc string? What should it say?

Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interface and explainer look great to me.

Could this PR also do the two-line work of switching over the Postgres adapter? It looks like there's one spot where it imports dbt.logger and should instead use AdapterLogger("Postgres")? That could be good as far as having a concrete example to point to when cutting over more adapters.

If you'd rather than come in a subsequent PR, that's also fine by me.

Comment on lines +12 to +21
To integrate existing log messages from adapters, you likely have a line of code like this in your adapter already:
```python
from dbt.logger import GLOBAL_LOGGER as logger
```

Simply change it to these two lines with your adapter's database name, and all your existing call sites will now use the new system for v1.0:
```python
from dbt.events import AdapterLogger
logger = AdapterLogger("<database name>")
# e.g. AdapterLogger("Snowflake")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@nathaniel-may nathaniel-may force-pushed the adapter-logging-interface branch from 6e7763a to e726824 Compare November 2, 2021 16:33
@nathaniel-may
Copy link
Contributor Author

Logbook is causing issues when I moved the Postgres adapter over to the new interface. Instead of spinning my wheels investigating, I migrated all these changes into #4176 because Logbook isn't a problem over there.

@nathaniel-may
Copy link
Contributor Author

Tests passed over there so I'm verifying that it works over here for record.

@nathaniel-may nathaniel-may mentioned this pull request Nov 2, 2021
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants