1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-05 10:22:31 +01:00

Less spammy user connection logs

This commit is contained in:
Madeline 2023-04-02 11:26:24 +10:00
parent d90fd6b4e5
commit 2e27281e23
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
2 changed files with 13 additions and 11 deletions

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { ConnectionConfigEntity } from "../entities/ConnectionConfigEntity";
let config: any;
@ -6,7 +7,7 @@ let pairs: ConnectionConfigEntity[];
export const ConnectionConfig = {
init: async function init() {
if (config) return config;
console.log("[ConnectionConfig] Loading configuration...");
console.log("[Connections] Loading configuration...");
pairs = await ConnectionConfigEntity.find();
config = pairsToConfig(pairs);
@ -44,7 +45,7 @@ function applyConfig(val: any) {
if (pair.value !== obj) {
pair.value = obj;
if (!pair.key || pair.key == null) {
console.log(`[ConnectionConfig] WARN: Empty key`);
console.log(`[Connections] WARN: Empty config key`);
console.log(pair);
} else return pair.save();
}

View File

@ -1,6 +1,5 @@
import fs from "fs";
import path from "path";
import { OrmUtils } from "../imports";
import Connection from "./Connection";
import { ConnectionConfig } from "./ConnectionConfig";
import { ConnectionStore } from "./ConnectionStore";
@ -27,10 +26,11 @@ export class ConnectionLoader {
ConnectionStore.connections.set(mod.id, mod);
mod.init();
console.log(`[Connections] Loaded connection '${mod.id}'`);
// console.log(`[Connections] Loaded connection '${mod.id}'`);
});
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public static getConnectionConfig(id: string, defaults?: any): any {
let cfg = ConnectionConfig.get()[id];
if (defaults) {
@ -41,21 +41,22 @@ export class ConnectionLoader {
}
}
if (!cfg)
console.log(
`[ConnectionConfig/WARN] Getting connection settings for '${id}' returned null! (Did you forget to add settings?)`,
);
if (cfg?.enabled) console.log(`[Connections] ${id} enabled`);
// if (!cfg)
// console.log(
// `[ConnectionConfig/WARN] Getting connection settings for '${id}' returned null! (Did you forget to add settings?)`,
// );
return cfg;
}
public static async setConnectionConfig(
id: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
config: Partial<any>,
): Promise<void> {
if (!config)
console.log(
`[ConnectionConfig/WARN] ${id} tried to set config=null!`,
);
console.warn(`[Connections/WARN] ${id} tried to set config=null!`);
await ConnectionConfig.set({
[id]: Object.assign(