-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Instrument @truffle/db with some initial logging #3475
Conversation
- Log each custom defined resolver - Log graphql and pouch operations
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 |
There was a problem hiding this 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"); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imported but not used.
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. |
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.