MCPcopy
hub / github.com/vercel/next.js / logRequests

Function logRequests

packages/next/src/server/dev/log-requests.ts:43–82  ·  view source on GitHub ↗
(
  request: NodeNextRequest,
  response: NodeNextResponse,
  loggingConfig: LoggingConfig,
  requestStartTime: bigint,
  requestEndTime: bigint,
  devRequestTimingMiddlewareStart: bigint | undefined,
  devRequestTimingMiddlewareEnd: bigint | undefined,
  devRequestTimingInternalsEnd: bigint | undefined,
  devGenerateStaticParamsDuration: bigint | undefined
)

Source from the content-addressed store, hash-verified

41}
42
43export function logRequests(
44 request: NodeNextRequest,
45 response: NodeNextResponse,
46 loggingConfig: LoggingConfig,
47 requestStartTime: bigint,
48 requestEndTime: bigint,
49 devRequestTimingMiddlewareStart: bigint | undefined,
50 devRequestTimingMiddlewareEnd: bigint | undefined,
51 devRequestTimingInternalsEnd: bigint | undefined,
52 devGenerateStaticParamsDuration: bigint | undefined
53): void {
54 if (!ignoreLoggingIncomingRequests(request, loggingConfig)) {
55 logIncomingRequests(
56 request,
57 requestStartTime,
58 requestEndTime,
59 response.statusCode,
60 devRequestTimingMiddlewareStart,
61 devRequestTimingMiddlewareEnd,
62 devRequestTimingInternalsEnd,
63 devGenerateStaticParamsDuration
64 )
65
66 // Log server action after the request log
67 const serverActionLog = getRequestMeta(request, 'devServerActionLog')
68 if (serverActionLog) {
69 const argsStr = formatArgs(serverActionLog.args)
70 process.stdout.write(
71 ` └─ ƒ ${serverActionLog.functionName}(${argsStr}) in ${serverActionLog.duration}ms ${dim(serverActionLog.location)}\n`
72 )
73 removeRequestMeta(request, 'devServerActionLog')
74 }
75 }
76
77 if (request.fetchMetrics) {
78 for (const fetchMetric of request.fetchMetrics) {
79 logFetchMetric(fetchMetric, loggingConfig)
80 }
81 }
82}
83
84function logIncomingRequests(
85 request: NodeNextRequest,

Callers 1

getRequestHandlerMethod · 0.90

Calls 7

getRequestMetaFunction · 0.90
formatArgsFunction · 0.90
removeRequestMetaFunction · 0.90
logIncomingRequestsFunction · 0.85
logFetchMetricFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected