fock-logger - v7.0.1
    Preparing search index...

    Расширение и кастомизация

    Наследуйте BaseFormatter и реализуйте canFormat и format.

    class MyCustomFormatter extends BaseFormatter<{ custom: string }> {
    public canFormat(input: LoggerInput): boolean {
    return input && typeof input === "object" && "custom" in input;
    }

    protected format(input: { custom: string }[]): string[] {
    return input.map((item) => `[CUSTOM] ${item.custom}`);
    }
    }

    Затем подключите его в FormatterHandler:

    const handler = new FormatterHandler([
    new MyCustomFormatter(),
    new ErrorFormatter(),
    new DefaultFormatter(),
    ]);

    Наследуйте BaseAffix и переопределите конструктор с нужным типом:

    class MyPrefix extends BaseAffix {
    public constructor(data: AffixChildConstructor) {
    super({ type: "prefix", ...data });
    }
    }

    TimestampService и любые другие, наследующие Turnable, можно включать/выключать:

    timestampService.disable();
    // Теперь временные метки не добавляются

    Вы можете реализовать интерфейсы FileServiceType или TimestampServiceType и передать их в конструктор логгера.

    При вызове read вы можете передать собственные данные в input, которые будут отформатированы через тот же formatterHandler.