mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
1f9b6ba90f
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
32 lines
565 B
Go
32 lines
565 B
Go
/*
|
|
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
|
|
}
|