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

Bug 1315808 - New Log Viewer integration #1975

Closed
wants to merge 33 commits into from

Conversation

helfi92
Copy link
Contributor

@helfi92 helfi92 commented Nov 7, 2016

Main Features

  • Be able to highlight different error lines
  • Get rid of "double hashing" when linking to a specific line number
  • Smooth scrolling
  • Highlight single and multiple lines
  • Follow log (option to scroll to the bottom of the log)

This change is Reviewable

@helfi92 helfi92 changed the title New Log Viewer Integration Bug 1315808 - New Log Viewer integration Nov 7, 2016
@helfi92
Copy link
Contributor Author

helfi92 commented Nov 8, 2016

I only commented the lines which were not making the code pass the linting tests. Most of the old implementation is still uncommented, but simply not used.

@wlach
Copy link
Contributor

wlach commented Nov 8, 2016

@helfi92 it looks like the ui tests are failing, could you have a look? http://treeherder.readthedocs.io/ui/installation.html#running-the-unit-tests

Also feel free to just delete any old code that is unused. I'd rather not have it sitting around in the repository, as it's going to confuse people.

@helfi92
Copy link
Contributor Author

helfi92 commented Nov 8, 2016

@wlach Sounds good. I will delete any old code that is unused and then push a commit. By the way, grunt checkjs and ./tests/ui/scripts/test.sh both execute successfully. But when I push my commit, I get a Firefox 31.0.0 (Linux 0.0.0) ERROR. Does that mean I will need to download a Firefox version 31 in order to fix that issue locally?

@wlach
Copy link
Contributor

wlach commented Nov 8, 2016

@helfi92 you shouldn't, no. hmm. could you rebase on master and reinstall the node dependencies? @jgraham updated the karma firefox dep (which we use to start the browser) in b379a10

@helfi92
Copy link
Contributor Author

helfi92 commented Nov 8, 2016

@wlach I did merge master with my branch in both of my commits and installed the new dependencies, so that's probably not the problem. I have a feeling that it might be happening because of me using ES6 features. Should I just change my code to be using ES5?

@wlach
Copy link
Contributor

wlach commented Nov 8, 2016

@helfi92 In theory es6 should be fine, we're already using features from it in various places. If you could try to figure it out that would be good, if you've tried and are still stuck, let me know and I can take a peek.

@@ -376,6 +401,21 @@ logViewerApp.controller('LogviewerCtrl', [
});
}

function displayErrorLines(errors) {
var css = errors
.reduce((line, err) => `${line}a[id="${err.line_number + 1}"]+span, `, '')
Copy link
Contributor

Choose a reason for hiding this comment

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

What does line mean here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eliperelman line contains the selector (e.g, a[id="1829"]+span, a[id="4490"]+span, a[id="4492"]+span, a[id="4538"]+span). Want me to rename it to selector

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh derp, didn't notice the .reduce. Nevermind.

Copy link
Contributor

Choose a reason for hiding this comment

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

Combined with my other comment then:

errors
    .map(({ line_number }) => `a[id="${line_number + 1}"] + span`)
    .join(', ')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eliperelman would it be smart to remove all the spaces to make the string smaller? No spaces between the + sign and after the comma ,

var css = errors
  .map(({ line_number }) => `a[id="${line_number + 1}"]+span`)
  .join(',')

function displayErrorLines(errors) {
var css = errors
.reduce((line, err) => `${line}a[id="${err.line_number + 1}"]+span, `, '')
.slice(0, -2)
Copy link
Contributor

Choose a reason for hiding this comment

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

What does the .slice here do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eliperelman it slices the last space character with the last comma. But now that you pointed this out, i can simply not add a space between each selector and simply slice the last comma before doing a concat with the style object. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see now. How about this? See other comment.

errors
    .map((line, err) => `${line}a[id="${err.line_number + 1}"] + span`)
    .join(', ')

var searchPart = () => {
var q = $location.search();

return "&highlightStart=" + q.highlightStart + "&highlightEnd=" + q.highlightEnd + "&lineNumber=" +
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not use template strings here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eliperelman Yes we can, but the literal will have a couple of backslashes since template literals records the newline character.

Copy link
Contributor

Choose a reason for hiding this comment

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

If it were me, I'd either prefer the slashes or array string-building over lots of concatenation. You could also get fancy since the key names match:

return [
    "highlightStart",
    "highlightEnd",
    "lineNumber",
    "wrapLines",
    "showLineNumbers"
].reduce((qs, key) => `${qs}&${key}=${q[key]}`, '');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like the array-building proposition. I'll use that one. Thanks!

@helfi92
Copy link
Contributor Author

helfi92 commented Nov 8, 2016

@wlach I'm still stuck. It can't be the use of ES6, because in one of the files I was touching, there was already some usage of ES6. I don't know what other option could be causing it when I can't really reproduce the problem. Can you try take a quick look to see if you might know?

@eliperelman
Copy link
Contributor

So, I there may be one issue here which is live logs. Right now the unified logviewer gives preference to non-live logs by attempting to load them as a binary arraybuffer first, and then gives up after 10 seconds and tries again as plain text. If we can know in Treeherder when loading the log whether it is still live or not, we can add a flag to the Unified Logviewer to skip loading as array buffer and go straight to text. Thoughts @helfi92 @wlach?

@wlach
Copy link
Contributor

wlach commented Nov 8, 2016

@helfi92 Everything passes here after rebasing on master. Could you push a branch rebased on master and see if that fixes travis?

P.S. To test locally you need to install a version of Firefox. It'll just use whatever version you have installed.

@helfi92
Copy link
Contributor Author

helfi92 commented Nov 8, 2016

@eliperelman from my understanding, the current implementation of treeherder does not allow you to view live logs, only completed ones.

@helfi92
Copy link
Contributor Author

helfi92 commented Nov 8, 2016

@wlach I rebased on master but I am still getting the same errors. It doesn't show any errors on my machine though, just on travis
screen shot 2016-11-08 at 4 36 32 pm

var css = errors
.map(({ line_number }) => `a[id="${line_number + 1}"]+span`)
.join(',')
.concat('{background-color:red;color:white}');
Copy link
Contributor

Choose a reason for hiding this comment

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

I also think that background-color: pink; color: red; has a more appealing look (for an error).

@wlach
Copy link
Contributor

wlach commented Nov 10, 2016

@helfi92 It just occured to me that the version of Firefox in the travis environment is rather old (31). Maybe there's an es6 feature it doesn't properly support or so.

Do you want to try upgrading it to the latest and see if it helps? Should be a minor tweak to .travis.yml in the root directory. https://docs.travis-ci.com/user/firefox/

@helfi92
Copy link
Contributor Author

helfi92 commented Nov 10, 2016

@wlach That seems to be the fix. the ui-tests are now passing :) Thanks for taking a look and helping. I will go ahead now and delete the unused code from the old logviewer then it should be ready for review

@helfi92
Copy link
Contributor Author

helfi92 commented Nov 17, 2016

@wlach I removed the unused code from the old log viewer. Code is now ready to reviewed

@wlach
Copy link
Contributor

wlach commented Nov 18, 2016

Haven't yet looked at the code in detail but a few problems I'm noticing in testing:

  1. The highlighting looks wrong on my Linux nightly (notice same on Chrome):
    screenshot from 2016-11-18 10-51-58

  2. Highlighting doesn't work at all if you enable line wrapping (which we probably want to enable by default, by the way)

  3. It looks like the logviewer urls are now ridiculously long by default and expose a lot of internal state:

    http://localhost:8000/logviewer.html#?job_id=39449331&repo=mozilla-inbound&highlightStart=&highlightEnd=&lineNumber=&wrapLines=false&showLineNumbers=&jumpToHighlight=false&followLog=false

    These links are frequently shared so we should try to shorten them if at all possible. The default link should be something like http://localhost:8000/logviewer.html#?job_id=39449331&repo=mozilla-inbound. I think the only really relevant piece of extra state that we might also want to pass in is a directive to jump to a specific line number.

  4. I don't think the "follow log" option is relevant by default for treeherder, could we configure it out somehow?

Overall though, this looks like a great step forward. Thanks for doing this awesome work!

@helfi92
Copy link
Contributor Author

helfi92 commented Dec 14, 2016

@wlach, what do you think about the new changes. I added some css to make it look like the current treeherder logviewer. Changes were pushed to gh-pages branch for quick access :)

@wlach
Copy link
Contributor

wlach commented Dec 19, 2016

@helfi92 this looks great! it seems more responsive now as well.

It seems like the hover effect for highlighting the error line quicklinks got broken though? Compare hovering over them here with your example: https://treeherder.mozilla.org/logviewer.html#?job_id=40233990&repo=mozilla-inbound&lineNumber=25195

I feel like functionally this is good enough to merge. I still need to review the code, will do so after the above is addressed.

@helfi92
Copy link
Contributor Author

helfi92 commented Dec 22, 2016

@wlach i addressed your comments regarding highlighting. Let me know if there's anything else you want me to change in the ui. otherwise, it should be ready for review.

@wlach
Copy link
Contributor

wlach commented Dec 22, 2016

@helfi92 testing locally I'm still not seeing the hover effect on the error line links that I'm expecting. here's a screenshot of the current behaviour for clarity (note how line 28226 is highlighted)

screen shot 2016-12-22 at 1 44 14 pm

@wlach
Copy link
Contributor

wlach commented Dec 22, 2016

(apologies if my previous comment was unclear)

Copy link
Contributor

@wlach wlach left a comment

Choose a reason for hiding this comment

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

The code all looks pretty good to me.

Could you try to switch the directive to a component? I don't think it should be too much effort. Other than that and the highlighting issue, I'd say we can land this soon.

@@ -29,7 +29,7 @@ treeherder.factory('thUrl', [
}, "");
},
getLogViewerUrl: function(job_id) {
return "logviewer.html#?job_id=" + job_id + "&repo=" + $rootScope.repoName;
return "logviewer.html#?job_id=" + job_id + "&repo=" + $rootScope.repoName + "&lineNumber=";
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it actually necessary to specify &lineNumber= here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right. i don't think it's necessary to specify that here. i'll remove it

@@ -0,0 +1,34 @@
'use strict';

treeherder.directive('thLogViewer', ['$sce', '$location', ($sce, $location) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're here, we might want to switch to using an angular component instead of a directive, which is a bit simpler... there's a few examples in ui/js/components/

@helfi92
Copy link
Contributor Author

helfi92 commented Dec 23, 2016

@wlach Yes there was a misunderstanding. I thought you were referring to the log itself but now I see what you mean. Nevertheless, the log highlighting should now look exactly like the current implementation so that's at least good. I'll now work on the log viewer step highlight and change the directive to a component. Thanks for your comments :)

@helfi92
Copy link
Contributor Author

helfi92 commented Dec 23, 2016

@wlach I switched the directive into a component and I made sure highlighting works.

@wlach
Copy link
Contributor

wlach commented Dec 28, 2016

@helfi92 Awesome! Looks great. Unfortunately I noticed one last feature that didn't make its way from the old logviewer implementation to the new. In the old one, it would auto-jump to the first failure line on load, this doesn't seem to be the case with the new one. E.g. compare when running a local instance:

http://localhost:8000/logviewer.html#?job_id=41099231&repo=mozilla-inbound
https://treeherder.mozilla.org/logviewer.html#?job_id=41099231&repo=mozilla-inbound

For reference, the original bug where this functionality was implemented was: https://bugzilla.mozilla.org/show_bug.cgi?id=1245760

After that's done, we can merge this into master for reals.

…o be using the on load event. behaviour is now as expected
@helfi92
Copy link
Contributor Author

helfi92 commented Dec 29, 2016

@wlach My bad. I just realized when I made the transition from the directive to the component, the iframe's on load event wasn't firing at the right moment. I made the required change and it seems to be acting accordingly.

By the way, I noticed when you open a log at first, it adds a certain offset to the lineNumber but then upon clicking different error lines from the log viewer steps , it removes that offset and so line jumping acts like the current implementation of this PR. Is that a wanted behaviour? I am assuming the added offset was used so that a user sees the lines right before the error. Do you want me to add this feature or is this not needed anymore since there won't be any scrolling issues with the new logviewer.

@wlach
Copy link
Contributor

wlach commented Dec 29, 2016

I'm pretty sure the old behavior was just an accident of implementation, let's just leave it the way it is for now and see if people complain. :)

I think this is good to merge now! Thank you so much for your work on this. There are some conflicts with what's currently on master, so I'll fix that up first.

wlach pushed a commit to wlach/treeherder that referenced this pull request Dec 29, 2016
@wlach
Copy link
Contributor

wlach commented Dec 29, 2016

Created PR #2050 for actually merging this.

@wlach wlach closed this Dec 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants