@@ -61,12 +61,25 @@ export function logAttributeToSerializedLogAttribute(value: unknown): Serialized
6161 }
6262}
6363
64+ function defaultCaptureSerializedLog ( client : Client , serializedLog : SerializedLog ) : void {
65+ const logBuffer = _INTERNAL_getLogBuffer ( client ) ;
66+ if ( logBuffer === undefined ) {
67+ GLOBAL_OBJ . _sentryClientToLogBufferMap ?. set ( client , [ serializedLog ] ) ;
68+ } else {
69+ GLOBAL_OBJ . _sentryClientToLogBufferMap ?. set ( client , [ ...logBuffer , serializedLog ] ) ;
70+ if ( logBuffer . length >= MAX_LOG_BUFFER_SIZE ) {
71+ _INTERNAL_flushLogsBuffer ( client , logBuffer ) ;
72+ }
73+ }
74+ }
75+
6476/**
6577 * Captures a log event and sends it to Sentry.
6678 *
6779 * @param log - The log event to capture.
6880 * @param scope - A scope. Uses the current scope if not provided.
6981 * @param client - A client. Uses the current client if not provided.
82+ * @param captureSerializedLog - A function to capture the serialized log.
7083 *
7184 * @experimental This method will experience breaking changes. This is not yet part of
7285 * the stable Sentry SDK API and can be changed or removed without warning.
@@ -75,6 +88,7 @@ export function _INTERNAL_captureLog(
7588 beforeLog : Log ,
7689 client : Client | undefined = getClient ( ) ,
7790 scope = getCurrentScope ( ) ,
91+ captureSerializedLog : ( client : Client , log : SerializedLog ) => void = defaultCaptureSerializedLog ,
7892) : void {
7993 if ( ! client ) {
8094 DEBUG_BUILD && logger . warn ( 'No client available to capture log.' ) ;
@@ -151,15 +165,7 @@ export function _INTERNAL_captureLog(
151165 ) ,
152166 } ;
153167
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- }
168+ captureSerializedLog ( client , serializedLog ) ;
163169
164170 client . emit ( 'afterCaptureLog' , log ) ;
165171}
0 commit comments