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: Add stage to build logs #577

Merged
merged 2 commits into from
Mar 28, 2022
Merged

feat: Add stage to build logs #577

merged 2 commits into from
Mar 28, 2022

Conversation

kylecarbs
Copy link
Member

@kylecarbs kylecarbs commented Mar 26, 2022

This adds a stage property to logs, and refactors the job logs cliui.

It also adds tests to the cliui for build logs!

asciicast

@kylecarbs kylecarbs requested a review from coadler March 26, 2022 19:24
@kylecarbs kylecarbs self-assigned this Mar 26, 2022
@kylecarbs kylecarbs force-pushed the nicerlogs branch 3 times, most recently from 615dfc2 to 4bb7597 Compare March 26, 2022 22:09
@codecov
Copy link

codecov bot commented Mar 26, 2022

Codecov Report

Merging #577 (13e303d) into main (4448ba2) will decrease coverage by 0.00%.
The diff coverage is 72.45%.

@@            Coverage Diff             @@
##             main     #577      +/-   ##
==========================================
- Coverage   63.48%   63.47%   -0.01%     
==========================================
  Files         195      194       -1     
  Lines       11205    11311     +106     
  Branches       85       85              
==========================================
+ Hits         7113     7180      +67     
- Misses       3336     3369      +33     
- Partials      756      762       +6     
Flag Coverage Δ
unittest-go- 62.54% <70.76%> (+0.27%) ⬆️
unittest-go-macos-latest ?
unittest-go-ubuntu-latest 61.47% <72.45%> (+0.14%) ⬆️
unittest-go-windows-2022 57.41% <66.10%> (+0.38%) ⬆️
unittest-js 63.32% <ø> (ø)
Impacted Files Coverage Δ
cli/cliui/cliui.go 40.00% <ø> (ø)
cli/workspacedelete.go 17.64% <0.00%> (+0.50%) ⬆️
cli/workspacestart.go 15.15% <0.00%> (+0.44%) ⬆️
cli/workspacestop.go 13.88% <0.00%> (+0.37%) ⬆️
codersdk/provisionerdaemons.go 64.61% <ø> (ø)
provisioner/terraform/provision.go 73.65% <0.00%> (-1.62%) ⬇️
cli/projectcreate.go 46.15% <40.00%> (-0.65%) ⬇️
cli/start.go 65.76% <50.00%> (-0.09%) ⬇️
cli/cliui/provisionerjob.go 69.78% <69.78%> (ø)
provisionerd/provisionerd.go 78.56% <90.66%> (-2.59%) ⬇️
... and 20 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4448ba2...13e303d. Read the comment docs.

@kylecarbs kylecarbs force-pushed the nicerlogs branch 7 times, most recently from cc3e174 to 7ed283c Compare March 26, 2022 23:24
This adds a stage property to logs, and refactors the job logs
cliui.

It also adds tests to the cliui for build logs!
@misskniss
Copy link

@kylecarbs can this be closed or does it still need to be done?

@kylecarbs
Copy link
Member Author

Confused here too. This will be merged.

cli/cliui/provisionerjob.go Outdated Show resolved Hide resolved
cli/cliui/provisionerjob.go Show resolved Hide resolved
cli/cliui/provisionerjob.go Outdated Show resolved Hide resolved
cli/cliui/provisionerjob.go Outdated Show resolved Hide resolved
@@ -109,7 +109,7 @@ func start() *cobra.Command {
if err != nil {
return xerrors.Errorf("create tunnel: %w", err)
}
_, _ = fmt.Fprintf(cmd.OutOrStdout(), cliui.Styles.Paragraph.Render(cliui.Styles.Wrap.Render(cliui.Styles.Prompt.String()+`Tunnel started. Your deployment is accessible at:`))+"\n "+cliui.Styles.Field.Render(accessURL))
_, _ = fmt.Fprintf(cmd.OutOrStdout(), cliui.Styles.Paragraph.Render(cliui.Styles.Wrap.Render(cliui.Styles.Prompt.String()+`Tunnel started. Your deployment is accessible at:`))+"\n "+cliui.Styles.Field.Render(accessURL)+"\n")
Copy link
Member

Choose a reason for hiding this comment

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

Just thinking out loud, we do the fmt.Fprintf(cmd.OutOrStdout(), ...) a lot. Might be nice to have a wrapper that accepts just cmd and ensures a newline is appended.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking that too. I'll make this change in another PR.

cmd/cliui/main.go Show resolved Hide resolved
Source: proto.LogSource_PROVISIONER_DAEMON,
Level: sdkproto.LogLevel_INFO,
Stage: "Setting up",
CreatedAt: time.Now().UTC().UnixMilli(),
Copy link
Member

Choose a reason for hiding this comment

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

The .UTC() seems redundant because unix is already UTC.

Copy link
Member

Choose a reason for hiding this comment

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

Also, is there a way we can enforce that unix milliseconds are only ever passed in here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm. Maybe with a linter, but it certainly seems like a ripe place for an issue.

@kylecarbs kylecarbs enabled auto-merge (squash) March 28, 2022 18:36
@kylecarbs kylecarbs merged commit b33dec9 into main Mar 28, 2022
@kylecarbs kylecarbs deleted the nicerlogs branch March 28, 2022 18:43
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.

None yet

3 participants