logger: collapse logs for hidden fields
This change "collapses" together log "groups" containing hidden fields for the TTY logger. e.g. `actions.foo._a` and `actions.foo_b` will show up as a combined `actions.foo`. Caveats: Since we don't know in advance how many tasks are in a group, the state will change back and forth. For each task in a group, the state will transition from computing to complete (e.g. blue to green), then back to computing and so on. The transition is fast enough not to be visibile. Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
1d1b9083b3
commit
55a9c9100d
@ -52,7 +52,13 @@ func (l *Logs) Add(event Event) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hide `#up.*` from log group names
|
||||||
|
// FIXME: remove in Europa
|
||||||
groupKey := strings.Split(task, ".#up")[0]
|
groupKey := strings.Split(task, ".#up")[0]
|
||||||
|
|
||||||
|
// Hide hidden fields (e.g. `._*`) from log group names
|
||||||
|
groupKey = strings.Split(groupKey, "._")[0]
|
||||||
|
|
||||||
group := l.groups[groupKey]
|
group := l.groups[groupKey]
|
||||||
|
|
||||||
// If the group doesn't exist, create it
|
// If the group doesn't exist, create it
|
||||||
@ -70,15 +76,16 @@ func (l *Logs) Add(event Event) error {
|
|||||||
|
|
||||||
// Handle state events
|
// Handle state events
|
||||||
// For state events, we just want to update the group status -- no need to
|
// For state events, we just want to update the group status -- no need to
|
||||||
// dispanything
|
// display anything
|
||||||
|
//
|
||||||
|
// FIXME: Since we don't know in advance how many tasks are in a group, the state will change back and forth.
|
||||||
|
// For each task in a group, the status will transition from computing to complete, then back to computing and so on.
|
||||||
|
// The transition is fast enough not to cause a problem.
|
||||||
if st, ok := event["state"].(string); ok {
|
if st, ok := event["state"].(string); ok {
|
||||||
// Ignore state updates for "sub" tasks
|
|
||||||
if task != groupKey {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
group.State = environment.State(st)
|
group.State = environment.State(st)
|
||||||
if group.State != environment.StateComputing {
|
if group.State == environment.StateComputing {
|
||||||
|
group.Completed = nil
|
||||||
|
} else {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
group.Completed = &now
|
group.Completed = &now
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ dagger.#Plan & {
|
|||||||
contents: data.output
|
contents: data.output
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpine: alpine.#Build & {
|
image: alpine.#Build & {
|
||||||
packages: {
|
packages: {
|
||||||
bash: {}
|
bash: {}
|
||||||
curl: {}
|
curl: {}
|
||||||
@ -52,7 +52,7 @@ dagger.#Plan & {
|
|||||||
|
|
||||||
// Check if the website was deployed
|
// Check if the website was deployed
|
||||||
verify: bash.#Run & {
|
verify: bash.#Run & {
|
||||||
input: _alpine.output
|
input: image.output
|
||||||
script: #"""
|
script: #"""
|
||||||
test "$(curl \#(deploy.deployUrl))" = "\#(marker)"
|
test "$(curl \#(deploy.deployUrl))" = "\#(marker)"
|
||||||
"""#
|
"""#
|
||||||
|
Reference in New Issue
Block a user