mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 21:44:55 +03:00
use logger
This commit is contained in:
parent
2e5a324669
commit
3b2b78dc7c
@ -4,6 +4,7 @@ import { WindowManager } from "./window-manager";
|
|||||||
import url from "url";
|
import url from "url";
|
||||||
import { uploadGamesBatch } from "./library-sync";
|
import { uploadGamesBatch } from "./library-sync";
|
||||||
import { clearGamesRemoteIds } from "./library-sync/clear-games-remote-id";
|
import { clearGamesRemoteIds } from "./library-sync/clear-games-remote-id";
|
||||||
|
import { logger } from "./logger";
|
||||||
|
|
||||||
export class HydraApi {
|
export class HydraApi {
|
||||||
private static instance: AxiosInstance;
|
private static instance: AxiosInstance;
|
||||||
@ -63,20 +64,20 @@ export class HydraApi {
|
|||||||
|
|
||||||
this.instance.interceptors.request.use(
|
this.instance.interceptors.request.use(
|
||||||
(request) => {
|
(request) => {
|
||||||
console.log(" ---- REQUEST -----");
|
logger.log(" ---- REQUEST -----");
|
||||||
console.log(request.method, request.url, request.data);
|
logger.log(request.method, request.url, request.data);
|
||||||
return request;
|
return request;
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
console.log("request error", error);
|
logger.log("request error", error);
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
this.instance.interceptors.response.use(
|
this.instance.interceptors.response.use(
|
||||||
(response) => {
|
(response) => {
|
||||||
console.log(" ---- RESPONSE -----");
|
logger.log(" ---- RESPONSE -----");
|
||||||
console.log(
|
logger.log(
|
||||||
response.status,
|
response.status,
|
||||||
response.config.method,
|
response.config.method,
|
||||||
response.config.url,
|
response.config.url,
|
||||||
@ -85,7 +86,7 @@ export class HydraApi {
|
|||||||
return response;
|
return response;
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
console.log("response error", error);
|
logger.error("response error", error);
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -104,6 +105,7 @@ export class HydraApi {
|
|||||||
private static async revalidateAccessTokenIfExpired() {
|
private static async revalidateAccessTokenIfExpired() {
|
||||||
if (!this.userAuth.authToken) {
|
if (!this.userAuth.authToken) {
|
||||||
userAuthRepository.delete({ id: 1 });
|
userAuthRepository.delete({ id: 1 });
|
||||||
|
logger.error("user is not logged in");
|
||||||
throw new Error("user is not logged in");
|
throw new Error("user is not logged in");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,6 +148,8 @@ export class HydraApi {
|
|||||||
if (WindowManager.mainWindow) {
|
if (WindowManager.mainWindow) {
|
||||||
WindowManager.mainWindow.webContents.send("on-signout");
|
WindowManager.mainWindow.webContents.send("on-signout");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.log("user refresh token expired");
|
||||||
}
|
}
|
||||||
|
|
||||||
throw err;
|
throw err;
|
||||||
|
Loading…
Reference in New Issue
Block a user