mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-25 15:39:37 -05:00
32 lines
526 B
Go
32 lines
526 B
Go
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"log/slog"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
type debugLog interface {
|
|
Debug(msg string, args ...any)
|
|
}
|
|
|
|
func newCLILogger(cmd *cobra.Command) (debugLog, error) {
|
|
logLvl := slog.LevelInfo
|
|
debugLog, err := cmd.Flags().GetBool("debug")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if debugLog {
|
|
logLvl = slog.LevelDebug
|
|
}
|
|
|
|
return logger.NewTextLogger(logLvl), nil
|
|
}
|