feat: include additional info in startup (#809)

This commit is contained in:
nils måsén 2021-03-28 21:04:11 +02:00 committed by GitHub
parent 5e17ef6014
commit 9fa2fd82a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 185 additions and 55 deletions

View file

@ -6,6 +6,7 @@ import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"os"
"strings"
)
// Notifier can send log output as notification to admins, with optional batching.
@ -42,6 +43,26 @@ func NewNotifier(c *cobra.Command) *Notifier {
return n
}
func (n *Notifier) String() string {
if len(n.types) < 1 {
return ""
}
sb := strings.Builder{}
for _, notif := range n.types {
for _, name := range notif.GetNames() {
sb.WriteString(name)
sb.WriteString(", ")
}
}
names := sb.String()
// remove the last separator
names = names[:len(names)-2]
return names
}
// getNotificationTypes produces an array of notifiers from a list of types
func (n *Notifier) getNotificationTypes(cmd *cobra.Command, levels []log.Level, types []string) []ty.Notifier {
output := make([]ty.Notifier, 0)