Skip to content

Commit

Permalink
remove verboseLogging.
Browse files Browse the repository at this point in the history
yeah, cya later pal. #504.
  • Loading branch information
Gnuxie committed Feb 6, 2025
1 parent f92a0ed commit 1761f57
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
3 changes: 0 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export interface IConfig {
acceptInvitesFromSpace: string | undefined;
recordIgnoredInvites: boolean;
managementRoom: string;
verboseLogging: boolean;
logLevel: "DEBUG" | "INFO" | "WARN" | "ERROR";
logMutedModules: string[];
verifyPermissionsOnStartup: boolean;
Expand Down Expand Up @@ -187,7 +186,6 @@ const defaultConfig: IConfig = {
autojoinOnlyIfManager: true,
recordIgnoredInvites: false,
managementRoom: "!noop:example.org",
verboseLogging: false,
logLevel: "INFO",
logMutedModules: ["MatrixHttpClient", "MatrixClientLite"],
verifyPermissionsOnStartup: true,
Expand Down Expand Up @@ -371,7 +369,6 @@ export function getProvisionedMjolnirConfig(managementRoomId: string): IConfig {
// on every created Draupnir, which would result in very confusing error messages.
const allowedKeys = [
"commands",
"verboseLogging",
"logLevel",
"verifyPermissionsOnStartup",
"automaticallyRedactForReasons",
Expand Down
5 changes: 3 additions & 2 deletions src/managementroom/ManagementRoomOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface ManagementRoomOutput {
managementRoomID: StringRoomID;
/**
* Log a message to the management room and the console, replaces any room ids in additionalRoomIds with pills.
* @param level Used to determine whether to hide the message or not depending on `config.verboseLogging`.
* @param level Used to determine whether to hide the message or not depending on `config.logLevel`.
* @param module Used to help find where in the source the message is coming from (when logging to the console).
* @param message The message we want to log.
* @param additionalRoomIds The roomIds in the message that we want to be replaced by room pills.
Expand Down Expand Up @@ -173,7 +173,8 @@ export default class StandardManagementRoomOutput
if (!Array.isArray(additionalRoomIds))
additionalRoomIds = [additionalRoomIds];

if (this.config.verboseLogging || LogLevel.INFO.includes(level)) {
const levelsIncluded = LogLevel[this.config.logLevel];
if (levelsIncluded.includes(level)) {
let clientMessage = message;
if (level === LogLevel.WARN) clientMessage = `⚠ | ${message}`;
if (level === LogLevel.ERROR) clientMessage = `‼ | ${message}`;
Expand Down
16 changes: 6 additions & 10 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ import {
} from "matrix-bot-sdk";
import { ClientRequest, IncomingMessage } from "http";
import * as Sentry from "@sentry/node";

import ManagementRoomOutput from "./managementroom/ManagementRoomOutput";
import { IConfig } from "./config";
import { Gauge } from "prom-client";
import { MatrixSendClient } from "matrix-protection-suite-for-matrix-bot-sdk";
import { RoomEvent } from "matrix-protection-suite";
import { Logger, RoomEvent } from "matrix-protection-suite";

const log = new Logger("utils");

export function htmlEscape(input: string): string {
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
Expand Down Expand Up @@ -103,9 +104,7 @@ export async function redactUserMessagesIn(
noop = false
) {
for (const targetRoomId of targetRoomIds) {
await managementRoom.logMessage(
LogLevel.DEBUG,
"utils#redactUserMessagesIn",
log.debug(
`Fetching sent messages for ${userIdOrGlob} in ${targetRoomId} to redact...`,
targetRoomId
);
Expand All @@ -118,18 +117,15 @@ export async function redactUserMessagesIn(
limit,
async (eventsToRedact) => {
for (const victimEvent of eventsToRedact) {
await managementRoom.logMessage(
LogLevel.DEBUG,
"utils#redactUserMessagesIn",
log.debug(
`Redacting ${victimEvent["event_id"]} in ${targetRoomId}`,
targetRoomId
);
if (!noop) {
await client
.redactEvent(targetRoomId, victimEvent["event_id"])
.catch((error: unknown) => {
LogService.error(
"utils#redactUserMessagesIn",
log.error(
`Error while trying to redact messages for ${userIdOrGlob} in ${targetRoomId}:`,
error,
targetRoomId
Expand Down

0 comments on commit 1761f57

Please sign in to comment.