Skip to content

Show line numbers and allow jumping to specific lines in job logs#309

Merged
tmcgilchrist merged 4 commits intoocurrent:masterfrom
punchagan:line-numbers
Feb 26, 2022
Merged

Show line numbers and allow jumping to specific lines in job logs#309
tmcgilchrist merged 4 commits intoocurrent:masterfrom
punchagan:line-numbers

Conversation

@punchagan
Copy link
Copy Markdown
Contributor

@punchagan punchagan commented Feb 9, 2022

This PR adds some simple JS and CSS to allow jumping to a specific line number in the logs, and also displays line numbers for all logs

A URL like http://localhost:8080/job/2022-02-09/115753-docker-build-71c777#L11-L15 would highlight lines 11 to 15 and scroll the page to line 11.
image

@punchagan punchagan marked this pull request as draft February 9, 2022 11:55
@kit-ty-kate
Copy link
Copy Markdown
Contributor

Could there be a special tag name for the last line as well by any chance?

@punchagan punchagan marked this pull request as ready for review February 9, 2022 12:17
@punchagan punchagan force-pushed the line-numbers branch 2 times, most recently from e2c717b to bec17d6 Compare February 9, 2022 12:33
@punchagan
Copy link
Copy Markdown
Contributor Author

Could there be a special tag name for the last line as well by any chance?

Yes, that should be possible to do! I can add that if it's useful. Some thing like #end always takes you to the last line of the log?

@kit-ty-kate
Copy link
Copy Markdown
Contributor

Some thing like #end always takes you to the last line of the log?

yes, that would be perfect! Thanks!

@punchagan
Copy link
Copy Markdown
Contributor Author

@art-w pointed out that the log response would be streamed by the server and this JS code wouldn't behave correctly when the output has not yet been completely rendered. I'll take a look into how to do this correctly and update the PR.

@punchagan punchagan force-pushed the line-numbers branch 2 times, most recently from f6f8a36 to f550b2c Compare February 10, 2022 09:05
@punchagan
Copy link
Copy Markdown
Contributor Author

I've updated the PR to use a MutationObserver to update the line numbers being displayed in the logs, as the logs get streamed from the server.

@punchagan
Copy link
Copy Markdown
Contributor Author

Some thing like #end always takes you to the last line of the log?

yes, that would be perfect! Thanks!

I've also added a commit that always scrolls the page to the end when #end URL hash is present.

The job logs page is streamed from the server to the client, while the job is
running. This commit uses Mutation observers on the pre tag to append line
numbers to the newly added lines in the <pre> tag.

We also add IDs to the line number span tags, which allows jumping to specific
line using #L<num> in URL.
Either a line number or a range of line numbers can be specified in the URL
hash, for example, L5 or L15-L30. This will highlight the line 5 or all lines
15 to 30 in the UI. Also, the page scrolls to the (first) line of the specified
selection in the URL hash.
@punchagan
Copy link
Copy Markdown
Contributor Author

@talex5 @tmcgilchrist could you please review this PR?

Copy link
Copy Markdown
Member

@tmcgilchrist tmcgilchrist left a comment

Choose a reason for hiding this comment

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

LGTM

@tmcgilchrist tmcgilchrist merged commit 8b6d09b into ocurrent:master Feb 26, 2022
@punchagan punchagan deleted the line-numbers branch February 26, 2022 15:14
@punchagan
Copy link
Copy Markdown
Contributor Author

Thanks @tmcgilchrist !

tmcgilchrist added a commit to tmcgilchrist/opam-repository that referenced this pull request Apr 7, 2022
…, current_github, current_git, current_examples, current_docker and current (0.6)

CHANGES:

Core:

- Implement labelling of clusters on the Graphviz diagram
  (@ewanmellor ocurrent/ocurrent#255)

- Abort propagation on constant/equal changes (@art-w ocurrent/ocurrent#318)

API:

- GitHub: Record build status using CheckRun (@tmcgilchrist ocurrent/ocurrent#279)

- GitHub: Add details_url to check_run. (@tmcgilchrist ocurrent/ocurrent#282)

- GitHub: Add Current_github.Api.cmdliner_opt to allow writing
  pipelines which can optionally be run as GitHub apps. (@talex5 ocurrent/ocurrent#281)

- GitHub: Provide markdown details for CheckRun. (@tmcgilchrist ocurrent/ocurrent#288)

- GitHub: Fix wrong name used for repository (@tmcgilchrist ocurrent/ocurrent#289 ocurrent/ocurrent#290)

- GitHub: Support Github rebuild via webooks. (@tmcgilchrist ocurrent/ocurrent#283)

- GitHub: monitor GraphQL queries (@art-w ocurrent/ocurrent#298)

- GitHub: Limit CheckRunStatus summary and text fields to 65535.
  (@tmcgilchrist ocurrent/ocurrent#300)

- GitHub: Log extra context for Webhook validation failure.
  (@tmcgilchrist ocurrent/ocurrent#302)

- GitLab: Initial GitLab plugin work. (@tmcgilchrist ocurrent/ocurrent#299)

- Git: Make git reset less verbose (@kit-ty-kate ocurrent/ocurrent#293)

Web UI:

- Use Lwt.pause instead of Lwt_unix.yield (@MisterDA ocurrent/ocurrent#297)

- Use `ansi` instead of `current_ansi` (@samoht ocurrent/ocurrent#321)

- Show line numbers and allow jumping to specific lines in job
  logs (@punchagan ocurrent/ocurrent#309)

Docker:

- Explicitly set confirmation levels to allow for
  manually triggered jobs. (@tmcgilchrist ocurrent/ocurrent#304)

- Stop using `Dockerfile.t` completely and use strings instead.
  (@MisterDA ocurrent/ocurrent#301 ocurrent/ocurrent#316)

Other:

- Update to cohttp 4.0.0 (ocurrent/ocurrent#274, @talex5)

- Move `Current_incr` to its own repository (ocurrent/ocurrent#284, @talex5)
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.

3 participants