/[sudobot]/branches/2.x/src/utils/debug.ts
ViewVC logotype

Contents of /branches/2.x/src/utils/debug.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (show annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 1766 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 import BaseCommand from "./structures/BaseCommand";
2 import BaseEvent from "./structures/BaseEvent";
3 import { fill, green, red, timeProcess, yellow } from "./util";
4
5 let colLengths = [19, 33, 10];
6 let totalLength = colLengths.reduce((acc, val) => acc + val);
7
8 export async function registrationStart() {
9 if (process.env.ENV === 'prod' || !process.argv.includes('--verbose'))
10 return;
11
12 console.log(`+-----------------------------------------------------+`);
13 console.log(`|Name |Time |Status |`);
14 }
15
16 export async function registered(command: BaseCommand | BaseEvent, startTime: number = 0, endTime: number = 0) {
17 if (process.env.ENV === 'prod' || !process.argv.includes('--verbose'))
18 return;
19
20 console.log(`|-------------------+----------------------+----------|`);
21
22 let name = command.getName();
23 let time: number = endTime - startTime;
24 let timeString = time + 'ms';
25
26 if (time >= 100) {
27 timeString = red(timeString);
28 }
29 else if (time >= 50) {
30 timeString = yellow(timeString);
31 }
32 else {
33 timeString = green(timeString);
34 }
35
36 let status = 'Success';
37
38 if (colLengths[0] > name.length) {
39 name = fill(colLengths[0], name);
40 }
41
42 if (colLengths[1] > timeString.length) {
43 timeString = fill(colLengths[1], timeString);
44 }
45
46 if (colLengths[2] > status.length) {
47 status = fill(colLengths[2], status);
48 }
49
50 console.log(`|${green(name)}|${timeString}|${green(status)}|`);
51 }
52
53 export async function registrationEnd() {
54 if (process.env.ENV === 'prod' || !process.argv.includes('--verbose'))
55 return;
56
57 console.log(`+-----------------------------------------------------+`);
58 console.log(`\n`);
59 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26