StateVoicesNational / Spoke

mass-contact text/SMS distribution tool
Other
460 stars 400 forks source link

Better logs #2374

Closed engelhartrueben closed 1 week ago

engelhartrueben commented 2 weeks ago

Fixes # (issue)

Creates clearer logs.

Description

Most information found in console.logs was jumbled, which benefitted from destructuring. Others, like getConversation were confusing. Take a look at the old log:

getConversations sql undefined { offset: 0, limit: 10 } {} select "campaign_contact"."id" as "cc_id" from "campaign_contact" inner join "campaign" on "campaign"."id" = "campaign_contact"."campaign_id" where "campaign"."organization_id" = '2' and "campaign"."is_archived" = false and "is_opted_out" = false order by "cc_id" desc limit 10

Here, undefined, dealt with awsContext, which is not apparent when looking at the log. Paired with undefined being followed by sql, caused some concern when not privy to what the console.log looks like. However, getConversations sql is a string within the log, and does not call any variable.

Will now read like:

Org ID: ## :: getConversations sql -- 
  awsContext: <>          // true or false rather, than undefined
  cursor: <>              // the {offset: #, limit: #}
  assignmentFilter: <>    // {}
  offsetLimitQuery: <>    // select... from... innerjoin... on...

Most changes to any console.log follows a similar destructuring.

Additionally, most errors, like those commonly found when NGP VAN is not configured correctly, did not share what organization was causing the problem. This update focused on including org ids and other supporting information to help pinpoint any misconfiguration. This is most apparent in multi org situations.

Checklist: