Add a config flag to reduce logging noise

This commit is contained in:
Travis Ralston 2019-10-31 09:55:34 -06:00
parent 84682db9b0
commit 0575c56b74
3 changed files with 9 additions and 2 deletions

View File

@ -33,6 +33,10 @@ managementRoom: "#moderators:example.org"
# Set to false to make the management room a bit quieter. # Set to false to make the management room a bit quieter.
verboseLogging: true 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 # Set to false to disable synchronizing the ban lists on startup. If true, this
# is the same as running !mjolnir sync immediately after startup. # is the same as running !mjolnir sync immediately after startup.
syncOnStartup: true syncOnStartup: true

View File

@ -28,6 +28,7 @@ interface IConfig {
autojoin: boolean; autojoin: boolean;
managementRoom: string; managementRoom: string;
verboseLogging: boolean; verboseLogging: boolean;
logLevel: "DEBUG" | "INFO" | "WARN" | "ERROR";
syncOnStartup: boolean; syncOnStartup: boolean;
verifyPermissionsOnStartup: boolean; verifyPermissionsOnStartup: boolean;
noop: boolean; noop: boolean;

View File

@ -17,6 +17,7 @@ limitations under the License.
import * as path from "path"; import * as path from "path";
import { import {
AutojoinRoomsMixin, AutojoinRoomsMixin,
LogLevel,
LogService, LogService,
MatrixClient, MatrixClient,
PantalaimonClient, PantalaimonClient,
@ -29,6 +30,9 @@ import BanList from "./models/BanList";
import { Mjolnir } from "./Mjolnir"; import { Mjolnir } from "./Mjolnir";
LogService.setLogger(new RichConsoleLogger()); LogService.setLogger(new RichConsoleLogger());
LogService.setLevel(LogLevel.fromString(config.logLevel, LogLevel.DEBUG));
LogService.info("index", "Starting bot...");
(async function () { (async function () {
const storage = new SimpleFsStorageProvider(path.join(config.dataPath, "bot.json")); 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); const bot = new Mjolnir(client, managementRoomId, protectedRooms, banLists);
await bot.start(); await bot.start();
LogService.info("index", "Bot started!")
})(); })();