@@ -5,8 +5,11 @@ import type {
55 TaskFolderAssociation ,
66 WorktreeInfo ,
77} from "../../shared/types" ;
8+ import { logger } from "../lib/logger" ;
89import { clearAllStoreData , foldersStore } from "./store" ;
910
11+ const log = logger . scope ( "folders" ) ;
12+
1013function generateFolderId ( ) : string {
1114 return `folder_${ Date . now ( ) } _${ Math . random ( ) . toString ( 36 ) . substring ( 2 , 9 ) } ` ;
1215}
@@ -54,7 +57,7 @@ async function removeFolder(folderId: string): Promise<void> {
5457
5558 foldersStore . set ( "folders" , filtered ) ;
5659 foldersStore . set ( "taskAssociations" , filteredAssociations ) ;
57- console . log ( `Removed folder with ID: ${ folderId } ` ) ;
60+ log . debug ( `Removed folder with ID: ${ folderId } ` ) ;
5861}
5962
6063async function updateFolderAccessed ( folderId : string ) : Promise < void > {
@@ -148,7 +151,7 @@ export function registerFoldersIpc(): void {
148151 try {
149152 return await getFolders ( ) ;
150153 } catch ( error ) {
151- console . error ( "Failed to get folders:" , error ) ;
154+ log . error ( "Failed to get folders:" , error ) ;
152155 return [ ] ;
153156 }
154157 } ,
@@ -163,7 +166,7 @@ export function registerFoldersIpc(): void {
163166 try {
164167 return await addFolder ( folderPath ) ;
165168 } catch ( error ) {
166- console . error ( `Failed to add folder ${ folderPath } :` , error ) ;
169+ log . error ( `Failed to add folder ${ folderPath } :` , error ) ;
167170 throw error ;
168171 }
169172 } ,
@@ -175,7 +178,7 @@ export function registerFoldersIpc(): void {
175178 try {
176179 await removeFolder ( folderId ) ;
177180 } catch ( error ) {
178- console . error ( `Failed to remove folder ${ folderId } :` , error ) ;
181+ log . error ( `Failed to remove folder ${ folderId } :` , error ) ;
179182 throw error ;
180183 }
181184 } ,
@@ -187,7 +190,7 @@ export function registerFoldersIpc(): void {
187190 try {
188191 await updateFolderAccessed ( folderId ) ;
189192 } catch ( error ) {
190- console . error ( `Failed to update folder with ID: ${ folderId } :` , error ) ;
193+ log . error ( `Failed to update folder with ID: ${ folderId } :` , error ) ;
191194 }
192195 } ,
193196 ) ;
@@ -197,9 +200,9 @@ export function registerFoldersIpc(): void {
197200 async ( _event : IpcMainInvokeEvent ) : Promise < void > => {
198201 try {
199202 clearAllStoreData ( ) ;
200- console . log ( "Cleared all application data" ) ;
203+ log . info ( "Cleared all application data" ) ;
201204 } catch ( error ) {
202- console . error ( "Failed to clear all data:" , error ) ;
205+ log . error ( "Failed to clear all data:" , error ) ;
203206 throw error ;
204207 }
205208 } ,
@@ -211,7 +214,7 @@ export function registerFoldersIpc(): void {
211214 try {
212215 return await getTaskAssociations ( ) ;
213216 } catch ( error ) {
214- console . error ( "Failed to get task associations:" , error ) ;
217+ log . error ( "Failed to get task associations:" , error ) ;
215218 return [ ] ;
216219 }
217220 } ,
@@ -226,7 +229,7 @@ export function registerFoldersIpc(): void {
226229 try {
227230 return await getTaskAssociation ( taskId ) ;
228231 } catch ( error ) {
229- console . error ( `Failed to get task association for ${ taskId } :` , error ) ;
232+ log . error ( `Failed to get task association for ${ taskId } :` , error ) ;
230233 return null ;
231234 }
232235 } ,
@@ -244,7 +247,7 @@ export function registerFoldersIpc(): void {
244247 try {
245248 return await setTaskAssociation ( taskId , folderId , folderPath , worktree ) ;
246249 } catch ( error ) {
247- console . error ( `Failed to set task association for ${ taskId } :` , error ) ;
250+ log . error ( `Failed to set task association for ${ taskId } :` , error ) ;
248251 throw error ;
249252 }
250253 } ,
@@ -260,7 +263,7 @@ export function registerFoldersIpc(): void {
260263 try {
261264 return await updateTaskWorktree ( taskId , worktree ) ;
262265 } catch ( error ) {
263- console . error ( `Failed to update worktree for ${ taskId } :` , error ) ;
266+ log . error ( `Failed to update worktree for ${ taskId } :` , error ) ;
264267 return null ;
265268 }
266269 } ,
@@ -272,10 +275,7 @@ export function registerFoldersIpc(): void {
272275 try {
273276 await removeTaskAssociation ( taskId ) ;
274277 } catch ( error ) {
275- console . error (
276- `Failed to remove task association for ${ taskId } :` ,
277- error ,
278- ) ;
278+ log . error ( `Failed to remove task association for ${ taskId } :` , error ) ;
279279 throw error ;
280280 }
281281 } ,
@@ -287,7 +287,7 @@ export function registerFoldersIpc(): void {
287287 try {
288288 await clearTaskWorktree ( taskId ) ;
289289 } catch ( error ) {
290- console . error ( `Failed to clear worktree for ${ taskId } :` , error ) ;
290+ log . error ( `Failed to clear worktree for ${ taskId } :` , error ) ;
291291 throw error ;
292292 }
293293 } ,
0 commit comments