@@ -6,7 +6,7 @@ import type {
66 ResolvedReturnType ,
77} from './create-resource-query.svelte' ;
88import { fromStore , toStore } from 'svelte/store' ;
9- import { debugLogQuery } from '$lib/debug ' ;
9+ import { useQueryLogger } from '$lib/query-logger ' ;
1010
1111export const createResourceMutation = < T extends Resource , K extends keyof T > (
1212 client : { current : T | undefined } ,
@@ -18,7 +18,7 @@ export const createResourceMutation = <T extends Resource, K extends keyof T>(
1818 const name = $derived ( client . current ?. name ) ;
1919 const methodName = $derived ( String ( method ) ) ;
2020
21- let index = 0 ;
21+ const debug = useQueryLogger ( ) ;
2222
2323 const mutationOptions = $derived ( {
2424 mutationKey : [
@@ -38,20 +38,19 @@ export const createResourceMutation = <T extends Resource, K extends keyof T>(
3838 ) ;
3939 }
4040
41- debugLogQuery ( index , 'REQ' , name , methodName , request ) ;
41+ const logger = debug . createLogger ( ) ;
42+ logger ( 'REQ' , name , methodName , request ) ;
4243
4344 try {
44- const result = ( await clientFunc . apply (
45+ const response = ( await clientFunc . apply (
4546 client . current ,
4647 request
4748 ) ) as Promise < MutReturn > ;
4849
49- debugLogQuery ( index ++ , 'RES' , name , methodName , result ) ;
50-
51- return result ;
50+ logger ( 'RES' , name , methodName , response ) ;
51+ return response ;
5252 } catch ( error ) {
53- debugLogQuery ( index ++ , 'ERR' , name , methodName , error ) ;
54-
53+ logger ( 'ERR' , name , methodName , error ) ;
5554 throw error ;
5655 }
5756 } ,
0 commit comments