mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 21:06:04 +00:00
added timestamps to app console logs
This commit is contained in:
@@ -14,7 +14,7 @@ import * as SystemPermissions from "modules/permissions";
|
|||||||
import { AdminController, type AdminControllerOptions } from "modules/server/AdminController";
|
import { AdminController, type AdminControllerOptions } from "modules/server/AdminController";
|
||||||
import { SystemController } from "modules/server/SystemController";
|
import { SystemController } from "modules/server/SystemController";
|
||||||
|
|
||||||
// biome-ignore
|
// biome-ignore format: must be there
|
||||||
import { Api, type ApiOptions } from "Api";
|
import { Api, type ApiOptions } from "Api";
|
||||||
|
|
||||||
export type AppPlugin = (app: App) => Promise<void> | void;
|
export type AppPlugin = (app: App) => Promise<void> | void;
|
||||||
@@ -122,6 +122,8 @@ export class App {
|
|||||||
this.trigger_first_boot = false;
|
this.trigger_first_boot = false;
|
||||||
await this.emgr.emit(new AppFirstBoot({ app: this }));
|
await this.emgr.emit(new AppFirstBoot({ app: this }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$console.log("App built");
|
||||||
}
|
}
|
||||||
|
|
||||||
mutateConfig<Module extends keyof Modules>(module: Module) {
|
mutateConfig<Module extends keyof Modules>(module: Module) {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { datetimeStringLocal } from "core/utils";
|
||||||
import colors from "picocolors";
|
import colors from "picocolors";
|
||||||
|
|
||||||
function hasColors() {
|
function hasColors() {
|
||||||
@@ -8,10 +9,10 @@ function hasColors() {
|
|||||||
env = p.env || {};
|
env = p.env || {};
|
||||||
return (
|
return (
|
||||||
!(!!env.NO_COLOR || argv.includes("--no-color")) &&
|
!(!!env.NO_COLOR || argv.includes("--no-color")) &&
|
||||||
// biome-ignore lint/complexity/useOptionalChain: <explanation>
|
|
||||||
(!!env.FORCE_COLOR ||
|
(!!env.FORCE_COLOR ||
|
||||||
argv.includes("--color") ||
|
argv.includes("--color") ||
|
||||||
p.platform === "win32" ||
|
p.platform === "win32" ||
|
||||||
|
// biome-ignore lint/complexity/useOptionalChain: <explanation>
|
||||||
((p.stdout || {}).isTTY && env.TERM !== "dumb") ||
|
((p.stdout || {}).isTTY && env.TERM !== "dumb") ||
|
||||||
!!env.CI)
|
!!env.CI)
|
||||||
);
|
);
|
||||||
@@ -43,19 +44,17 @@ function __tty(type: any, args: any[]) {
|
|||||||
prefix: colors.cyan
|
prefix: colors.cyan
|
||||||
},
|
},
|
||||||
log: {
|
log: {
|
||||||
prefix: colors.gray
|
prefix: colors.dim
|
||||||
},
|
},
|
||||||
debug: {
|
debug: {
|
||||||
prefix: colors.yellow
|
prefix: colors.yellow
|
||||||
}
|
}
|
||||||
} as const;
|
} as const;
|
||||||
const prefix = styles[type].prefix(
|
const prefix = styles[type].prefix(`[${type.toUpperCase()}]`);
|
||||||
`[${type.toUpperCase()}]${has ? " ".repeat(5 - type.length) : ""}`
|
|
||||||
);
|
|
||||||
const _args = args.map((a) =>
|
const _args = args.map((a) =>
|
||||||
"args" in styles[type] && has && typeof a === "string" ? styles[type].args(a) : a
|
"args" in styles[type] && has && typeof a === "string" ? styles[type].args(a) : a
|
||||||
);
|
);
|
||||||
return originalConsoles[type](prefix, ..._args);
|
return originalConsoles[type](prefix, colors.gray(datetimeStringLocal()), ..._args);
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TConsoleSeverity = keyof typeof originalConsoles;
|
export type TConsoleSeverity = keyof typeof originalConsoles;
|
||||||
|
|||||||
Reference in New Issue
Block a user