MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / log

Function log

packages/core/src/integrations/consola.ts:228–290  ·  view source on GitHub ↗
(logObj: ConsolaLogObject)

Source from the content-addressed store, hash-verified

226
227 return {
228 log(logObj: ConsolaLogObject) {
229 // We need to exclude certain known properties from being added as additional attributes
230 // eslint-disable-next-line @typescript-eslint/no-unused-vars
231 const { type, level, message: consolaMessage, args, tag, date: _date, ...rest } = logObj;
232
233 // Get client - use provided client or current client
234 const client = providedClient || getClient();
235 if (!client) {
236 return;
237 }
238
239 // Determine the log severity level
240 const logSeverityLevel = getLogSeverityLevel(type, level);
241
242 // Early exit if this level should not be captured
243 if (!levels.has(logSeverityLevel)) {
244 return;
245 }
246
247 const { normalizeDepth = 3, normalizeMaxBreadth = 1_000 } = client.getOptions();
248
249 const attributes: Record<string, unknown> = {};
250
251 // Build attributes
252 for (const [key, value] of Object.entries(rest)) {
253 attributes[key] = normalize(value, normalizeDepth, normalizeMaxBreadth);
254 }
255
256 attributes['sentry.origin'] = 'auto.log.consola';
257
258 if (tag) {
259 attributes['consola.tag'] = tag;
260 }
261
262 if (type) {
263 attributes['consola.type'] = type;
264 }
265
266 // Only add level if it's a valid number (not null/undefined)
267 if (level != null && typeof level === 'number') {
268 attributes['consola.level'] = level;
269 }
270
271 const extractionResult = processExtractedAttributes(
272 defaultExtractAttributes(args, normalizeDepth, normalizeMaxBreadth),
273 normalizeDepth,
274 normalizeMaxBreadth,
275 );
276
277 if (extractionResult?.attributes) {
278 Object.assign(attributes, extractionResult.attributes);
279 }
280
281 _INTERNAL_captureLog({
282 level: logSeverityLevel,
283 message:
284 extractionResult?.message ||
285 consolaMessage ||

Callers

nothing calls this directly

Calls 11

getClientFunction · 0.90
normalizeFunction · 0.90
_INTERNAL_captureLogFunction · 0.90
formatConsoleArgsFunction · 0.90
getLogSeverityLevelFunction · 0.85
defaultExtractAttributesFunction · 0.85
assignMethod · 0.80
hasMethod · 0.65
getOptionsMethod · 0.65
entriesMethod · 0.65

Tested by

no test coverage detected