/[sudobot]/trunk/src/utils/debug.ts
ViewVC logotype

Annotation of /trunk/src/utils/debug.ts

Parent Directory Parent Directory | Revision Log Revision Log


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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26