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

feat: log errors context #84

Merged
merged 17 commits into from
Jan 28, 2021
Merged

feat: log errors context #84

merged 17 commits into from
Jan 28, 2021

Conversation

turcottedanny
Copy link
Contributor

@turcottedanny turcottedanny commented Jan 27, 2021

Screen Shot 2021-01-27 at 6 38 07 PM

Changes

  • Adds an Extras() []string concept which a View can optionally implement.
  • For views which implement this, rows are added below that each row (only for the Stream implementation).
  • Table implementation is reverted back to non-continuous mode.
  • For non silent mode, if there are errors, the entire body is displayed as YAML (we can improve this later, but the types are too varied to disambiguate for now).
  • For actions, the display is nice and neat (thanks @turcottedanny )
  • Since we dropped continuous, streaming tables, then we're back to the main version of tablewriter.

@cyx cyx marked this pull request as ready for review January 28, 2021 02:38
@cyx
Copy link
Contributor

cyx commented Jan 28, 2021

Here's what logs look like when there's actions context available:

Screen Shot 2021-01-27 at 10 51 47 PM

Users can silence the extended data:

Screen Shot 2021-01-27 at 11 05 53 PM

Snippet of silent:

Screen Shot 2021-01-27 at 11 06 08 PM

Snippet of default:

Screen Shot 2021-01-27 at 11 06 35 PM

Comment on lines +11 to +19
// NewSampledExecutionAPI creates a decorated ActionExecutionAPI which
// implements a leaky bucket based on the given interval.
func NewSampledExecutionAPI(api auth0.ActionExecutionAPI, interval time.Duration) auth0.ActionExecutionAPI {
return &sampledExecutionAPI{
api: api,
interval: interval,
timer: time.NewTimer(0),
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is likely a key pattern we can utilize for cases where we need to N+1 a query. For this particular case, actions execution information needs to be fetched as a separate API call since the log only contains the execution ID.


}

func (r *Renderer) Stream(data []View, ch <-chan View) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Stream is now completely separate and will simply display rows in "tab separated" format"

fmt.Fprintf(w, fmtStr, args...)
}

func writeTable(w io.Writer, header []string, data [][]string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

writeTable is back to its original form, without streaming concerns. (Thank god! :)

@turcottedanny
Copy link
Contributor Author

LGTM, but I can't approve this since I'm the owner of the PR

@cyx cyx merged commit f98d138 into main Jan 28, 2021
@cyx cyx deleted the improve-log-errors branch January 28, 2021 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants