mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-06 05:54:28 -04:00
Add debug logging for verify command (#610)
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
e98feab57f
commit
1f9b6ba90f
4 changed files with 76 additions and 10 deletions
31
cli/internal/cmd/log.go
Normal file
31
cli/internal/cmd/log.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
Copyright (c) Edgeless Systems GmbH
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
type debugLog interface {
|
||||
Debugf(format string, args ...any)
|
||||
Sync()
|
||||
}
|
||||
|
||||
func newCLILogger(cmd *cobra.Command) (debugLog, error) {
|
||||
logLvl := zapcore.InfoLevel
|
||||
debugLog, err := cmd.Flags().GetBool("debug")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if debugLog {
|
||||
logLvl = zapcore.DebugLevel
|
||||
}
|
||||
|
||||
return logger.New(logger.PlainLog, logLvl), nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue