diff --git a/src/bot.ts b/src/bot.ts index 993b2c1..09184e5 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -10,7 +10,7 @@ import { SlashCommandStringOption, } from "npm:discord.js@14.14.1"; import { channel, log_from, SimpleResult, split_promise } from "./utils.ts"; -const log = (...args: unknown[]) => log_from(import.meta.url, ...args); +const log = log_from(import.meta.url); /** * Wraps a discord bot and implements required actions. diff --git a/src/cri.ts b/src/cri.ts index 5c0d8c9..75e1fff 100644 --- a/src/cri.ts +++ b/src/cri.ts @@ -1,6 +1,6 @@ import { z } from "https://deno.land/x/zod@v3.22.4/mod.ts"; import { log_from } from "./utils.ts"; -const log = (...args: unknown[]) => log_from(import.meta.url, ...args); +const log = log_from(import.meta.url); /** * Wraps the CRI API. diff --git a/src/email.ts b/src/email.ts index 407357b..6a1b776 100644 --- a/src/email.ts +++ b/src/email.ts @@ -1,6 +1,6 @@ import { ClientOptions, SMTPClient } from "https://deno.land/x/denomailer@1.6.0/mod.ts"; import { log_from } from "./utils.ts"; -const log = (...args: unknown[]) => log_from(import.meta.url, ...args); +const log = log_from(import.meta.url); export type EmailerConfig = { hostname: string; diff --git a/src/main.ts b/src/main.ts index 7c4912a..7234b0d 100755 --- a/src/main.ts +++ b/src/main.ts @@ -7,7 +7,7 @@ import { EpitlsBot } from "./bot.ts"; import { CriApi } from "./cri.ts"; import { Emailer } from "./email.ts"; import { WebVerifier } from "./verifier.ts"; -const log = (...args: unknown[]) => log_from(import.meta.url, ...args); +const log = log_from(import.meta.url); async function main() { const conf = await read_conf(root_path() + "/conf.json"); diff --git a/src/utils.ts b/src/utils.ts index 1acda34..b449060 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -51,10 +51,10 @@ export type Resolver = (item: T) => void; /** * Logging function factory. */ -export function log_from(url: string, ...args: unknown[]) { +export function log_from(url: string) { const date = new Date().toLocaleString("fr-FR"); const file = path.basename(new URL(url).pathname); - console.log(`[${date}][epitls][${file}]`, ...args); + return (...args: unknown[]) => console.log(`[${date}][epitls][${file}]`, ...args); } export type Conf = Awaited>; diff --git a/src/verifier.ts b/src/verifier.ts index e37d154..0898175 100644 --- a/src/verifier.ts +++ b/src/verifier.ts @@ -1,6 +1,6 @@ import { v1 as uuid } from "https://deno.land/std@0.213.0/uuid/mod.ts"; import { channel, log_from, Resolver, SimpleResult, split_promise, wait } from "./utils.ts"; -const log = (...args: unknown[]) => log_from(import.meta.url, ...args); +const log = log_from(import.meta.url); export type WebVerifierConf = { port: number;