Skip to content

Commit 5c05627

Browse files
authored
feat(core): Export _INTERNAL_captureSerializedLog (#16387)
I renamed `defaultCaptureSerializedLog` to `_INTERNAL_captureSerializedLog` and exported it so it can be accessed from other SDKs. I will use this in the Electron SDK in the root main process to add logs passed by IPC from other processes to the queue.
1 parent 2801d9b commit 5c05627

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

packages/core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export { trpcMiddleware } from './trpc';
119119
export { wrapMcpServerWithSentry } from './mcp-server';
120120
export { captureFeedback } from './feedback';
121121
export type { ReportDialogOptions } from './report-dialog';
122-
export { _INTERNAL_captureLog, _INTERNAL_flushLogsBuffer } from './logs/exports';
122+
export { _INTERNAL_captureLog, _INTERNAL_flushLogsBuffer, _INTERNAL_captureSerializedLog } from './logs/exports';
123123
export { consoleLoggingIntegration } from './logs/console-integration';
124124

125125
export type { FeatureFlag } from './featureFlags';

packages/core/src/logs/exports.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,16 @@ export function logAttributeToSerializedLogAttribute(value: unknown): Serialized
6161
}
6262
}
6363

64-
function defaultCaptureSerializedLog(client: Client, serializedLog: SerializedLog): void {
64+
/**
65+
* Captures a serialized log event and adds it to the log buffer for the given client.
66+
*
67+
* @param client - A client. Uses the current client if not provided.
68+
* @param serializedLog - The serialized log event to capture.
69+
*
70+
* @experimental This method will experience breaking changes. This is not yet part of
71+
* the stable Sentry SDK API and can be changed or removed without warning.
72+
*/
73+
export function _INTERNAL_captureSerializedLog(client: Client, serializedLog: SerializedLog): void {
6574
const logBuffer = _INTERNAL_getLogBuffer(client);
6675
if (logBuffer === undefined) {
6776
GLOBAL_OBJ._sentryClientToLogBufferMap?.set(client, [serializedLog]);
@@ -88,7 +97,7 @@ export function _INTERNAL_captureLog(
8897
beforeLog: Log,
8998
client: Client | undefined = getClient(),
9099
scope = getCurrentScope(),
91-
captureSerializedLog: (client: Client, log: SerializedLog) => void = defaultCaptureSerializedLog,
100+
captureSerializedLog: (client: Client, log: SerializedLog) => void = _INTERNAL_captureSerializedLog,
92101
): void {
93102
if (!client) {
94103
DEBUG_BUILD && logger.warn('No client available to capture log.');

0 commit comments

Comments
 (0)