42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
/*
|
|
Copyright © 2026 Craig Williams <craig@avsdev.uk>
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
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()
|
|
}
|
|
}
|