@@ -61,12 +61,25 @@ export function logAttributeToSerializedLogAttribute(value: unknown): Serialized
61
61
}
62
62
}
63
63
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
+
64
76
/**
65
77
* Captures a log event and sends it to Sentry.
66
78
*
67
79
* @param log - The log event to capture.
68
80
* @param scope - A scope. Uses the current scope if not provided.
69
81
* @param client - A client. Uses the current client if not provided.
82
+ * @param captureSerializedLog - A function to capture the serialized log.
70
83
*
71
84
* @experimental This method will experience breaking changes. This is not yet part of
72
85
* the stable Sentry SDK API and can be changed or removed without warning.
@@ -75,6 +88,7 @@ export function _INTERNAL_captureLog(
75
88
beforeLog : Log ,
76
89
client : Client | undefined = getClient ( ) ,
77
90
scope = getCurrentScope ( ) ,
91
+ captureSerializedLog : ( client : Client , log : SerializedLog ) => void = defaultCaptureSerializedLog ,
78
92
) : void {
79
93
if ( ! client ) {
80
94
DEBUG_BUILD && logger . warn ( 'No client available to capture log.' ) ;
@@ -151,15 +165,7 @@ export function _INTERNAL_captureLog(
151
165
) ,
152
166
} ;
153
167
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 ) ;
163
169
164
170
client . emit ( 'afterCaptureLog' , log ) ;
165
171
}
0 commit comments