mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 21:44:55 +03:00
feat: adding logger
This commit is contained in:
parent
ac9565f924
commit
eebd09ccf2
@ -87,17 +87,12 @@ const uploadSaveGame = async (
|
||||
true
|
||||
);
|
||||
|
||||
// fs.rm(zipLocation, (err) => {
|
||||
// if (err) {
|
||||
// logger.error("Failed to remove zip file", err);
|
||||
// throw err;
|
||||
// }
|
||||
|
||||
// WindowManager.mainWindow?.webContents.send(
|
||||
// `on-upload-complete-${objectId}-${shop}`,
|
||||
// true
|
||||
// );
|
||||
// });
|
||||
fs.rm(zipLocation, (err) => {
|
||||
if (err) {
|
||||
logger.error("Failed to remove zip file", err);
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -28,6 +28,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { UserFriendModal } from "./pages/shared-modals/user-friend-modal";
|
||||
import { downloadSourcesWorker } from "./workers";
|
||||
import { repacksContext } from "./context";
|
||||
import { logger } from "./logger";
|
||||
|
||||
export interface AppProps {
|
||||
children: React.ReactNode;
|
||||
@ -231,6 +232,8 @@ export function App() {
|
||||
}
|
||||
|
||||
for (const downloadSource of downloadSources) {
|
||||
logger.info("Migrating download source", downloadSource.url);
|
||||
|
||||
const channel = new BroadcastChannel(
|
||||
`download_sources:import:${downloadSource.url}`
|
||||
);
|
||||
@ -243,6 +246,10 @@ export function App() {
|
||||
channel.onmessage = () => {
|
||||
window.electron.deleteDownloadSource(downloadSource.id).then(() => {
|
||||
resolve(true);
|
||||
logger.info(
|
||||
"Deleted download source from SQLite",
|
||||
downloadSource.url
|
||||
);
|
||||
});
|
||||
|
||||
indexRepacks();
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { gameBackupsTable } from "@renderer/dexie";
|
||||
import { useToast } from "@renderer/hooks";
|
||||
import { logger } from "@renderer/logger";
|
||||
import type { LudusaviBackup, GameArtifact, GameShop } from "@types";
|
||||
import React, {
|
||||
createContext,
|
||||
@ -92,11 +93,17 @@ export function CloudSyncContextProvider({
|
||||
setArtifacts(results);
|
||||
});
|
||||
|
||||
window.electron.getGameBackupPreview(objectId, shop).then((preview) => {
|
||||
if (preview && Object.keys(preview.games).length) {
|
||||
setBackupPreview(preview);
|
||||
}
|
||||
});
|
||||
window.electron
|
||||
.getGameBackupPreview(objectId, shop)
|
||||
.then((preview) => {
|
||||
logger.info("Game backup preview", objectId, shop, preview);
|
||||
if (preview && Object.keys(preview.games).length) {
|
||||
setBackupPreview(preview);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
logger.error("Failed to get game backup preview", objectId, shop, err);
|
||||
});
|
||||
}, [objectId, shop]);
|
||||
|
||||
const uploadSaveGame = useCallback(async () => {
|
||||
@ -146,9 +153,15 @@ export function CloudSyncContextProvider({
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
window.electron.checkGameCloudSyncSupport(objectId, shop).then((result) => {
|
||||
setSupportsCloudSync(result);
|
||||
});
|
||||
window.electron
|
||||
.checkGameCloudSyncSupport(objectId, shop)
|
||||
.then((result) => {
|
||||
logger.info("Cloud sync support", objectId, shop, result);
|
||||
setSupportsCloudSync(result);
|
||||
})
|
||||
.catch((err) => {
|
||||
logger.error("Failed to check cloud sync support", err);
|
||||
});
|
||||
}, [objectId, shop, getGameBackupPreview]);
|
||||
|
||||
useEffect(() => {
|
||||
|
3
src/renderer/src/logger.ts
Normal file
3
src/renderer/src/logger.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import log from "electron-log/renderer";
|
||||
|
||||
export const logger = log.scope("renderer");
|
@ -195,7 +195,7 @@ export function CloudSyncModal({ visible, onClose }: CloudSyncModalProps) {
|
||||
}}
|
||||
>
|
||||
<h2>{t("backups")}</h2>
|
||||
<small>2 / 2</small>
|
||||
<small>{artifacts.length} / 2</small>
|
||||
</div>
|
||||
|
||||
<ul className={styles.artifacts}>
|
||||
|
Loading…
Reference in New Issue
Block a user