3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

logs: allow per-log-channel log formats

This commit is contained in:
Dragory 2020-07-30 02:28:11 +03:00
parent 8b22ce267d
commit 28de8a592b
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
3 changed files with 20 additions and 13 deletions

View file

@ -1,5 +1,5 @@
import { PluginData } from "knub";
import { LogsPluginType } from "../types";
import { LogsPluginType, TLogFormats } from "../types";
import { LogType } from "src/data/LogType";
import {
verboseUserMention,
@ -14,9 +14,14 @@ import { renderTemplate, TemplateParseError } from "src/templateFormatter";
import { logger } from "src/logger";
import moment from "moment-timezone";
export async function getLogMessage(pluginData: PluginData<LogsPluginType>, type: LogType, data: any): Promise<string> {
export async function getLogMessage(
pluginData: PluginData<LogsPluginType>,
type: LogType,
data: any,
formats?: TLogFormats,
): Promise<string> {
const config = pluginData.config.get();
const format = config.format[LogType[type]] || "";
const format = (formats && formats[LogType[type]]) || config.format[LogType[type]] || "";
if (format === "") return;
const values = {