@steve31415/baselib 3.73.0 → 3.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/http.d.ts +12 -0
- package/dist/http.js +2 -0
- package/package.json +1 -1
package/dist/http.d.ts
CHANGED
|
@@ -6,6 +6,18 @@ export interface RequestLoggingOptions {
|
|
|
6
6
|
* `?app=`, so one service's sockets can be told apart by app); fields
|
|
7
7
|
* whose value is undefined are left out. */
|
|
8
8
|
meta?: (c: Context) => Record<string, unknown>;
|
|
9
|
+
/** Await `logger.flush()` after the exit line, before the response goes
|
|
10
|
+
* out, for requests where it returns true. On request-billed Cloud Run
|
|
11
|
+
* the CPU is throttled to almost nothing once the response is sent, so
|
|
12
|
+
* lines left for the shipper's batch timer — the handler's last lines and
|
|
13
|
+
* this exit line itself — often wait for the next request, and their
|
|
14
|
+
* 10 s ship attempt times out (radar's 5-minute scheduler pokes, task
|
|
15
|
+
* acb5a5e1, 2026-11-24). A handler's own `await logger.flush()` cannot
|
|
16
|
+
* cover the exit line, which is logged after the handler returns. Use it
|
|
17
|
+
* for machine callers (Scheduler pokes, `/internal/*`), not for user
|
|
18
|
+
* requests: it adds one Axiom round trip (bounded by the shipper's
|
|
19
|
+
* attempt timeout) to the response. */
|
|
20
|
+
flush?: (c: Context) => boolean;
|
|
9
21
|
}
|
|
10
22
|
/** One INFO line per request on exit (method, path, status, elapsed,
|
|
11
23
|
* identity, plus `options.meta`); /health excluded. Entry-point detail
|
package/dist/http.js
CHANGED
|
@@ -26,6 +26,8 @@ export function requestLogging(logger, options = {}) {
|
|
|
26
26
|
...(identity ? { identity: identity.email } : {}),
|
|
27
27
|
...Object.fromEntries(extra),
|
|
28
28
|
});
|
|
29
|
+
if (options.flush?.(c))
|
|
30
|
+
await logger.flush();
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
/** The address of the client that connected to Google's edge, read from
|
package/package.json
CHANGED