Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignoreLogs = ['cascade-pattern-with-extension'] emits console error #12151

Closed
jmooring opened this issue Feb 25, 2024 · 5 comments · Fixed by #12161
Closed

ignoreLogs = ['cascade-pattern-with-extension'] emits console error #12151

jmooring opened this issue Feb 25, 2024 · 5 comments · Fixed by #12161

Comments

@jmooring
Copy link
Member

jmooring commented Feb 25, 2024

With this config...

ignoreLogs = ['cascade-pattern-with-extension']

[[cascade]]
[cascade.params]
foo = 'bar'
[cascade._target]
path = '/p1.md'   <-- will trigger the error that we want to suppress

...the build completes as expected with status code 0 (no errors), yet the console displays:

ERROR cascade target path "/p1.md" looks like a path with an extension; since Hugo v0.123.0 this will not match anything, see https://gohugo.io/methods/page/path/
You can suppress this error by adding the following to your site configuration:
ignoreLogs = ['cascade-pattern-with-extension']

The test below passes (as it should), but needs a log assertion (I couldn't get that to work).

test case
func TestFoo(t *testing.T) {
	files := `
-- hugo.toml --
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
ignoreLogs = ['cascade-pattern-with-extension']
[[cascade]]
[cascade.params]
foo = 'bar'
[cascade._target]
path = '/p1.md'
-- layouts/index.html --
{{ .Title }}
-- content/index.md --
---
title: home
---
-- content/p1.md --
---
title: p1
---
`

	b, err := TestE(t, files)
	b.Assert(err, qt.IsNil)
}

Reference: https://discourse.gohugo.io/t/ignorelogs-cascade-pattern-with-extension-is-ignored/48383

@bep
Copy link
Member

bep commented Feb 26, 2024

The test below passes (as it should), but needs a log assertion (I couldn't get that to work).

It doesn't log an error, which is correct, which I suspect is the reason you couldn't get it to work.

@jmooring
Copy link
Member Author

It may not "log" an error, but an error is displayed in the console:

git clone --single-branch -b hugo-github-issue-12151 https://github.com/jmooring/hugo-testing hugo-github-issue-12151
cd hugo-github-issue-12151
hugo server

image

@bep bep removed the NeedsTriage label Feb 26, 2024
@bep bep added this to the v0.123.4 milestone Feb 26, 2024
@bep
Copy link
Member

bep commented Feb 26, 2024

Yea, right ... we're logging this before we have configured the ... logger.

@bep bep self-assigned this Feb 26, 2024
@jmooring
Copy link
Member Author

Thanks for confirming, and please let me know if there's a simple assertion (or example) for testing stdout and stderr.

bep added a commit to bep/hugo that referenced this issue Feb 26, 2024
Also clean up the log handling in the integration tester, most notably lost logs during the config loading.

Fixes gohugoio#12151
bep added a commit that referenced this issue Feb 26, 2024
Also clean up the log handling in the integration tester, most notably lost logs during the config loading.

Fixes #12151
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants