26 lines
574 B
Go
26 lines
574 B
Go
package cli
|
|
|
|
import (
|
|
"log/slog"
|
|
|
|
"git.avsdev.uk/Go/job-search/internal/logging"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func SetupIntialLogging(cmd *cobra.Command) {
|
|
// Start logging to terminal first - any commands that want to use file
|
|
// logging should activate it themselves
|
|
logging.LogToTerminal()
|
|
|
|
// Check for quiet flag
|
|
if quiet, _ := cmd.Flags().GetBool("quiet"); quiet {
|
|
logging.SetLevel(slog.LevelError)
|
|
}
|
|
|
|
// Check for debug logging enabled (overrides quiet flag)
|
|
debugEnabled, _ := cmd.Flags().GetBool("debug")
|
|
if debugEnabled {
|
|
logging.EnableDebug()
|
|
}
|
|
}
|