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
Hide 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'
...
@@ -9,10 +9,6 @@ import type { webpack } from 'next/dist/compiled/webpack/webpack'
import
{
COMPILER_NAMES
}
from
'../../shared/lib/constants'
import
{
COMPILER_NAMES
}
from
'../../shared/lib/constants'
import
type
{
CompilerNameValues
}
from
'../../shared/lib/constants'
import
type
{
CompilerNameValues
}
from
'../../shared/lib/constants'
export
function
startedDevelopmentServer
(
appUrl
:
string
,
bindAddr
:
string
)
{
consoleStore
.
setState
({
appUrl
,
bindAddr
})
}
type
CompilerDiagnostics
=
{
type
CompilerDiagnostics
=
{
totalModulesCount
:
number
totalModulesCount
:
number
errors
:
string
[]
|
null
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
...
@@ -80,9 +80,16 @@ let trigger = '' // default, use empty string for trigger
let
triggerUrl
:
string
|
undefined
=
undefined
let
triggerUrl
:
string
|
undefined
=
undefined
let
loadingLogTimer
:
NodeJS
.
Timeout
|
null
=
null
let
loadingLogTimer
:
NodeJS
.
Timeout
|
null
=
null
let
traceSpan
:
Span
|
null
=
null
let
traceSpan
:
Span
|
null
=
null
let
logging
=
true
store
.
subscribe
((
state
)
=>
{
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
return
}
}
...
...
packages/next/src/server/config-schema.ts
View file @
ec34cdfb
...
@@ -542,7 +542,7 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
...
@@ -542,7 +542,7 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
})
})
.
optional
(),
.
optional
(),
}),
}),
z
.
boolean
(
),
z
.
literal
(
false
),
])
])
.
optional
(),
.
optional
(),
modularizeImports
:
z
modularizeImports
:
z
...
...
packages/next/src/server/config-shared.ts
View file @
ec34cdfb
...
@@ -859,7 +859,7 @@ export interface NextConfig extends Record<string, any> {
...
@@ -859,7 +859,7 @@ export interface NextConfig extends Record<string, any> {
fullUrl
?:
boolean
fullUrl
?:
boolean
}
}
}
}
|
boolean
|
false
/**
/**
* period (in seconds) where the server allow to serve stale cache
* period (in seconds) where the server allow to serve stale cache
...
@@ -934,6 +934,7 @@ export const defaultConfig: NextConfig = {
...
@@ -934,6 +934,7 @@ export const defaultConfig: NextConfig = {
httpAgentOptions
:
{
httpAgentOptions
:
{
keepAlive
:
true
,
keepAlive
:
true
,
},
},
logging
:
{},
swrDelta
:
undefined
,
swrDelta
:
undefined
,
staticPageGenerationTimeout
:
60
,
staticPageGenerationTimeout
:
60
,
output
:
!!
process
.
env
.
NEXT_PRIVATE_STANDALONE
?
'standalone'
:
undefined
,
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(
...
@@ -256,7 +256,6 @@ export async function createHotReloaderTurbopack(
loading
:
true
,
loading
:
true
,
trigger
:
id
,
trigger
:
id
,
url
:
requestUrl
,
url
:
requestUrl
,
logging
:
nextConfig
.
logging
,
}
as
OutputState
,
}
as
OutputState
,
true
true
)
)
...
@@ -273,7 +272,6 @@ export async function createHotReloaderTurbopack(
...
@@ -273,7 +272,6 @@ export async function createHotReloaderTurbopack(
consoleStore
.
setState
(
consoleStore
.
setState
(
{
{
loading
:
false
,
loading
:
false
,
logging
:
nextConfig
.
logging
,
}
as
OutputState
,
}
as
OutputState
,
true
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'
...
@@ -88,6 +88,7 @@ import { isMetadataRoute } from '../../../lib/metadata/is-metadata-route'
import
{
normalizeMetadataPageToRoute
}
from
'../../../lib/metadata/get-metadata-route'
import
{
normalizeMetadataPageToRoute
}
from
'../../../lib/metadata/get-metadata-route'
import
{
createEnvDefinitions
}
from
'../experimental/create-env-definitions'
import
{
createEnvDefinitions
}
from
'../experimental/create-env-definitions'
import
{
JsConfigPathsPlugin
}
from
'../../../build/webpack/plugins/jsconfig-paths-plugin'
import
{
JsConfigPathsPlugin
}
from
'../../../build/webpack/plugins/jsconfig-paths-plugin'
import
{
store
as
consoleStore
}
from
'../../../build/output/store'
export
type
SetupOpts
=
{
export
type
SetupOpts
=
{
renderServer
:
LazyRenderServerInstance
renderServer
:
LazyRenderServerInstance
...
@@ -175,6 +176,11 @@ async function startWatcher(opts: SetupOpts) {
...
@@ -175,6 +176,11 @@ async function startWatcher(opts: SetupOpts) {
const
serverFields
:
ServerFields
=
{}
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
const
hotReloader
:
NextJsHotReloaderInterface
=
opts
.
turbo
?
await
createHotReloaderTurbopack
(
opts
,
serverFields
,
distDir
)
?
await
createHotReloaderTurbopack
(
opts
,
serverFields
,
distDir
)
:
new
HotReloaderWebpack
(
opts
.
dir
,
{
:
new
HotReloaderWebpack
(
opts
.
dir
,
{
...
...
packages/next/src/server/next-server.ts
View file @
ec34cdfb
...
@@ -1117,24 +1117,16 @@ export default class NextNodeServer extends BaseServer<
...
@@ -1117,24 +1117,16 @@ export default class NextNodeServer extends BaseServer<
const
normalizedReq
=
this
.
normalizeReq
(
req
)
const
normalizedReq
=
this
.
normalizeReq
(
req
)
const
normalizedRes
=
this
.
normalizeRes
(
res
)
const
normalizedRes
=
this
.
normalizeRes
(
res
)
let
logging
=
this
.
nextConfig
.
logging
const
logConfig
=
this
.
nextConfig
.
logging
let
isLoggingDisabled
=
false
const
isLoggingDisabled
=
logConfig
===
false
if
(
typeof
logging
===
'boolean'
)
{
const
fetchesLoggingConfig
=
isLoggingDisabled
if
(
logging
===
false
)
{
?
false
// disable all logging options if logging === false
:
logConfig
?.
fetches
logging
=
{}
isLoggingDisabled
=
true
const
enabledVerboseLogging
=
!!
fetchesLoggingConfig
}
const
shouldTruncateUrl
=
// explicit check value for better readability
typeof
fetchesLoggingConfig
===
'object'
&&
if
(
logging
===
true
)
{
!
fetchesLoggingConfig
.
fullUrl
// enable all logging options if logging === true
logging
=
{
fetches
:
{
fullUrl
:
true
}
}
}
}
const
loggingFetchesConfig
=
logging
?.
fetches
const
enabledVerboseLogging
=
!!
loggingFetchesConfig
const
shouldTruncateUrl
=
!
loggingFetchesConfig
?.
fullUrl
if
(
this
.
renderOpts
.
dev
)
{
if
(
this
.
renderOpts
.
dev
)
{
const
{
blue
,
green
,
yellow
,
red
,
gray
,
white
,
bold
}
=
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
{
nextTestSetup
}
from
'e2e-utils'
import
{
check
}
from
'next-test-utils'
describe
(
'disable-logging-route'
,
()
=>
{
describe
(
'
app-dir -
disable-logging-route'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
files
:
__dirname
,
})
})
...
@@ -9,19 +8,7 @@ describe('disable-logging-route', () => {
...
@@ -9,19 +8,7 @@ describe('disable-logging-route', () => {
it
(
'should not log if disabled logging'
,
async
()
=>
{
it
(
'should not log if disabled logging'
,
async
()
=>
{
const
html
=
await
next
.
render
(
'/slug1'
)
const
html
=
await
next
.
render
(
'/slug1'
)
expect
(
html
).
toContain
(
'slug1'
)
expect
(
html
).
toContain
(
'slug1'
)
expect
(
next
.
cliOutput
).
not
.
toContain
(
'GET /slug1'
)
expect
(
next
.
cliOutput
).
not
.
toContain
(
'Compiling'
)
expect
(
next
.
cliOutput
).
not
.
toContain
(
'GET'
)
// 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'
)
})
})
})
})
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