Files
bwilliams e19c8c2b69 Imports split into three groups: standard library, third-party, then this project's own packages
gci is configured with the sections standard, default and localmodule, and
goimports with the module path as its local prefix, so both formatters
agree.
2026-10-14 17:40:06 +01:00

30 lines
741 B
Go

package cli
import (
"log/slog"
"github.com/spf13/cobra"
"git.avsdev.uk/Go/job-search/internal/logging"
)
// SetupInitialLogging starts logging to the terminal, at the level set by
// cmd's --quiet and --debug flags (--debug wins), before any configuration
// is loaded.
func SetupInitialLogging(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()
}
}