Fix: error msg with uppercase, usage missed pt-

This commit is contained in:
Yoann La Cancellera
2023-09-14 10:24:14 +02:00
parent 5638387713
commit 6d6f30372c
6 changed files with 24 additions and 21 deletions

View File

@@ -19,7 +19,7 @@ func (c *ctx) Help() string {
func (c *ctx) Run() error {
if len(c.Paths) != 1 {
return errors.New("Can only use 1 path at a time for ctx subcommand")
return errors.New("can only use 1 path at a time for ctx subcommand")
}
timeline, err := timelineFromPaths(c.Paths, regex.AllRegexes())

View File

@@ -49,7 +49,7 @@ func timelineFromPaths(paths []string, regexes types.RegexMap) (types.Timeline,
continue
}
found = true
logger.Debug().Str("path", path).Msg("Finished searching")
logger.Debug().Str("path", path).Msg("finished searching")
// Why it should not just identify using the file path:
// so that we are able to merge files that belong to the same nodes
@@ -63,7 +63,7 @@ func timelineFromPaths(paths []string, regexes types.RegexMap) (types.Timeline,
}
}
if !found {
return nil, errors.New("Could not find data")
return nil, errors.New("could not find data")
}
return timeline, nil
}
@@ -89,7 +89,7 @@ func prepareGrepArgument(regexes types.RegexMap) string {
if CLI.PxcOperator {
grepRegex += ")"
}
logger.Debug().Str("grepArg", grepRegex).Msg("Compiled grep arguments")
logger.Debug().Str("grepArg", grepRegex).Msg("compiled grep arguments")
return grepRegex
}
@@ -135,7 +135,7 @@ func execGrepAndIterate(path, compiledRegex string, stdout chan<- string) error
// double-check it stopped correctly
if err = cmd.Wait(); err != nil {
if exiterr, ok := err.(*exec.ExitError); ok && exiterr.ExitCode() == 1 {
return errors.New("Found nothing")
return errors.New("found nothing")
}
return errors.Wrap(err, "grep subprocess error")
}

View File

@@ -1,6 +1,8 @@
package main
import (
"fmt"
"github.com/percona/percona-toolkit/src/go/pt-galera-log-explainer/display"
"github.com/percona/percona-toolkit/src/go/pt-galera-log-explainer/regex"
"github.com/percona/percona-toolkit/src/go/pt-galera-log-explainer/types"
@@ -20,30 +22,30 @@ type list struct {
}
func (l *list) Help() string {
return `List events for each nodes in a columnar output
return fmt.Sprintf(`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
`
%[1]s list --all <list of files>
%[1]s list --all *.log
%[1]s list --sst --views --states <list of files>
%[1]s list --events --views *.log
`, toolname)
}
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")
return errors.New("flag required: --all, or any parameters from: --sst --views --events --states --applicative")
}
toCheck := l.regexesToUse()
timeline, err := timelineFromPaths(CLI.List.Paths, toCheck)
if err != nil {
return errors.Wrap(err, "Could not list events")
return errors.Wrap(err, "could not list events")
}
display.TimelineCLI(timeline, CLI.Verbosity)

View File

@@ -12,7 +12,7 @@ import (
func internalRegexSubmatch(regex *regexp.Regexp, log string) ([]string, error) {
slice := regex.FindStringSubmatch(log)
if len(slice) == 0 {
return nil, errors.New(fmt.Sprintf("Could not find submatch from log \"%s\" using pattern \"%s\"", log, regex.String()))
return nil, errors.New(fmt.Sprintf("could not find submatch from log \"%s\" using pattern \"%s\"", log, regex.String()))
}
return slice, nil
}

View File

@@ -17,21 +17,22 @@ type sed struct {
}
func (s *sed) Help() string {
return `sed translates a log, replacing node UUID, IPS, names with either name or IP everywhere. By default it replaces by name.
return fmt.Sprintf(`sed translates a log, replacing node UUID, IPS, names with either name or IP everywhere. By default it replaces by name.
Use like so:
cat node1.log | galera-log-explainer sed *.log | less
galera-log-explainer sed *.log < node1.log | less
cat node1.log | %[1]s sed *.log | less
%[1]s sed *.log < node1.log | less
You can also simply call the command to get a generated sed command to review and apply yourself
galera-log-explainer sed *.log`
%[1]s sed *.log`, toolname)
}
func (s *sed) Run() error {
toCheck := regex.AllRegexes()
timeline, err := timelineFromPaths(s.Paths, toCheck)
if err != nil {
return errors.Wrap(err, "Found nothing worth replacing")
return errors.Wrap(err, "found nothing worth replacing")
}
ctxs := timeline.GetLatestUpdatedContextsByNodes()
@@ -56,7 +57,7 @@ func (s *sed) Run() error {
}
if len(args) == 0 {
return errors.New("Could not find informations to replace")
return errors.New("could not find informations to replace")
}
fstat, err := os.Stdin.Stat()

View File

@@ -26,7 +26,7 @@ func (w *whois) Run() error {
toCheck := regex.AllRegexes()
timeline, err := timelineFromPaths(CLI.Whois.Paths, toCheck)
if err != nil {
return errors.Wrap(err, "Found nothing to translate")
return errors.Wrap(err, "found nothing to translate")
}
ctxs := timeline.GetLatestUpdatedContextsByNodes()