-
Notifications
You must be signed in to change notification settings - Fork 32
Add log type include filter #714
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
base: main
Are you sure you want to change the base?
Changes from all commits
c100636
d21490c
4fb3117
dcc096a
bccd92c
f5b43ae
8487400
708301d
abaf216
b78377d
2029984
6425efd
20364ed
c98468d
5614b36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package syslog | ||
|
|
||
| // LogType defines the log types used within Cloud Foundry | ||
| // Their order in the code is as documented in https://docs.cloudfoundry.org/devguide/deploy-apps/streaming-logs.html#format | ||
| type LogType string | ||
|
|
||
| const ( | ||
| LOG_API LogType = "API" | ||
| LOG_STG LogType = "STG" | ||
| LOG_RTR LogType = "RTR" | ||
| LOG_LGR LogType = "LGR" | ||
| LOG_APP LogType = "APP" | ||
| LOG_SSH LogType = "SSH" | ||
| LOG_CELL LogType = "CELL" | ||
| ) | ||
|
|
||
| // validLogTypes contains LogType prefixes for efficient lookup | ||
| var validLogTypes = map[LogType]struct{}{ | ||
| LOG_API: {}, | ||
| LOG_STG: {}, | ||
| LOG_RTR: {}, | ||
| LOG_LGR: {}, | ||
| LOG_APP: {}, | ||
| LOG_SSH: {}, | ||
| LOG_CELL: {}, | ||
| } | ||
|
|
||
| // IsValid checks if the provided LogType is valid | ||
| func (lt LogType) IsValid() bool { | ||
| _, ok := validLogTypes[lt] | ||
| return ok | ||
| } | ||
|
|
||
| // AllLogTypes returns all valid log types | ||
| func AllLogTypes() []LogType { | ||
| types := make([]LogType, 0, len(validLogTypes)) | ||
| for t := range validLogTypes { | ||
| types = append(types, t) | ||
| } | ||
| return types | ||
| } | ||
|
|
||
| // LogTypeSet is a set of LogTypes for efficient membership checking | ||
| type LogTypeSet map[LogType]struct{} | ||
|
|
||
| // Add adds a LogType to the set | ||
| func (s LogTypeSet) Add(lt LogType) { | ||
| s[lt] = struct{}{} | ||
| } | ||
|
|
||
| // Contains checks if the set contains a LogType | ||
| func (s LogTypeSet) Contains(lt LogType) bool { | ||
| _, exists := s[lt] | ||
| return exists | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ type Binding struct { | |
| DrainData DrainData `json:"type,omitempty"` | ||
| OmitMetadata bool | ||
| InternalTls bool | ||
| LogFilter *LogTypeSet | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that this has to be a pointer.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried that at first, but in manager.go line 45 My understanding is that maps in Go are not comparable, so adding LogTypeSet (which is a map[LogType]struct{}) to the Binding struct makes it non-comparable. AFAICS the alternative to using a pointer would be to implement a custom comparable key for the map, but using a pointer seemed simpler to me. |
||
| } | ||
|
|
||
| type Drain struct { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.