1
0
mirror of https://github.com/upscayl/upscayl.git synced 2025-01-18 17:14:08 +01:00

Added log for console

This commit is contained in:
Nayam Amarshe 2023-03-31 16:03:48 +05:30
parent 411ba135b6
commit 373870621e
6 changed files with 50 additions and 14 deletions

View File

@ -11,6 +11,7 @@ import { autoUpdater } from "electron-updater";
import getPlatform from "./getPlatform";
import ffmpeg from "upscayl-ffmpeg";
import { join, parse } from "path";
import log from "electron-log";
import { format } from "url";
import fs from "fs";
@ -31,15 +32,17 @@ import prepareNext from "electron-next";
import isDev from "electron-is-dev";
import commands from "./commands";
log.initialize({ preload: true });
// Prepare the renderer once the app is ready
let mainWindow;
app.on("ready", async () => {
await prepareNext("./renderer");
console.log("🚀 ICON PATH: ", join(__dirname, "build", "icon.png"));
console.log("🚀 UPSCAYL EXEC PATH: ", execPath(""));
console.log("🚀 MODELS PATH: ", modelsPath);
console.log("🚀 FFMPEG PATH: ", ffmpeg.path);
log.info("🚀 ICON PATH: ", join(__dirname, "build", "icon.png"));
log.info("🚀 UPSCAYL EXEC PATH: ", execPath(""));
log.info("🚀 MODELS PATH: ", modelsPath);
log.info("🚀 FFMPEG PATH: ", ffmpeg.path);
mainWindow = new BrowserWindow({
icon: join(__dirname, "build", "icon.png"),
@ -84,7 +87,8 @@ app.on("ready", async () => {
// Quit the app once all windows are closed
app.on("window-all-closed", app.quit);
console.log(app.getAppPath());
log.log(app.getAppPath());
//------------------------Select File-----------------------------//
// ! DONT FORGET TO RESTART THE APP WHEN YOU CHANGE CODE HERE
ipcMain.handle(commands.SELECT_FILE, async () => {
@ -93,10 +97,10 @@ ipcMain.handle(commands.SELECT_FILE, async () => {
});
if (canceled) {
console.log("operation cancelled");
console.log("File Operation Cancelled");
return "cancelled";
} else {
console.log(filePaths[0]);
console.log("Selected File Path: ", filePaths[0]);
// CREATE input AND upscaled FOLDER
return filePaths[0];
}

View File

@ -18,6 +18,7 @@ const electron_updater_1 = require("electron-updater");
const getPlatform_1 = __importDefault(require("./getPlatform"));
const upscayl_ffmpeg_1 = __importDefault(require("upscayl-ffmpeg"));
const path_1 = require("path");
const electron_log_1 = __importDefault(require("electron-log"));
const url_1 = require("url");
const fs_1 = __importDefault(require("fs"));
const binaries_1 = require("./binaries");
@ -27,14 +28,15 @@ const upscayl_1 = require("./upscayl");
const electron_next_1 = __importDefault(require("electron-next"));
const electron_is_dev_1 = __importDefault(require("electron-is-dev"));
const commands_1 = __importDefault(require("./commands"));
electron_log_1.default.initialize({ preload: true });
// Prepare the renderer once the app is ready
let mainWindow;
electron_1.app.on("ready", () => __awaiter(void 0, void 0, void 0, function* () {
yield (0, electron_next_1.default)("./renderer");
console.log("🚀 ICON PATH: ", (0, path_1.join)(__dirname, "build", "icon.png"));
console.log("🚀 UPSCAYL EXEC PATH: ", (0, binaries_1.execPath)(""));
console.log("🚀 MODELS PATH: ", binaries_1.modelsPath);
console.log("🚀 FFMPEG PATH: ", upscayl_ffmpeg_1.default.path);
electron_log_1.default.info("🚀 ICON PATH: ", (0, path_1.join)(__dirname, "build", "icon.png"));
electron_log_1.default.info("🚀 UPSCAYL EXEC PATH: ", (0, binaries_1.execPath)(""));
electron_log_1.default.info("🚀 MODELS PATH: ", binaries_1.modelsPath);
electron_log_1.default.info("🚀 FFMPEG PATH: ", upscayl_ffmpeg_1.default.path);
mainWindow = new electron_1.BrowserWindow({
icon: (0, path_1.join)(__dirname, "build", "icon.png"),
width: 1300,
@ -72,7 +74,7 @@ electron_1.app.on("ready", () => __awaiter(void 0, void 0, void 0, function* ()
}));
// Quit the app once all windows are closed
electron_1.app.on("window-all-closed", electron_1.app.quit);
console.log(electron_1.app.getAppPath());
electron_log_1.default.log(electron_1.app.getAppPath());
//------------------------Select File-----------------------------//
// ! DONT FORGET TO RESTART THE APP WHEN YOU CHANGE CODE HERE
electron_1.ipcMain.handle(commands_1.default.SELECT_FILE, () => __awaiter(void 0, void 0, void 0, function* () {
@ -80,11 +82,11 @@ electron_1.ipcMain.handle(commands_1.default.SELECT_FILE, () => __awaiter(void 0
properties: ["openFile", "multiSelections"],
});
if (canceled) {
console.log("operation cancelled");
console.log("File Operation Cancelled");
return "cancelled";
}
else {
console.log(filePaths[0]);
console.log("Selected File Path: ", filePaths[0]);
// CREATE input AND upscaled FOLDER
return filePaths[0];
}

15
package-lock.json generated
View File

@ -13,6 +13,7 @@
"daisyui": "^2.51.4",
"electron-is-dev": "^2.0.0",
"electron-is-packaged": "^1.0.2",
"electron-log": "^5.0.0-beta.16",
"electron-next": "^3.1.5",
"electron-root-path": "^1.1.0",
"electron-updater": "^5.3.0",
@ -3327,6 +3328,15 @@
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0"
}
},
"node_modules/electron-log": {
"version": "5.0.0-beta.16",
"resolved": "https://registry.npmjs.org/electron-log/-/electron-log-5.0.0-beta.16.tgz",
"integrity": "sha512-oBGFKjAsOXyzhvJIW0s+HIA7cV+kZ0B0FvO3hKyS8yPDGFsjQyr3M8N7ZyYxI6yEeihVID3CCfsTmpi6L9k0gw==",
"engines": {
"electron": ">= 13",
"node": ">= 14"
}
},
"node_modules/electron-next": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/electron-next/-/electron-next-3.1.5.tgz",
@ -10108,6 +10118,11 @@
"integrity": "sha512-JZpV9QgVsehop7tm3KDll2/iJ9K3e7mL+jm6E3gA96zurIhxv3FZ0kxJK0eGL9c3SYORU1rN+/q2Ia8/v62Pjw==",
"requires": {}
},
"electron-log": {
"version": "5.0.0-beta.16",
"resolved": "https://registry.npmjs.org/electron-log/-/electron-log-5.0.0-beta.16.tgz",
"integrity": "sha512-oBGFKjAsOXyzhvJIW0s+HIA7cV+kZ0B0FvO3hKyS8yPDGFsjQyr3M8N7ZyYxI6yEeihVID3CCfsTmpi6L9k0gw=="
},
"electron-next": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/electron-next/-/electron-next-3.1.5.tgz",

View File

@ -159,6 +159,7 @@
"daisyui": "^2.51.4",
"electron-is-dev": "^2.0.0",
"electron-is-packaged": "^1.0.2",
"electron-log": "^5.0.0-beta.16",
"electron-next": "^3.1.5",
"electron-root-path": "^1.1.0",
"electron-updater": "^5.3.0",

View File

@ -3,6 +3,7 @@ import Head from "next/head";
import { AppProps } from "next/app";
import { useEffect } from "react";
import { themeChange } from "theme-change";
import log from "electron-log/renderer";
const MyApp = ({ Component, pageProps }: AppProps) => {
return (

View File

@ -11,6 +11,8 @@ import LeftPaneImageSteps from "../components/LeftPaneImageSteps";
import Tabs from "../components/Tabs";
import SettingsTab from "../components/SettingsTab";
let logData = [];
const Home = () => {
// STATES
const [imagePath, SetImagePath] = useState("");
@ -38,6 +40,17 @@ const Home = () => {
height: null,
});
const [selectedTab, setSelectedTab] = useState(0);
const [logData, setLogData] = useState([]);
(function () {
let info = console.info;
console.log = function () {
var args = Array.prototype.slice.call(arguments);
info.apply(this, args);
setLogData([...logData, { level: "info", arguments: args }]);
};
})();
// EFFECTS
useEffect(() => {