@@ -61,12 +61,28 @@ export function logAttributeToSerializedLogAttribute(value: unknown): Serialized
6161 }
6262}
6363
64+ function defaultCaptureSerializedLog (
65+ client : Client ,
66+ serializedLog : SerializedLog ,
67+ ) : void {
68+ const logBuffer = _INTERNAL_getLogBuffer ( client ) ;
69+ if ( logBuffer === undefined ) {
70+ GLOBAL_OBJ . _sentryClientToLogBufferMap ?. set ( client , [ serializedLog ] ) ;
71+ } else {
72+ GLOBAL_OBJ . _sentryClientToLogBufferMap ?. set ( client , [ ...logBuffer , serializedLog ] ) ;
73+ if ( logBuffer . length >= MAX_LOG_BUFFER_SIZE ) {
74+ _INTERNAL_flushLogsBuffer ( client , logBuffer ) ;
75+ }
76+ }
77+ }
78+
6479/**
6580 * Captures a log event and sends it to Sentry.
6681 *
6782 * @param log - The log event to capture.
6883 * @param scope - A scope. Uses the current scope if not provided.
6984 * @param client - A client. Uses the current client if not provided.
85+ * @param captureSerializedLog - A function to capture the serialized log.
7086 *
7187 * @experimental This method will experience breaking changes. This is not yet part of
7288 * the stable Sentry SDK API and can be changed or removed without warning.
@@ -75,6 +91,7 @@ export function _INTERNAL_captureLog(
7591 beforeLog : Log ,
7692 client : Client | undefined = getClient ( ) ,
7793 scope = getCurrentScope ( ) ,
94+ captureSerializedLog : ( client : Client , log : SerializedLog ) => void = defaultCaptureSerializedLog ,
7895) : void {
7996 if ( ! client ) {
8097 DEBUG_BUILD && logger . warn ( 'No client available to capture log.' ) ;
@@ -151,15 +168,7 @@ export function _INTERNAL_captureLog(
151168 ) ,
152169 } ;
153170
154- const logBuffer = _INTERNAL_getLogBuffer ( client ) ;
155- if ( logBuffer === undefined ) {
156- GLOBAL_OBJ . _sentryClientToLogBufferMap ?. set ( client , [ serializedLog ] ) ;
157- } else {
158- GLOBAL_OBJ . _sentryClientToLogBufferMap ?. set ( client , [ ...logBuffer , serializedLog ] ) ;
159- if ( logBuffer . length >= MAX_LOG_BUFFER_SIZE ) {
160- _INTERNAL_flushLogsBuffer ( client , logBuffer ) ;
161- }
162- }
171+ captureSerializedLog ( client , serializedLog ) ;
163172
164173 client . emit ( 'afterCaptureLog' , log ) ;
165174}
0 commit comments