-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
gui: Add log viewer (fixes #2644) #4604
Conversation
Just because there are a ton of people struggling to set env vars. Perhaps this should live in advanced settings, and perhaps we should have a button to view the log.
Awesome! A big +1 to having a button which shows the log -- that's going to be far easier for users to grok than "figure out where, if anywhere, your system is logging to". |
$http.get(urlbase + '/system/debug').success(function (data) { | ||
var debug = {}; | ||
data.enabled = data.enabled || []; | ||
$.each(data.facilities, function(key, value) { |
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 this the same as data.facilities.forEach
? Just asking because $.each
isn't used in syncthingController.js anywhere else.
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.
Same thing. forEach I think is less cross browsery.
@@ -14,9 +14,9 @@ import ( | |||
) | |||
|
|||
var ( | |||
l = logger.DefaultLogger.NewFacility("filesystem", "Filesystem access") | |||
l = logger.DefaultLogger.NewFacility("fs", "Filesystem access") |
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.
This needs to be changed in the help text in main too (and subsequently in docs).
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.
Help text in main is generated from available facilities.
ef486d3
to
a0bd933
Compare
The log view keeps re-writing tags from the beginning (cmdline confirms it isn't actually restarting): Also the trailing is very jumpy and doesn't actually follow the last line, but that may be related to the above problem. I think (de-)activating trailing should be done with a button that toggles it (while still also disabling when clicking into the text area). What is the intention of the log view? If it is meant as the main source when asking users for logs, 250 lines might not be enough and a button to copy or save the log would be neat. To not increase memory consumption by raising the limit, maybe there could be an additional debug config option to keep all the logs. |
It's rewriting logs if you haven't built syncthing, as there is a bug in the since parsing logic. I guess when we tell people to look at the log, they atleast can glimpse at the last 250 lines. You can open the log and keep it open for a while I guess, but I suspect this would only be used to peek at the last few lines. |
I have rebuilt before and now with clean & assets for good measure, the problem with repeating logs and trailing not working remains (nothing in the JS console). |
Do the http calls have a since query string? Whats the issue with trailing apart from you not liking the way you enable disable it? |
Also, the message is a red herring. Essentially, it stops tailing when the field gains focus, and the message comes up as 'click on me' just for the user to lose focus on the textarea (clicking the text doesn't actually do anything). |
I am confused: In JS console it looks like the
it fails to parse it (custom debug log after time.Parse):
The "test case" t, err := time.Parse(time.RFC3339, "2006-01-02T15:04:05Z07:00")
fmt.Println(t, err) also results in
What is wrong here? |
Strange that it can generate timestamps with that signature yet not parse them, anyway, that's definately a bug. |
I guess I could replace the text with "Click anywhere outside of the text box to continue tailing the log" |
"Z07:00" is definitely a broken time zone specifier, so wherever that is generated should be fixed.
|
EDIT: Missed calmh's comment: That is not generated, that was me copy-pasting from the Go docs.
Nah, it's non-obvious format notation combined with me not RTFM (thoroughly). The time zone is either That's actually a pretty annoying format for html queries, because |
Well, anything you put in a query string should be automatically escaped by whatever library you're using to do the query, so that shouldn't be an issue... |
How does the library know whether you mean a literal + or not? Curl and angularjs (I am assume Also I would propose to change the log rest functions such that a problem like this is a bit more obvious: --- a/cmd/syncthing/gui.go
+++ b/cmd/syncthing/gui.go
@@ -955,20 +955,36 @@ func (s *apiService) postSystemErrorClear(w http.ResponseWriter, r *http.Request
func (s *apiService) getSystemLog(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
- since, err := time.Parse(time.RFC3339, q.Get("since"))
- l.Debugln(err)
+ var t time.Time
+ if since := q.Get("since"); since != "" {
+ var err error
+ if t, err = time.Parse(time.RFC3339, since); err != nil {
+ l.Debugln(err)
+ http.Error(w, err.Error(), 400)
+ return
+ }
+ }
+
sendJSON(w, map[string][]logger.Line{
- "messages": s.systemLog.Since(since),
+ "messages": s.systemLog.Since(t),
})
}
func (s *apiService) getSystemLogTxt(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
- since, err := time.Parse(time.RFC3339, q.Get("since"))
- l.Debugln(err)
+ var t time.Time
+ if since := q.Get("since"); since != "" {
+ var err error
+ if t, err = time.Parse(time.RFC3339, since); err != nil {
+ l.Debugln(err)
+ http.Error(w, err.Error(), 400)
+ return
+ }
+ }
+
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
- for _, line := range s.systemLog.Since(since) {
+ for _, line := range s.systemLog.Since(t) {
fmt.Fprintf(w, "%s: %s\n", line.When.Format(time.RFC3339), line.Message)
}
} |
Apparently you should use encodeURIComponent with $http.get.
You pass in some values. They're url encoded. The server url decodes them, and gets your values. If you pass in a |
That's it - using |
<div id="log-viewer-log" class="tab-pane in active"> | ||
<label translate ng-if="logging.logEntries.length == 0">Loading...</label> | ||
<textarea ng-focus="logging.paused = true" ng-blur="logging.paused = false" id="logViewerText" class="form-control" rows="20" ng-if="logging.logEntries.length != 0" readonly style="font-family: Consolas; font-size: 11px; overflow: auto;">{{ logging.content() }}</textarea> | ||
<p translate class="help-block" ng-style="{'visibility': logging.paused ? 'visible' : 'hidden'}">Log tailing paused. Click here to continue</p> |
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 click on me as text seems fine and better than the new "Click anywhere..." proposal: Otherwise someone might click on the background and complain when the log modal disappears :P
I would add a dot (or three) at the end though.
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.
Three dots to existing text?
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.
To be consistent (first sentence gets a final dot): "Log tailing paused. Click here to continue."
On second thought, I don't like three dots ("continue..."). The idea was, that it signifies that something (trailing) will continue when you click, but that seems unnecessary and might be a problem for translation.
@calmh The mac agent is missing - is it a planned "revision outage" or something unforeseen? More to the point: Will it be up soon(ish) or should we start skipping that test to merge stuff? Apart from the very nitpicky comment about punctuation, this is lgtm. |
Mac builder is down because it’s at my home, internet there is apparently down, and I’m currently in Dubai and unable to troubleshoot. I’ll be back in a couple of days and will fix it then.
|
Translation strings need to be updated. |
@calmh does that before every release anyway |
@st-review lgtm |
@calmh: Noted! Need another LGTM or explicit merge command. |
I think the viewer deserves to be full screen and not a modal but that's a valid future improvement and this is great as is. |
@imsodin needs to leave his mark. |
@st-review lgtm |
👌 Merged as c58b383. Thanks, @AudriusButkevicius! |
Just because there are a ton of people struggling to set env vars. Perhaps this should live in advanced settings, and perhaps we should have a button to view the log. GitHub-Pull-Request: #4604 LGTM: calmh, imsodin
Just because there are a ton of people struggling to set env vars.
Perhaps this should live in advanced settings, and perhaps we should have a button to view the log.