mirror of
https://git.bits.team/Bits/mod-manager.git
synced 2025-06-30 17:19:43 -04:00
Added logging
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
||||
import {existsSync, mkdirSync, writeFileSync} from "fs";
|
||||
import path from "path";
|
||||
import Mods from "../mods/mods.js";
|
||||
import PrintUtils from "./print_utils.js";
|
||||
import ModManager from "../mod-manager.js";
|
||||
|
||||
export default class Initialiser {
|
||||
private static readonly MOD_MANAGER_FOLDER = ".mod-manager"
|
||||
@ -13,6 +14,12 @@ export default class Initialiser {
|
||||
|
||||
if (success) {
|
||||
PrintUtils.success("Sucessfully initialised Mod Manager!");
|
||||
|
||||
// Initialise a logger when Mod Manager is initialised
|
||||
if (ModManager.logger == null) {
|
||||
ModManager.logger = ModManager.createLogger();
|
||||
}
|
||||
|
||||
} else {
|
||||
PrintUtils.error("Unable to set up the Mod Manager folder structure");
|
||||
}
|
||||
@ -39,6 +46,7 @@ export default class Initialiser {
|
||||
if (!existsSync(this.getModManagerFolderPath())) {
|
||||
mkdirSync(this.getModManagerFolderPath());
|
||||
writeFileSync(Mods.getModFilePath(), "[]");
|
||||
mkdirSync(path.join(this.getModManagerFolderPath(), "logs"))
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -1,21 +1,38 @@
|
||||
import chalk from "chalk";
|
||||
import ora, { Ora } from "ora";
|
||||
import ModManager from "../mod-manager.js";
|
||||
|
||||
export default class PrintUtils {
|
||||
|
||||
static info(print: string) {
|
||||
if (ModManager.logger != null) {
|
||||
ModManager.logger.info(print);
|
||||
}
|
||||
|
||||
console.log(chalk.white(print));
|
||||
}
|
||||
|
||||
static warn(print: string) {
|
||||
if (ModManager.logger != null) {
|
||||
ModManager.logger.warn(print)
|
||||
}
|
||||
|
||||
console.log(chalk.yellowBright(print));
|
||||
}
|
||||
|
||||
static success(print: string) {
|
||||
if (ModManager.logger != null) {
|
||||
ModManager.logger.info(print)
|
||||
}
|
||||
|
||||
console.log(chalk.greenBright(print));
|
||||
}
|
||||
|
||||
static error(print: string) {
|
||||
if (ModManager.logger != null) {
|
||||
ModManager.logger.error(print);
|
||||
}
|
||||
|
||||
console.log(chalk.redBright(print));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user