Skip to content

Commit e0c85c4

Browse files
committed
reduce output noise
1 parent fe0959f commit e0c85c4

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

adminforth/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,18 @@ class AdminForth implements IAdminForth {
112112
dbDiscover: 'running',
113113
};
114114

115-
console.log(`🚀 AdminForth v${ADMINFORTH_VERSION} starting up`)
115+
116+
117+
console.log(`${this.formatAdminForth()} v${ADMINFORTH_VERSION} starting up`)
118+
}
119+
120+
formatAdminForth() {
121+
const NO_FORMAT='\x1b[0m'
122+
const F_BOLD="\x1b[1m"
123+
const C_AQUA="\x1b[38;5;14m"
124+
const C_GREY70="\x1b[38;5;249m"
125+
const C_GREY15="\x1b[48;5;235m"
126+
return `${F_BOLD}${C_GREY70}${C_GREY15} 🚀 Admin${C_AQUA}Forth ${NO_FORMAT}`
116127
}
117128

118129
async tr(this, msg: string, category: string = 'default', lang: string = 'en', params: any): Promise<string> {

adminforth/modules/codeInjector.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ class CodeInjector implements ICodeInjector {
116116
};
117117

118118
console.log(`⚙️ exec: npm ${command}`);
119-
console.time(`npm ${command} done in`);
119+
process.env.HEAVY_DEBUG && console.time(`npm ${command} done in`);
120120
const { stdout: out, stderr: err } = await execAsync(`${nodeBinary} ${npmPath} ${command}`, {
121121
cwd,
122122
env,
123123
});
124-
console.timeEnd(`npm ${command} done in`);
124+
process.env.HEAVY_DEBUG && console.timeEnd(`npm ${command} done in`);
125125

126126
process.env.HEAVY_DEBUG && console.log(`🪲 npm ${command} output:`, out);
127127
if (err) {
@@ -727,7 +727,7 @@ class CodeInjector implements ICodeInjector {
727727
}
728728

729729
async bundleNow({ hotReload = false }: { hotReload: boolean }) {
730-
console.log(`AdminForth bundling ${hotReload ? ' and listening for changes (🔥 Hotreload)' : ' (no hot reload)'}`);
730+
console.log(`${this.adminforth.formatAdminForth()} Bundling ${hotReload ? 'and listening for changes (🔥 Hotreload)' : ' (no hot reload)'}`);
731731
this.adminforth.runningHotReload = hotReload;
732732

733733
await this.prepareSources();
@@ -797,12 +797,12 @@ class CodeInjector implements ICodeInjector {
797797
this.devServerPort = parseInt(portMatch[1]);
798798
}
799799
} else {
800-
console.log(`[AdminForth SPA]:`);
801-
process.stdout.write(data);
800+
process.env.HEAVY_DEBUG && console.log(`[AdminForth SPA]:`);
801+
process.env.HEAVY_DEBUG && process.stdout.write(data);
802802
}
803803
});
804804
devServer.stderr.on('data', (data) => {
805-
console.error(`[AdminForth SPA ERR]:`);
805+
console.error(`[AdminForth SPA ERROR]:`);
806806
process.stdout.write(data);
807807
});
808808

adminforth/servers/express.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class ExpressServer implements IExpressHttpServer {
170170

171171
this.server = http.createServer(this.expressApp);
172172
const wss = new WebSocketServer({ server: this.server, path: `${base}/afws` });
173-
console.log(' 🌐WebSocket server started');
173+
console.log(`${this.adminforth.formatAdminForth()} 🌐 WebSocket server started`);
174174
// Handle WebSocket connections
175175
wss.on('connection', async (ws, req) => {
176176
try {
@@ -334,7 +334,7 @@ class ExpressServer implements IExpressHttpServer {
334334
res.json(output);
335335
}
336336

337-
console.log(`Adding endpoint ${method} ${fullPath}`);
337+
process.env.HEAVY_DEBUG && console.log(`👂 Adding endpoint ${method} ${fullPath}`);
338338
this.expressApp[method.toLowerCase()](fullPath, noAuth ? expressHandler : this.authorize(expressHandler));
339339
}
340340

adminforth/spa/src/views/CreateView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ async function saveRecord() {
142142
record: record.value,
143143
},
144144
});
145-
if (response.error) {
145+
if (response?.error) {
146146
showErrorTost(response.error);
147147
}
148148
saving.value = false;

adminforth/types/Back.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ export interface IAdminForth {
302302
[key: string]: IAdminForthDataSourceConnectorBase;
303303
};
304304

305+
formatAdminForth(): string;
306+
305307
tr(msg: string, category: string, lang: string, params: any): Promise<string>;
306308

307309
createResourceRecord(

0 commit comments

Comments
 (0)