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
Conversation
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. |
@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. |
@wlach Sounds good. I will delete any old code that is unused and then push a commit. By the way, |
@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? |
@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, `, '') |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(', ')
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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=" + |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]}`, '');
There was a problem hiding this comment.
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!
@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? |
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? |
@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. |
@eliperelman from my understanding, the current implementation of treeherder does not allow you to view live logs, only completed ones. |
d8f9e5b
to
717eba4
Compare
@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 |
var css = errors | ||
.map(({ line_number }) => `a[id="${line_number + 1}"]+span`) | ||
.join(',') | ||
.concat('{background-color:red;color:white}'); |
There was a problem hiding this comment.
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).
@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/ |
@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 |
@wlach I removed the unused code from the old log viewer. Code is now ready to reviewed |
…ecks if the element is a string. if it is, it will parse it to an object. this change is an attempt into making line jumping faster
@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 |
@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. |
@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. |
@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) |
(apologies if my previous comment was unclear) |
There was a problem hiding this 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="; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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/
@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 :) |
@wlach I switched the directive into a component and I made sure highlighting works. |
@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 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
@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. |
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. |
Created PR #2050 for actually merging this. |
Main Features
This change is