Skip to content

Commit

Permalink
Add a field prefix to the deprecated log statements
Browse files Browse the repository at this point in the history
To make theme easier to spot, esp. on INFO level.
  • Loading branch information
bep committed Nov 1, 2023
1 parent 80f793c commit 4d38f47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion common/hugo/hugo.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func DeprecateLevel(item, alternative, version string, level logg.Level) {
msg = fmt.Sprintf("%s was deprecated in Hugo %s and will be removed in a future release. %s", item, version, alternative)
}

loggers.Log().Logger().WithLevel(level).Logf(msg)
loggers.Log().Logger().WithLevel(level).WithField(loggers.FieldNameCmd, "deprecated").Logf(msg)
}

// We ususally do about one minor version a month.
Expand Down
14 changes: 7 additions & 7 deletions testscripts/commands/deprecate.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

# Test deprecation logging.
hugo -e info --logLevel info
stdout 'INFO deprecated: item was deprecated in Hugo'

hugo -e info --logLevel info
stdout 'INFO item was deprecated in Hugo'
hugo -e warn --logLevel warn
stdout 'WARN deprecated: item was deprecated in Hugo'

hugo -e warn --logLevel warn
stdout 'WARN item was deprecated in Hugo'

! hugo -e error --logLevel warn
stdout 'ERROR item was deprecated in Hugo'
! hugo -e error --logLevel warn
stdout 'ERROR deprecated: item was deprecated in Hugo'

-- hugo.toml --
baseURL = "https://example.com/"
Expand Down

0 comments on commit 4d38f47

Please sign in to comment.