From 3b2b78dc7c89aa59417c83a1fead15d4d7a21d8c Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Wed, 19 Jun 2024 00:09:13 -0300 Subject: [PATCH] use logger --- src/main/services/hydra-api.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/services/hydra-api.ts b/src/main/services/hydra-api.ts index b398cbd8..87bb4077 100644 --- a/src/main/services/hydra-api.ts +++ b/src/main/services/hydra-api.ts @@ -4,6 +4,7 @@ import { WindowManager } from "./window-manager"; import url from "url"; import { uploadGamesBatch } from "./library-sync"; import { clearGamesRemoteIds } from "./library-sync/clear-games-remote-id"; +import { logger } from "./logger"; export class HydraApi { private static instance: AxiosInstance; @@ -63,20 +64,20 @@ export class HydraApi { this.instance.interceptors.request.use( (request) => { - console.log(" ---- REQUEST -----"); - console.log(request.method, request.url, request.data); + logger.log(" ---- REQUEST -----"); + logger.log(request.method, request.url, request.data); return request; }, (error) => { - console.log("request error", error); + logger.log("request error", error); return Promise.reject(error); } ); this.instance.interceptors.response.use( (response) => { - console.log(" ---- RESPONSE -----"); - console.log( + logger.log(" ---- RESPONSE -----"); + logger.log( response.status, response.config.method, response.config.url, @@ -85,7 +86,7 @@ export class HydraApi { return response; }, (error) => { - console.log("response error", error); + logger.error("response error", error); return Promise.reject(error); } ); @@ -104,6 +105,7 @@ export class HydraApi { private static async revalidateAccessTokenIfExpired() { if (!this.userAuth.authToken) { userAuthRepository.delete({ id: 1 }); + logger.error("user is not logged in"); throw new Error("user is not logged in"); } @@ -146,6 +148,8 @@ export class HydraApi { if (WindowManager.mainWindow) { WindowManager.mainWindow.webContents.send("on-signout"); } + + logger.log("user refresh token expired"); } throw err;