mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-01 18:22:41 -08:00
refactor(cli): remove deprecated verbose logging flags
This commit is contained in:
@@ -2,6 +2,9 @@ import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import * as readline from "readline";
|
||||
import { CliArgs } from "../../cli/args";
|
||||
import { createLogger } from "../../logger";
|
||||
|
||||
const logger = createLogger("core:config-gen");
|
||||
|
||||
function formatBackupTimestamp(date = new Date()): string {
|
||||
const pad = (v: number): string => String(v).padStart(2, "0");
|
||||
@@ -40,13 +43,13 @@ export async function generateDefaultConfigFile(
|
||||
const backupPath = `${targetPath}.bak.${formatBackupTimestamp()}`;
|
||||
fs.copyFileSync(targetPath, backupPath);
|
||||
fs.writeFileSync(targetPath, template, "utf-8");
|
||||
console.log(`Backed up existing config to ${backupPath}`);
|
||||
console.log(`Generated config at ${targetPath}`);
|
||||
logger.info(`Backed up existing config to ${backupPath}`);
|
||||
logger.info(`Generated config at ${targetPath}`);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
||||
console.error(
|
||||
logger.error(
|
||||
`Config exists at ${targetPath}. Re-run with --backup-overwrite to back up and overwrite.`,
|
||||
);
|
||||
return 1;
|
||||
@@ -56,15 +59,15 @@ export async function generateDefaultConfigFile(
|
||||
`Config exists at ${targetPath}. Back up and overwrite? [y/N] `,
|
||||
);
|
||||
if (!confirmed) {
|
||||
console.log("Config generation cancelled.");
|
||||
logger.info("Config generation cancelled.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
const backupPath = `${targetPath}.bak.${formatBackupTimestamp()}`;
|
||||
fs.copyFileSync(targetPath, backupPath);
|
||||
fs.writeFileSync(targetPath, template, "utf-8");
|
||||
console.log(`Backed up existing config to ${backupPath}`);
|
||||
console.log(`Generated config at ${targetPath}`);
|
||||
logger.info(`Backed up existing config to ${backupPath}`);
|
||||
logger.info(`Generated config at ${targetPath}`);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -73,6 +76,6 @@ export async function generateDefaultConfigFile(
|
||||
fs.mkdirSync(parentDir, { recursive: true });
|
||||
}
|
||||
fs.writeFileSync(targetPath, template, "utf-8");
|
||||
console.log(`Generated config at ${targetPath}`);
|
||||
logger.info(`Generated config at ${targetPath}`);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { CliArgs, shouldStartApp } from "../../cli/args";
|
||||
import { createLogger } from "../../logger";
|
||||
|
||||
const logger = createLogger("core:electron-backend");
|
||||
|
||||
function getElectronOzonePlatformHint(): string | null {
|
||||
const hint = process.env.ELECTRON_OZONE_PLATFORM_HINT?.trim().toLowerCase();
|
||||
@@ -34,6 +37,6 @@ export function enforceUnsupportedWaylandMode(args: CliArgs): void {
|
||||
|
||||
const message =
|
||||
"Unsupported Electron backend: Wayland. Set ELECTRON_OZONE_PLATFORM_HINT=x11 and restart SubMiner.";
|
||||
console.error(message);
|
||||
logger.error(message);
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { Notification, nativeImage } from "electron";
|
||||
import * as fs from "fs";
|
||||
import { createLogger } from "../../logger";
|
||||
|
||||
const logger = createLogger("core:notification");
|
||||
|
||||
export function showDesktopNotification(
|
||||
title: string,
|
||||
@@ -24,7 +27,7 @@ export function showDesktopNotification(
|
||||
if (fs.existsSync(options.icon)) {
|
||||
notificationOptions.icon = options.icon;
|
||||
} else {
|
||||
console.warn("Notification icon file not found:", options.icon);
|
||||
logger.warn("Notification icon file not found", options.icon);
|
||||
}
|
||||
} else if (
|
||||
typeof options.icon === "string" &&
|
||||
@@ -36,14 +39,14 @@ export function showDesktopNotification(
|
||||
Buffer.from(base64Data, "base64"),
|
||||
);
|
||||
if (image.isEmpty()) {
|
||||
console.warn(
|
||||
logger.warn(
|
||||
"Notification icon created from base64 is empty - image format may not be supported by Electron",
|
||||
);
|
||||
} else {
|
||||
notificationOptions.icon = image;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to create notification icon from base64:", err);
|
||||
logger.error("Failed to create notification icon from base64", err);
|
||||
}
|
||||
} else {
|
||||
notificationOptions.icon = options.icon;
|
||||
|
||||
Reference in New Issue
Block a user