@@ -11,7 +11,6 @@ import type {
1111 Extra ,
1212 Extras ,
1313 FinishedCheckIn ,
14- LogSeverityLevel ,
1514 MonitorConfig ,
1615 Primitive ,
1716 Session ,
@@ -24,6 +23,7 @@ import { logger } from './utils-hoist/logger';
2423import { uuid4 } from './utils-hoist/misc' ;
2524import { timestampInSeconds } from './utils-hoist/time' ;
2625import { GLOBAL_OBJ } from './utils-hoist/worldwide' ;
26+ import { parameterize } from './utils/parameterize' ;
2727import type { ExclusiveEventHintOrCaptureContext } from './utils/prepareEvent' ;
2828import { parseEventHintOrCaptureContext } from './utils/prepareEvent' ;
2929
@@ -337,8 +337,6 @@ export function captureSession(end: boolean = false): void {
337337 _sendSessionUpdate ( ) ;
338338}
339339
340- type OmitFirstArg < F > = F extends ( x : LogSeverityLevel , ...args : infer P ) => infer R ? ( ...args : P ) => R : never ;
341-
342340/**
343341 * A namespace for experimental logging functions.
344342 *
@@ -349,55 +347,106 @@ export const _experiment_log = {
349347 * A utility to record a log with level 'TRACE' and send it to sentry.
350348 *
351349 * Logs represent a message and some parameters which provide context for a trace or error.
352- * Ex: Sentry._experiment_log.trace`user ${username} just bought ${item}!`
350+ *
351+ * @example
352+ * ```js
353+ * const { trace, fmt } = Sentry._experiment_log;
354+ * trace(fmt`user ${username} just bought ${item}!`);
355+ * ```
353356 */
354- trace : sendLog . bind ( null , 'trace' ) as OmitFirstArg < typeof sendLog > ,
357+ trace : sendLog ( 'trace' ) ,
355358 /**
356359 * A utility to record a log with level 'DEBUG' and send it to sentry.
357360 *
358361 * Logs represent a message and some parameters which provide context for a trace or error.
359- * Ex: Sentry._experiment_log.debug`user ${username} just bought ${item}!`
362+ *
363+ * @example
364+ * ```js
365+ * const { debug, fmt } = Sentry._experiment_log;
366+ * debug(fmt`user ${username} just bought ${item}!`);
367+ * ```
360368 */
361- debug : sendLog . bind ( null , 'debug' ) as OmitFirstArg < typeof sendLog > ,
369+ debug : sendLog ( 'debug' ) ,
362370 /**
363371 * A utility to record a log with level 'INFO' and send it to sentry.
364372 *
365373 * Logs represent a message and some parameters which provide context for a trace or error.
366- * Ex: Sentry._experiment_log.info`user ${username} just bought ${item}!`
374+ *
375+ * @example
376+ * ```js
377+ * const { info, fmt } = Sentry._experiment_log;
378+ * info(fmt`user ${username} just bought ${item}!`);
379+ * ```
367380 */
368- info : sendLog . bind ( null , 'info' ) as OmitFirstArg < typeof sendLog > ,
381+ info : sendLog ( 'info' ) ,
369382 /**
370383 * A utility to record a log with level 'INFO' and send it to sentry.
371384 *
372385 * Logs represent a message and some parameters which provide context for a trace or error.
373- * Ex: Sentry._experiment_log.log`user ${username} just bought ${item}!`
386+ *
387+ * @example
388+ * ```js
389+ * const { log, fmt } = Sentry._experiment_log;
390+ * log(fmt`user ${username} just bought ${item}!`);
391+ * ```
374392 */
375- log : sendLog . bind ( null , 'log' ) as OmitFirstArg < typeof sendLog > ,
393+ log : sendLog ( 'info' , 10 ) ,
376394 /**
377395 * A utility to record a log with level 'ERROR' and send it to sentry.
378396 *
379397 * Logs represent a message and some parameters which provide context for a trace or error.
380- * Ex: Sentry._experiment_log.error`user ${username} just bought ${item}!`
398+ *
399+ * @example
400+ * ```js
401+ * const { error, fmt } = Sentry._experiment_log;
402+ * error(fmt`user ${username} just bought ${item}!`);
403+ * ```
381404 */
382- error : sendLog . bind ( null , 'error' ) as OmitFirstArg < typeof sendLog > ,
405+ error : sendLog ( 'error' ) ,
383406 /**
384407 * A utility to record a log with level 'WARN' and send it to sentry.
385408 *
386409 * Logs represent a message and some parameters which provide context for a trace or error.
387- * Ex: Sentry._experiment_log.warn`user ${username} just bought ${item}!`
410+ *
411+ * @example
412+ * ```js
413+ * const { warn, fmt } = Sentry._experiment_log;
414+ * warn(fmt`user ${username} just bought ${item}!`);
415+ * ```
388416 */
389- warn : sendLog . bind ( null , 'warn' ) as OmitFirstArg < typeof sendLog > ,
417+ warn : sendLog ( 'warn' ) ,
390418 /**
391419 * A utility to record a log with level 'FATAL' and send it to sentry.
392420 *
393421 * Logs represent a message and some parameters which provide context for a trace or error.
394- * Ex: Sentry._experiment_log.warn`user ${username} just bought ${item}!`
422+ *
423+ * @example
424+ * ```js
425+ * const { fatal, fmt } = Sentry._experiment_log;
426+ * fatal(fmt`user ${username} just bought ${item}!`);
427+ * ```
395428 */
396- fatal : sendLog . bind ( null , 'fatal' ) as OmitFirstArg < typeof sendLog > ,
429+ fatal : sendLog ( 'fatal' ) ,
430+
431+ /**
432+ * Tagged template function which returns parameterized representation of the message
433+ *
434+ * @example
435+ * ```js
436+ * Sentry._experiment_log.fmt`This is a log statement with ${x} and ${y} params`
437+ * ```
438+ */
439+ fmt : parameterize ,
440+
397441 /**
398442 * A flexible utility to record a log with a custom level and send it to sentry.
399443 *
400444 * You can optionally pass in custom attributes and a custom severity number to be attached to the log.
445+ *
446+ * @example
447+ * ```js
448+ * Sentry._experiment_log.emit({ level: 'info', message: Sentry._experiment_log.fmt`user ${username }just bought ${item}`, attributes: { extra: 123 } })
449+ * ```
401450 */
402- captureLog,
451+ emit : captureLog ,
403452} ;
0 commit comments