@@ -35,11 +35,18 @@ export class BytesRadar {
3535 message,
3636 ...( data && { data } )
3737 } ;
38-
39- console . log ( `[${ level . toUpperCase ( ) } ] ${ message } ` , data ? data : '' ) ;
38+
39+ const fn = {
40+ debug : console . debug ,
41+ info : console . info ,
42+ warn : console . warn ,
43+ error : console . error ,
44+ }
4045
4146 if ( environment === 'production' ) {
42- console . log ( JSON . stringify ( logEntry ) ) ;
47+ fn [ level ] ( JSON . stringify ( logEntry ) ) ;
48+ } else {
49+ fn [ level ] ( `[${ level . toUpperCase ( ) } ] ${ message } ` , data ? data : '' ) ;
4350 }
4451 }
4552 }
@@ -61,6 +68,11 @@ export class BytesRadar {
6168 }
6269
6370 async fetch ( request : Request ) {
71+ const url = new URL ( request . url ) ;
72+ if ( url . pathname === '/favicon.ico' ) {
73+ return new Response ( null , { status : 404 } ) ;
74+ }
75+
6476 const startTime = performance . now ( ) ;
6577 const debugInfo : any = {
6678 timestamp : new Date ( ) . toISOString ( ) ,
@@ -71,7 +83,6 @@ export class BytesRadar {
7183 await this . initializeWasm ( ) ;
7284 debugInfo . wasm_initialized = true ;
7385
74- const url = new URL ( request . url ) ;
7586 const pathParts = url . pathname . split ( '/' ) . filter ( Boolean ) ;
7687 const targetUrl = pathParts . join ( '/' ) ;
7788
@@ -124,15 +135,7 @@ export class BytesRadar {
124135 debug_info : debugInfo
125136 } ;
126137
127- console . log ( 'Analysis completed successfully:' , {
128- url : targetUrl ,
129- project : debugInfo . project_name ,
130- files : debugInfo . files_analyzed ,
131- lines : debugInfo . total_lines ,
132- languages : debugInfo . languages_detected ,
133- size : debugInfo . total_size_formatted ,
134- duration : debugInfo . total_duration_ms + 'ms'
135- } ) ;
138+ this . log ( 'info' , 'Analysis completed successfully' , debugInfo ) ;
136139
137140 return new Response ( JSON . stringify ( response ) , {
138141 headers : {
@@ -175,14 +178,7 @@ export class BytesRadar {
175178 debugInfo . suggested_fix = 'Please check the error details and try again' ;
176179 }
177180
178- console . error ( 'Error in BytesRadar fetch:' , {
179- error : errorMessage ,
180- type : errorType ,
181- category : debugInfo . error_category ,
182- stack : errorStack ,
183- url : debugInfo . target_url ,
184- duration : debugInfo . duration_ms + 'ms'
185- } ) ;
181+ this . log ( 'error' , 'Error in BytesRadar fetch' , debugInfo ) ;
186182
187183 const errorResponse : any = {
188184 error : errorMessage ,
@@ -201,14 +197,6 @@ export class BytesRadar {
201197 } ) ;
202198 }
203199 }
204-
205- private formatBytes ( bytes : number ) : string {
206- if ( bytes === 0 ) return '0 B' ;
207- const k = 1024 ;
208- const sizes = [ 'B' , 'KB' , 'MB' , 'GB' ] ;
209- const i = Math . floor ( Math . log ( bytes ) / Math . log ( k ) ) ;
210- return parseFloat ( ( bytes / Math . pow ( k , i ) ) . toFixed ( 2 ) ) + ' ' + sizes [ i ] ;
211- }
212200}
213201
214202export default {
0 commit comments