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

Feature/runtime logs #735

Merged
merged 21 commits into from
May 6, 2021
Merged

Conversation

i-hate-nicknames
Copy link
Contributor

@i-hate-nicknames i-hate-nicknames commented Apr 20, 2021

Did you run make format && make check?

Fixes #725

Changes:

  • Add GET /api/visors/{pk}/runtime-logs endpoint

How to test this PR:
Run visor with hypervisor. Check output of the request.

Response is an array of json-encoded log entries. Entries are created by logger clients and can have custom fields with values, e.g. PK field that provide additional info.
Each log entry should have the following fields:
time: formatted timestamp of the log entry
msg: message of the entry
level: level of the entry
log_line: log entry line in the global log. Since the capacity of log store is limited, some old entries could be dropped.
All other keys may be absent in some entries.

pkg/visor/logstore/logstore.go Outdated Show resolved Hide resolved
pkg/visor/logstore/logstore.go Outdated Show resolved Hide resolved
@Senyoret1
Copy link
Contributor

Senyoret1 commented Apr 28, 2021

I found some things:

  • I tested it and got 50+ elements in the response, but all of them had level set to panic. Some entries just had info about API responses, so I think there is a problem with that.

  • The response appears to be JSON, but the format is not correct, because the elements are not really inside an array. Opening it with Firefox causes this error to appear:
    er

Appart from that, the response is somewhat complex, as there are a lot of possible properties and not all entries have the same ones. If the manager is just going to open the whole response in a new tab, there is no problem, but if the manager needs to show the data in a more processed way then we will need to plan what will be shown, to check if the data currently being returned will allow to do that.

@i-hate-nicknames
Copy link
Contributor Author

Thanks. Another issue that I just found is that not logs get to the hook for some reason. Apparently, new subloggers created by e.g. dmsg do not inherit hooks.

@Senyoret1 log entries are inherently heterogeneous, because callers add their own data that makes sense to them to the entries. JSON representation just gets all the data that is there.
I thought about returning just textual representation of an entry, but this way there will be no coloring and it might get long.
Would it be possible to use the generic parts of a log entry for presentation (level, date, log line, message), and show every other field as "additional fields" somewhere, like a dropdown?

@jdknives
Copy link
Member

@i-hate-nicknames this endpoint and the returned logs do not need to be colored to be honest. We will mostly use this for diagnostics so we may even just return a file to the user with plain text. Colored and nicely formatted text in the UI would be cool but not really necessary so I would keep it simple.

@i-hate-nicknames
Copy link
Contributor Author

@Senyoret1 ended up using json formatter, because standard text formatter only pretty-prints entries when using colors. I will update PR description with fields that are included in every entry

Copy link
Member

@jdknives jdknives left a comment

Choose a reason for hiding this comment

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

Good job.

pkg/visor/logstore/logstore.go Outdated Show resolved Hide resolved
pkg/visor/logstore/logstore.go Outdated Show resolved Hide resolved
@jdknives jdknives merged commit e635e0f into skycoin:develop May 6, 2021
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.

5 participants