diff --git a/src/Mjolnir.ts b/src/Mjolnir.ts index 844dbde..d855dbc 100644 --- a/src/Mjolnir.ts +++ b/src/Mjolnir.ts @@ -293,6 +293,7 @@ export class Mjolnir { * Stop Mjolnir from syncing and processing commands. */ public stop() { + LogService.info("Mjolnir", "Stopping Mjolnir..."); this.client.stop(); } diff --git a/test/integration/clientHelper.ts b/test/integration/clientHelper.ts index 1a1d116..ec43932 100644 --- a/test/integration/clientHelper.ts +++ b/test/integration/clientHelper.ts @@ -1,6 +1,6 @@ import axios from "axios"; import { HmacSHA1 } from "crypto-js"; -import { MatrixClient, MemoryStorageProvider, PantalaimonClient } from "matrix-bot-sdk"; +import { LogService, MatrixClient, MemoryStorageProvider, PantalaimonClient } from "matrix-bot-sdk"; import config from "../../src/config"; /** @@ -40,8 +40,7 @@ export async function registerNewTestUser(isAdmin: boolean) { username = `mjolnir-test-user-${Math.floor(Math.random() * 100000)}` await registerUser(username, username, username, isAdmin).then(_ => isUserValid = true).catch(e => { if (e.isAxiosError && e?.response?.data?.errcode === 'M_USER_IN_USE') { - // FIXME: Replace with the real logging service. - console.log(`${username} already registered, trying another`); + LogService.debug("test/clientHelper", `${username} already registered, trying another`); false // continue and try again } else { console.error(`failed to register user ${e}`); diff --git a/test/integration/fixtures.ts b/test/integration/fixtures.ts index 5a85ebf..25ff98c 100644 --- a/test/integration/fixtures.ts +++ b/test/integration/fixtures.ts @@ -16,7 +16,6 @@ export const mochaHooks = { ], afterEach: [ async function() { - console.log("stopping mjolnir"); await this.mjolnir.stop(); // Mjolnir resolves config.managementRoom and overwrites it, so we undo this here // after stopping Mjolnir for the next time we setup a Mjolnir and a management room. diff --git a/test/integration/helloTest.ts b/test/integration/helloTest.ts index 9fa6d31..24455e8 100644 --- a/test/integration/helloTest.ts +++ b/test/integration/helloTest.ts @@ -1,5 +1,3 @@ -import { doesNotMatch } from "assert"; -import { assert } from "console"; import config from "../../src/config"; import { newTestUser, noticeListener } from "./clientHelper" @@ -17,7 +15,6 @@ describe("help command", () => { // listener for getting the event reply let reply = new Promise((resolve, reject) => { client.on('room.message', noticeListener(config.managementRoom, (event) => { - console.log(event.event_id) if (event.content.body.includes("Print status information")) { resolve(event); } diff --git a/test/integration/mjolnirSetupUtils.ts b/test/integration/mjolnirSetupUtils.ts index c297d18..b6b43a7 100644 --- a/test/integration/mjolnirSetupUtils.ts +++ b/test/integration/mjolnirSetupUtils.ts @@ -16,7 +16,10 @@ limitations under the License. import { MatrixClient, PantalaimonClient, - MemoryStorageProvider + MemoryStorageProvider, + LogService, + LogLevel, + RichConsoleLogger } from "matrix-bot-sdk"; import { Mjolnir} from '../../src/Mjolnir'; import config from "../../src/config"; @@ -57,7 +60,9 @@ async function configureMjolnir() { export async function makeMjolnir() { await configureMjolnir(); - console.info('starting mjolnir'); + LogService.setLogger(new RichConsoleLogger()); + LogService.setLevel(LogLevel.fromString(config.logLevel, LogLevel.DEBUG)); + LogService.info("test/mjolnirSetupUtils", "Starting bot..."); const pantalaimon = new PantalaimonClient(config.homeserverUrl, new MemoryStorageProvider()); const client = await pantalaimon.createClientWithCredentials(config.pantalaimon.username, config.pantalaimon.password); await ensureAliasedRoomExists(client, config.managementRoom);