How to use the matrix-bot-sdk.LogService function in matrix-bot-sdk

To help you get started, we’ve selected a few matrix-bot-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github turt2live / matrix-dimension / src / index.ts View on Github external
import { LogService } from "matrix-js-snippets";
import config from "./config";
import { DimensionStore } from "./db/DimensionStore";
import Webserver from "./api/Webserver";
import { CURRENT_VERSION } from "./version";
import { MatrixStickerBot } from "./matrix/MatrixStickerBot";
import * as BotSdk from "matrix-bot-sdk";
import User from "./db/models/User";

LogService.configure(config.logging);
LogService.info("index", "Starting dimension " + CURRENT_VERSION);

// Redirect the bot-sdk logger to our logger
BotSdk.LogService.setLogger({
    debug: (module: string, ...args: any[]) => args.map(a => LogService.info("BotSdk-" + module, a)),
    info: (module: string, ...args: any[]) => args.map(a => LogService.info("BotSdk-" + module, a)),
    warn: (module: string, ...args: any[]) => args.map(a => LogService.warn("BotSdk-" + module, a)),
    error: (module: string, ...args: any[]) => args.map(a => LogService.error("BotSdk-" + module, a)),
});

async function startup() {
    await DimensionStore.updateSchema();

    const webserver = new Webserver();
    await webserver.start();

    const userId = await MatrixStickerBot.getUserId();
    const users = await User.findAll({where: {userId: userId, isSelfBot: false}});
    if (users.length > 0) {
        LogService.error("index", "The access token configured for Dimension belongs to a user which is also " +