mirror of
https://github.com/foomo/sesamy-cli.git
synced 2025-10-16 12:35:36 +00:00
fix: use warning logger
This commit is contained in:
parent
0617588911
commit
bc28c78ad8
@ -14,6 +14,7 @@ import (
|
||||
tracifyprovider "github.com/foomo/sesamy-cli/pkg/provider/tracify"
|
||||
umamiprovider "github.com/foomo/sesamy-cli/pkg/provider/umami"
|
||||
"github.com/foomo/sesamy-cli/pkg/tagmanager"
|
||||
"github.com/foomo/sesamy-cli/pkg/utils"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/pterm/pterm"
|
||||
"github.com/spf13/cobra"
|
||||
@ -143,7 +144,8 @@ func NewServer(root *cobra.Command) {
|
||||
}
|
||||
tree.Children = append(tree.Children, child)
|
||||
}
|
||||
if err := pterm.DefaultTree.WithRoot(tree).Render(); err != nil {
|
||||
|
||||
if err := pterm.DefaultTree.WithRoot(tree).WithWriter(utils.NewPTermWriter(pterm.Warning)).Render(); err != nil {
|
||||
l.Warn("failed to render missed resources", "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
googletagmanagerprovider "github.com/foomo/sesamy-cli/pkg/provider/googletagmanager"
|
||||
hotjarprovider "github.com/foomo/sesamy-cli/pkg/provider/hotjar"
|
||||
"github.com/foomo/sesamy-cli/pkg/tagmanager"
|
||||
"github.com/foomo/sesamy-cli/pkg/utils"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/pterm/pterm"
|
||||
"github.com/spf13/cobra"
|
||||
@ -112,7 +113,7 @@ func NewWeb(root *cobra.Command) {
|
||||
}
|
||||
tree.Children = append(tree.Children, child)
|
||||
}
|
||||
if err := pterm.DefaultTree.WithRoot(tree).Render(); err != nil {
|
||||
if err := pterm.DefaultTree.WithRoot(tree).WithWriter(utils.NewPTermWriter(pterm.Warning)).Render(); err != nil {
|
||||
l.Warn("failed to render missed resources", "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +95,6 @@ func Execute() {
|
||||
if err := root.Execute(); err != nil {
|
||||
pterm.Error.Println(say(strings.Split(errors.Cause(err).Error(), ":")[0]))
|
||||
pterm.Error.Println(err.Error())
|
||||
pterm.Error.Println(root.UsageString())
|
||||
code = 1
|
||||
}
|
||||
}
|
||||
|
||||
20
pkg/utils/ptermwriter.go
Normal file
20
pkg/utils/ptermwriter.go
Normal file
@ -0,0 +1,20 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"github.com/pterm/pterm"
|
||||
)
|
||||
|
||||
type PTermWriter struct {
|
||||
printer pterm.PrefixPrinter
|
||||
}
|
||||
|
||||
func NewPTermWriter(printer pterm.PrefixPrinter) *PTermWriter {
|
||||
return &PTermWriter{
|
||||
printer: printer,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PTermWriter) Write(b []byte) (int, error) {
|
||||
p.printer.Println(string(b))
|
||||
return len(b), nil
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user