11import type { DebugLogEntry , DebugTransport } from '../types' ;
22
3- /**
4- * ANSI color codes for console output
5- */
6- const COLORS = {
7- blue : '\x1b[34m' ,
8- bright : '\x1b[1m' ,
9- cyan : '\x1b[36m' ,
10- dim : '\x1b[2m' ,
11- gray : '\x1b[90m' ,
12- green : '\x1b[32m' ,
13- magenta : '\x1b[35m' ,
14- red : '\x1b[31m' ,
15- reset : '\x1b[0m' ,
16- white : '\x1b[37m' ,
17- yellow : '\x1b[33m' ,
18- } as const ;
19-
20- /**
21- * Color mapping for different log levels
22- */
23- const LEVEL_COLORS = {
24- debug : COLORS . green ,
25- error : COLORS . red ,
26- info : COLORS . blue ,
27- warn : COLORS . yellow ,
28- } as const ;
29-
303/**
314 * A transport that writes debug logs to the host environment's console
32- * (e.g. browser devtools or Node.js stdout) with ANSI color accents.
5+ * (e.g. browser devtools or Node.js stdout).
6+ *
7+ * Currently disabled by default (noop).
338 *
349 * @public
3510 */
@@ -40,40 +15,7 @@ export class ConsoleTransport implements DebugTransport {
4015 *
4116 * @param entry - The debug log entry to print
4217 */
43- send ( entry : DebugLogEntry ) : Promise < void > {
44- const timestamp = new Date ( entry . timestamp ) . toISOString ( ) ;
45- const level = entry . level . toUpperCase ( ) ;
46- const source = entry . source ? `[${ entry . source } ]` : '' ;
47- const context = entry . context ? ` ${ JSON . stringify ( entry . context ) } ` : '' ;
48-
49- const levelColor = LEVEL_COLORS [ entry . level ] || COLORS . white ;
50-
51- const prefix = `${ COLORS . bright } ${ COLORS . cyan } [Clerk Debug]${ COLORS . reset } ` ;
52- const timestampColored = `${ COLORS . dim } ${ timestamp } ${ COLORS . reset } ` ;
53- const levelColored = `${ levelColor } ${ level } ${ COLORS . reset } ` ;
54- const sourceColored = source ? `${ COLORS . gray } ${ source } ${ COLORS . reset } ` : '' ;
55- const messageColored = `${ COLORS . white } ${ entry . message } ${ COLORS . reset } ` ;
56- const contextColored = context ? `${ COLORS . dim } ${ context } ${ COLORS . reset } ` : '' ;
57-
58- const message = `${ prefix } ${ timestampColored } ${ levelColored } ${ sourceColored } : ${ messageColored } ${ contextColored } ` ;
59-
60- switch ( entry . level ) {
61- case 'error' :
62- console . error ( message ) ;
63- break ;
64- case 'warn' :
65- console . warn ( message ) ;
66- break ;
67- case 'info' :
68- console . info ( message ) ;
69- break ;
70- case 'debug' :
71- console . debug ( message ) ;
72- break ;
73- default :
74- console . log ( message ) ;
75- }
76-
18+ send ( _entry : DebugLogEntry ) : Promise < void > {
7719 return Promise . resolve ( ) ;
7820 }
7921}
0 commit comments