|
78 | 78 |
|
79 | 79 | // Store extension state
|
80 | 80 | var clVars = {
|
81 |
| - |
| 81 | + // variable for preventing any spammy messages (TX and RX) that CL logs, potentially increasing performance. Noticed by TheShovel and mentioned it in the discord server, so I'm just adding it here |
| 82 | + logToConsole: true, |
| 83 | + |
82 | 84 | // WebSocket object.
|
83 | 85 | socket: null,
|
84 | 86 |
|
|
384 | 386 | }
|
385 | 387 |
|
386 | 388 | // Send the message
|
387 |
| - console.log("[CloudLink] TX:", message); |
| 389 | + if (clVars.logToConsole) { |
| 390 | + console.log("[CloudLink] TX:", message); |
| 391 | + } |
388 | 392 | clVars.socket.send(outgoing);
|
389 | 393 | }
|
390 | 394 |
|
|
482 | 486 | console.error("[CloudLink] Incoming message read failure! This message doesn't contain the required \"cmd\" key. Is this really a CloudLink server?", packet);
|
483 | 487 | return;
|
484 | 488 | }
|
485 |
| - console.log("[CloudLink] RX:", packet); |
| 489 | + if (clVars.logToConsole) { |
| 490 | + console.log("[CloudLink] RX:", packet); |
| 491 | + } |
486 | 492 | switch (packet.cmd) {
|
487 | 493 | case "gmsg":
|
488 | 494 | clVars.gmsg.varState = packet.val;
|
|
1484 | 1490 | },
|
1485 | 1491 |
|
1486 | 1492 | "---",
|
| 1493 | + |
| 1494 | + { |
| 1495 | + opcode: "changeLogToConsole", |
| 1496 | + blockType: BlockType.COMMAND, |
| 1497 | + text: "[BOOL] logging to console", |
| 1498 | + arguments: { |
| 1499 | + BOOL: { |
| 1500 | + type: ArgumentType.STRING, |
| 1501 | + menu: "boolmenu", |
| 1502 | + defaultValue: "Enable", |
| 1503 | + }, |
| 1504 | + } |
| 1505 | + }, |
| 1506 | + |
| 1507 | + "---", |
1487 | 1508 |
|
1488 | 1509 | ],
|
1489 | 1510 | menus: {
|
|
1499 | 1520 | almostallmenu: {
|
1500 | 1521 | items: ['Global data', 'Private data', 'Direct data', 'Status code', "Global variables", "Private variables"]
|
1501 | 1522 | },
|
| 1523 | + boolmenu: { |
| 1524 | + items: ['Enable', 'Disable'] |
| 1525 | + } |
1502 | 1526 | }
|
1503 | 1527 | };
|
1504 | 1528 | }
|
|
2319 | 2343 | break;
|
2320 | 2344 | }
|
2321 | 2345 | }
|
| 2346 | + |
| 2347 | + changeLogToConsole(args) { |
| 2348 | + clVars.logToConsole = args.BOOL == 'Enable'; |
| 2349 | + } |
2322 | 2350 | }
|
2323 | 2351 | console.log("[CloudLink] Extension loaded!");
|
2324 | 2352 | module.exports = CloudLink;
|
|
0 commit comments