Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Instrument @truffle/db with some initial logging #3475

Merged
merged 2 commits into from
Oct 27, 2020
Merged

Instrument @truffle/db with some initial logging #3475

merged 2 commits into from
Oct 27, 2020

Conversation

gnidan
Copy link
Contributor

@gnidan gnidan commented Oct 27, 2020

This PR adds debug in an internal @truffle/db/logger module, for use throughout the @truffle/db codebase.

This defines logger instances in all existing TS modules, as well as adds some initial logging in key areas.

g. nicholas d'andrea added 2 commits October 26, 2020 22:13
- Log each custom defined resolver
- Log graphql and pouch operations
@gnidan
Copy link
Contributor Author

gnidan commented Oct 27, 2020

There's more I want to do here... e.g. I am tempted to group loggers more by resource/collectionName where appropriate, but I figure it's probably more important to get something in place as a start

@gnidan
Copy link
Contributor Author

gnidan commented Oct 27, 2020

This is what this looks like when I run DEBUG=db* yarn test:

Screen Shot 2020-10-26 at 22 20 20

Copy link
Contributor

@fainashalts fainashalts left a comment

Choose a reason for hiding this comment

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

This is so great! Will definitely make development easier by letting us see where things go wrong. I wonder if we could add some logging of the actual result somewhere, if the result is an error? Would be more informative, but I supposed while developing when you see where something is breaking you can add a log statement.

I left a couple of comments about a few places where you imported the package but aren't using it, but since it looks like you did it a lot there was probably a good reason so I stopped adding those comments. :)

@@ -1,3 +1,6 @@
import { logger } from "@truffle/db/logger";
const debug = logger("db:connect");
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you adding this here for later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep - I added it to every module I could, in case we need it. We have a dedicated eslint rule to allow this as an unused variable. This is how we do things in other packages.

@@ -1,3 +1,6 @@
import { logger } from "@truffle/db/logger";
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto, imported but not being used.

@@ -1,3 +1,6 @@
import { logger } from "@truffle/db/logger";
Copy link
Contributor

Choose a reason for hiding this comment

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

Here too.

@@ -1,3 +1,6 @@
import { logger } from "@truffle/db/logger";
const debug = logger("db:graphql:types");
Copy link
Contributor

Choose a reason for hiding this comment

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

imported but not used.

@@ -1,3 +1,6 @@
import { logger } from "@truffle/db/logger";
Copy link
Contributor

Choose a reason for hiding this comment

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

imported but not used.

@gnidan
Copy link
Contributor Author

gnidan commented Oct 27, 2020

Re: logging actual results - that's another thing that I wanted to do but figured it could wait. My concern with logging actual results is that there needs to be a mechanism to say how verbose you want the logs - otherwise the output would just be entirely unwieldy.

@gnidan gnidan merged commit 4db36c3 into develop Oct 27, 2020
@gnidan gnidan deleted the db-logging branch October 27, 2020 16:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants