From 0575c56b740abeec357d583ecb59e0d0c8ea2f00 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 31 Oct 2019 09:55:34 -0600 Subject: [PATCH] Add a config flag to reduce logging noise --- config/default.yaml | 4 ++++ src/config.ts | 1 + src/index.ts | 6 ++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/config/default.yaml b/config/default.yaml index d17d2ce..81fefef 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -33,6 +33,10 @@ managementRoom: "#moderators:example.org" # Set to false to make the management room a bit quieter. verboseLogging: true +# The log level for the logs themselves. One of DEBUG, INFO, WARN, and ERROR. +# This should be at INFO or DEBUG in order to get support for Mjolnir problems. +logLevel: "INFO" + # Set to false to disable synchronizing the ban lists on startup. If true, this # is the same as running !mjolnir sync immediately after startup. syncOnStartup: true diff --git a/src/config.ts b/src/config.ts index 94f7061..32ce24b 100644 --- a/src/config.ts +++ b/src/config.ts @@ -28,6 +28,7 @@ interface IConfig { autojoin: boolean; managementRoom: string; verboseLogging: boolean; + logLevel: "DEBUG" | "INFO" | "WARN" | "ERROR"; syncOnStartup: boolean; verifyPermissionsOnStartup: boolean; noop: boolean; diff --git a/src/index.ts b/src/index.ts index 08bf6d3..6ff9685 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,6 +17,7 @@ limitations under the License. import * as path from "path"; import { AutojoinRoomsMixin, + LogLevel, LogService, MatrixClient, PantalaimonClient, @@ -29,6 +30,9 @@ import BanList from "./models/BanList"; import { Mjolnir } from "./Mjolnir"; LogService.setLogger(new RichConsoleLogger()); +LogService.setLevel(LogLevel.fromString(config.logLevel, LogLevel.DEBUG)); + +LogService.info("index", "Starting bot..."); (async function () { const storage = new SimpleFsStorageProvider(path.join(config.dataPath, "bot.json")); @@ -69,6 +73,4 @@ LogService.setLogger(new RichConsoleLogger()); const bot = new Mjolnir(client, managementRoomId, protectedRooms, banLists); await bot.start(); - - LogService.info("index", "Bot started!") })();