chore(log): use PersistentPreRunE to setup logging in a cleaner way

This commit is contained in:
2022-03-22 00:34:47 +00:00
parent bc69c016a3
commit dd5238f9ff
7 changed files with 15 additions and 17 deletions

View File

@@ -11,17 +11,13 @@ import (
type runEFunc func(cmd *cobra.Command, _ []string) error
func WithPrettyLogging(
f func(cmd *cobra.Command, args []string) error,
) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
err := SetupZerolog(cmd)
if err != nil {
return err
}
return f(cmd, args)
func PersistentPreRunE(cmd *cobra.Command, _ []string) error {
err := SetupZerolog(cmd)
if err != nil {
return err
}
return nil
}
func SetupZerolog(cmd *cobra.Command) error {