-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: Server side logs #31
Conversation
@adityathebe can you add an integration test for this ? |
@moshloop I've added integration test. |
pkg/files/search.go
Outdated
for scanner.Scan() { | ||
fileContents[path] = append(fileContents[path], logs.Result{ | ||
Time: fInfo.ModTime().Format(time.RFC3339), | ||
// Labels: , all the records will have the same labels. Is it necessary to add it 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.
Yes, we should also add the filename
pkg/files/search.go
Outdated
for _, path := range paths { | ||
fInfo, err := os.Stat(path) | ||
if err != nil { | ||
return nil, fmt.Errorf("error get file stat. path=%s; %w", path, err) |
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 shouldn't be an error, just returning an empty result
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.
Modified this. On error, it'll continue reading other files
- Add filepath label. - Modified integration test.
Added 1 unit test
@moshloop should be good now |
func readFilesLines(paths []string, labelsToAttach map[string]string) logsPerFile { | ||
fileContents := make(logsPerFile, len(paths)) | ||
for _, path := range paths { | ||
fInfo, err := os.Stat(path) |
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 add support for globs ?
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.
Added support
|
||
// MergeMap will merge map b into a. | ||
// On key collision, map b takes precedence. | ||
func MergeMap(a, b map[string]string) map[string]string { |
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.
@moshloop Do we have a common go pkg with small helper funcs like this one? Don't want this in here. I could create pkg/helper and move it there.
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 think it could go in here e- https://github.com/flanksource/commons/blob/master/collections/collections.go
🎉 This PR is included in version 0.0.21 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Addresses #30