Skip to content

Commit

Permalink
Add --debug option to be improved on over time
Browse files Browse the repository at this point in the history
Why:

 * first time using hugo I got very little info from --verbose output
   but I noticed there is quite a lot of useful DEBUG logging
 * asked for in other issues like #3514

This change addreses the need by:

 * adding a simple --debug flag which simply turns on debug level in stdout
   and logoutput if enabled.
  • Loading branch information
maxandersen authored and bep committed Jul 27, 2017
1 parent c1a5da9 commit aee2b06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion commands/hugo.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ var (
renderToMemory bool // for benchmark testing
verbose bool
verboseLog bool
debug bool
quiet bool
)

Expand Down Expand Up @@ -263,6 +264,7 @@ func initBenchmarkBuildingFlags(cmd *cobra.Command) {
// init initializes flags.
func init() {
HugoCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose output")
HugoCmd.PersistentFlags().BoolVarP(&debug, "debug", "", false, "debug output")
HugoCmd.PersistentFlags().BoolVar(&logging, "log", false, "enable Logging")
HugoCmd.PersistentFlags().StringVar(&logFile, "logFile", "", "log File path (if set, logging enabled automatically)")
HugoCmd.PersistentFlags().BoolVar(&verboseLog, "verboseLog", false, "verbose logging")
Expand Down Expand Up @@ -432,8 +434,15 @@ func createLogger(cfg config.Provider) (*jww.Notepad, error) {
stdoutThreshold = jww.LevelInfo
}

if cfg.GetBool("debug") {
stdoutThreshold = jww.LevelDebug
}

if verboseLog {
logThreshold = jww.LevelInfo
if cfg.GetBool("debug") {
logThreshold = jww.LevelDebug
}
}

// The global logger is used in some few cases.
Expand All @@ -446,7 +455,7 @@ func createLogger(cfg config.Provider) (*jww.Notepad, error) {
}

func (c *commandeer) initializeFlags(cmd *cobra.Command) {
persFlagKeys := []string{"verbose", "logFile"}
persFlagKeys := []string{"debug", "verbose", "logFile"}
flagKeys := []string{
"cleanDestinationDir",
"buildDrafts",
Expand Down
1 change: 1 addition & 0 deletions hugolib/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,5 @@ func loadDefaultSettingsFor(v *viper.Viper) {
v.SetDefault("enableGitInfo", false)
v.SetDefault("ignoreFiles", make([]string, 0))
v.SetDefault("disableAliases", false)
v.SetDefault("debug", false)
}

0 comments on commit aee2b06

Please sign in to comment.