Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
ec34cdfb
Unverified
Commit
ec34cdfb
authored
Jul 22, 2024
by
Jiachi Liu
Committed by
GitHub
Jul 22, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix logging option internal consuming (#67972)
parent
7293e7ed
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
41 additions
and
27 deletions
+41
-27
index.ts
packages/next/src/build/output/index.ts
+0
-4
store.ts
packages/next/src/build/output/store.ts
+8
-1
config-schema.ts
packages/next/src/server/config-schema.ts
+1
-1
config-shared.ts
packages/next/src/server/config-shared.ts
+2
-1
hot-reloader-turbopack.ts
packages/next/src/server/dev/hot-reloader-turbopack.ts
+0
-2
setup-dev-bundler.ts
...ges/next/src/server/lib/router-utils/setup-dev-bundler.ts
+6
-0
next-server.ts
packages/next/src/server/next-server.ts
+10
-18
page.tsx
test/e2e/app-dir/disable-logging-route/app/[id]/page.tsx
+0
-0
layout.tsx
test/e2e/app-dir/disable-logging-route/app/layout.tsx
+0
-0
disable-logging-route.test.ts
...p-dir/disable-logging-route/disable-logging-route.test.ts
+14
-0
next.config.js
test/e2e/app-dir/disable-logging-route/next.config.js
+0
-0
No files found.
packages/next/src/build/output/index.ts
View file @
ec34cdfb
...
...
@@ -9,10 +9,6 @@ import type { webpack } from 'next/dist/compiled/webpack/webpack'
import
{
COMPILER_NAMES
}
from
'../../shared/lib/constants'
import
type
{
CompilerNameValues
}
from
'../../shared/lib/constants'
export
function
startedDevelopmentServer
(
appUrl
:
string
,
bindAddr
:
string
)
{
consoleStore
.
setState
({
appUrl
,
bindAddr
})
}
type
CompilerDiagnostics
=
{
totalModulesCount
:
number
errors
:
string
[]
|
null
...
...
packages/next/src/build/output/store.ts
View file @
ec34cdfb
...
...
@@ -80,9 +80,16 @@ let trigger = '' // default, use empty string for trigger
let
triggerUrl
:
string
|
undefined
=
undefined
let
loadingLogTimer
:
NodeJS
.
Timeout
|
null
=
null
let
traceSpan
:
Span
|
null
=
null
let
logging
=
true
store
.
subscribe
((
state
)
=>
{
if
(
state
.
logging
===
false
)
{
// Update persisted logging state
if
(
'logging'
in
state
)
{
logging
=
state
.
logging
}
// If logging is disabled, do not log
if
(
!
logging
)
{
return
}
...
...
packages/next/src/server/config-schema.ts
View file @
ec34cdfb
...
...
@@ -542,7 +542,7 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
})
.
optional
(),
}),
z
.
boolean
(
),
z
.
literal
(
false
),
])
.
optional
(),
modularizeImports
:
z
...
...
packages/next/src/server/config-shared.ts
View file @
ec34cdfb
...
...
@@ -859,7 +859,7 @@ export interface NextConfig extends Record<string, any> {
fullUrl
?:
boolean
}
}
|
boolean
|
false
/**
* period (in seconds) where the server allow to serve stale cache
...
...
@@ -934,6 +934,7 @@ export const defaultConfig: NextConfig = {
httpAgentOptions
:
{
keepAlive
:
true
,
},
logging
:
{},
swrDelta
:
undefined
,
staticPageGenerationTimeout
:
60
,
output
:
!!
process
.
env
.
NEXT_PRIVATE_STANDALONE
?
'standalone'
:
undefined
,
...
...
packages/next/src/server/dev/hot-reloader-turbopack.ts
View file @
ec34cdfb
...
...
@@ -256,7 +256,6 @@ export async function createHotReloaderTurbopack(
loading
:
true
,
trigger
:
id
,
url
:
requestUrl
,
logging
:
nextConfig
.
logging
,
}
as
OutputState
,
true
)
...
...
@@ -273,7 +272,6 @@ export async function createHotReloaderTurbopack(
consoleStore
.
setState
(
{
loading
:
false
,
logging
:
nextConfig
.
logging
,
}
as
OutputState
,
true
)
...
...
packages/next/src/server/lib/router-utils/setup-dev-bundler.ts
View file @
ec34cdfb
...
...
@@ -88,6 +88,7 @@ import { isMetadataRoute } from '../../../lib/metadata/is-metadata-route'
import
{
normalizeMetadataPageToRoute
}
from
'../../../lib/metadata/get-metadata-route'
import
{
createEnvDefinitions
}
from
'../experimental/create-env-definitions'
import
{
JsConfigPathsPlugin
}
from
'../../../build/webpack/plugins/jsconfig-paths-plugin'
import
{
store
as
consoleStore
}
from
'../../../build/output/store'
export
type
SetupOpts
=
{
renderServer
:
LazyRenderServerInstance
...
...
@@ -175,6 +176,11 @@ async function startWatcher(opts: SetupOpts) {
const
serverFields
:
ServerFields
=
{}
// Update logging state once based on next.config.js when initializing
consoleStore
.
setState
({
logging
:
nextConfig
.
logging
!==
false
,
})
const
hotReloader
:
NextJsHotReloaderInterface
=
opts
.
turbo
?
await
createHotReloaderTurbopack
(
opts
,
serverFields
,
distDir
)
:
new
HotReloaderWebpack
(
opts
.
dir
,
{
...
...
packages/next/src/server/next-server.ts
View file @
ec34cdfb
...
...
@@ -1117,24 +1117,16 @@ export default class NextNodeServer extends BaseServer<
const
normalizedReq
=
this
.
normalizeReq
(
req
)
const
normalizedRes
=
this
.
normalizeRes
(
res
)
let
logging
=
this
.
nextConfig
.
logging
let
isLoggingDisabled
=
false
if
(
typeof
logging
===
'boolean'
)
{
if
(
logging
===
false
)
{
// disable all logging options if logging === false
logging
=
{}
isLoggingDisabled
=
true
}
// explicit check value for better readability
if
(
logging
===
true
)
{
// enable all logging options if logging === true
logging
=
{
fetches
:
{
fullUrl
:
true
}
}
}
}
const
loggingFetchesConfig
=
logging
?.
fetches
const
enabledVerboseLogging
=
!!
loggingFetchesConfig
const
shouldTruncateUrl
=
!
loggingFetchesConfig
?.
fullUrl
const
logConfig
=
this
.
nextConfig
.
logging
const
isLoggingDisabled
=
logConfig
===
false
const
fetchesLoggingConfig
=
isLoggingDisabled
?
false
:
logConfig
?.
fetches
const
enabledVerboseLogging
=
!!
fetchesLoggingConfig
const
shouldTruncateUrl
=
typeof
fetchesLoggingConfig
===
'object'
&&
!
fetchesLoggingConfig
.
fullUrl
if
(
this
.
renderOpts
.
dev
)
{
const
{
blue
,
green
,
yellow
,
red
,
gray
,
white
,
bold
}
=
...
...
test/
development
/app-dir/disable-logging-route/app/[id]/page.tsx
→
test/
e2e
/app-dir/disable-logging-route/app/[id]/page.tsx
View file @
ec34cdfb
File moved
test/
development
/app-dir/disable-logging-route/app/layout.tsx
→
test/
e2e
/app-dir/disable-logging-route/app/layout.tsx
View file @
ec34cdfb
File moved
test/
development
/app-dir/disable-logging-route/disable-logging-route.test.ts
→
test/
e2e
/app-dir/disable-logging-route/disable-logging-route.test.ts
View file @
ec34cdfb
import
{
nextTestSetup
}
from
'e2e-utils'
import
{
check
}
from
'next-test-utils'
describe
(
'disable-logging-route'
,
()
=>
{
describe
(
'
app-dir -
disable-logging-route'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
})
...
...
@@ -9,19 +8,7 @@ describe('disable-logging-route', () => {
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'
)
expect
(
next
.
cliOutput
).
not
.
toContain
(
'Compiling'
)
expect
(
next
.
cliOutput
).
not
.
toContain
(
'GET'
)
})
})
test/
development
/app-dir/disable-logging-route/next.config.js
→
test/
e2e
/app-dir/disable-logging-route/next.config.js
View file @
ec34cdfb
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment