-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: disable development logging by setting
logging: false
in next…
… config (#67590) ### Why? Logging compiled route `GET / in ...` is a very handy feature. It would be more great if we have an option to opt-out the logging. ### How? Set `logging` to false in next config. ```js const nextConfig = { logging: false, } // ... ``` x-ref: #65992 Closes NEXT-3583 Closes NDX-26 --------- Co-authored-by: Jiachi Liu <inbox@huozhi.im> Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
- Loading branch information
1 parent
b88b442
commit 05decb1
Showing
10 changed files
with
117 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/development/app-dir/disable-logging-route/app/[id]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page({ params: { id } }) { | ||
return <p>{id}</p> | ||
} |
8 changes: 8 additions & 0 deletions
8
test/development/app-dir/disable-logging-route/app/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ReactNode } from 'react' | ||
export default function Root({ children }: { children: ReactNode }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
27 changes: 27 additions & 0 deletions
27
test/development/app-dir/disable-logging-route/disable-logging-route.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { nextTestSetup } from 'e2e-utils' | ||
import { check } from 'next-test-utils' | ||
|
||
describe('disable-logging-route', () => { | ||
const { next } = nextTestSetup({ | ||
files: __dirname, | ||
}) | ||
|
||
it('should not log if disabled logging', async () => { | ||
const html = await next.render('/slug1') | ||
expect(html).toContain('slug1') | ||
expect(next.cliOutput).not.toContain('GET /slug1') | ||
|
||
// re-enable logging | ||
await next.patchFile('next.config.js', (content) => | ||
content.replace('logging: false,', '') | ||
) | ||
|
||
// should log now | ||
await check(async () => { | ||
const html = await next.render('/slug1') | ||
expect(html).toContain('slug1') | ||
expect(next.cliOutput).toContain('GET /slug1') | ||
return 'success' | ||
}, 'success') | ||
}) | ||
}) |
8 changes: 8 additions & 0 deletions
8
test/development/app-dir/disable-logging-route/next.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* @type {import('next').NextConfig} | ||
*/ | ||
const nextConfig = { | ||
logging: false, | ||
} | ||
|
||
module.exports = nextConfig |