This repository was archived by the owner on Jun 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlist.go
More file actions
80 lines (67 loc) · 2.82 KB
/
list.go
File metadata and controls
80 lines (67 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package main
import (
"github.com/pkg/errors"
"github.com/ylacancellera/galera-log-explainer/display"
"github.com/ylacancellera/galera-log-explainer/regex"
"github.com/ylacancellera/galera-log-explainer/types"
)
type list struct {
// Paths is duplicated because it could not work as variadic with kong cli if I set it as CLI object
Paths []string `arg:"" name:"paths" help:"paths of the log to use"`
SkipStateColoredColumn bool `help:"avoid having the placeholder colored with mysql state, which is guessed using several regexes that will not be displayed"`
All bool `help:"List everything" xor:"states,views,events,sst,applicative"`
States bool `help:"List WSREP state changes(SYNCED, DONOR, ...)" xor:"states"`
Views bool `help:"List how Galera views evolved (who joined, who left)" xor:"views"`
Events bool `help:"List generic mysql events (start, shutdown, assertion failures)" xor:"events"`
SST bool `help:"List Galera synchronization event" xor:"sst"`
Applicative bool `help:"List applicative events (resyncs, desyncs, conflicts). Events tied to one's usage of Galera" xor:"applicative"`
}
func (l *list) Help() string {
return `List events for each nodes in a columnar output
It will merge logs between themselves
"identifier" is an internal metadata, this is used to merge logs.
Usage:
galera-log-explainer list --all <list of files>
galera-log-explainer list --all *.log
galera-log-explainer list --sst --views --states <list of files>
galera-log-explainer list --events --views *.log
`
}
func (l *list) Run() error {
if !(l.All || l.Events || l.States || l.SST || l.Views || l.Applicative) {
return errors.New("Please select a type of logs to search: --all, or any parameters from: --sst --views --events --states")
}
toCheck := l.regexesToUse()
timeline, err := timelineFromPaths(CLI.List.Paths, toCheck)
if err != nil {
return errors.Wrap(err, "Could not list events")
}
display.TimelineCLI(timeline, CLI.Verbosity)
return nil
}
func (l *list) regexesToUse() types.RegexMap {
// IdentRegexes is always needed: we would not be able to identify the node where the file come from
toCheck := regex.IdentsMap
if l.States || l.All {
toCheck.Merge(regex.StatesMap)
} else if !l.SkipStateColoredColumn {
regex.SetVerbosity(types.DebugMySQL, regex.StatesMap)
toCheck.Merge(regex.StatesMap)
}
if l.Views || l.All {
toCheck.Merge(regex.ViewsMap)
}
if l.SST || l.All {
toCheck.Merge(regex.SSTMap)
}
if l.Applicative || l.All {
toCheck.Merge(regex.ApplicativeMap)
}
if l.Events || l.All {
toCheck.Merge(regex.EventsMap)
} else if !l.SkipStateColoredColumn {
regex.SetVerbosity(types.DebugMySQL, regex.EventsMap)
toCheck.Merge(regex.EventsMap)
}
return toCheck
}