Skip to content

Commit aee2b06

Browse files
maxandersenbep
authored andcommitted
Add --debug option to be improved on over time
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.
1 parent c1a5da9 commit aee2b06

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

‎commands/hugo.go‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ var (
143143
renderToMemory bool // for benchmark testing
144144
verbose bool
145145
verboseLog bool
146+
debug bool
146147
quiet bool
147148
)
148149

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

437+
if cfg.GetBool("debug") {
438+
stdoutThreshold = jww.LevelDebug
439+
}
440+
435441
if verboseLog {
436442
logThreshold = jww.LevelInfo
443+
if cfg.GetBool("debug") {
444+
logThreshold = jww.LevelDebug
445+
}
437446
}
438447

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

448457
func (c *commandeer) initializeFlags(cmd *cobra.Command) {
449-
persFlagKeys := []string{"verbose", "logFile"}
458+
persFlagKeys := []string{"debug", "verbose", "logFile"}
450459
flagKeys := []string{
451460
"cleanDestinationDir",
452461
"buildDrafts",

‎hugolib/config.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,5 @@ func loadDefaultSettingsFor(v *viper.Viper) {
132132
v.SetDefault("enableGitInfo", false)
133133
v.SetDefault("ignoreFiles", make([]string, 0))
134134
v.SetDefault("disableAliases", false)
135+
v.SetDefault("debug", false)
135136
}

0 commit comments

Comments
 (0)