Skip to content

Add "uber transform" for formatting #3

Description

@sdedios

I think there needs to be a simple "uber-formatting" plugin that has a couple of pre-canned options but that provides a set of great out-of-the-box formatting options. Some suggestions for features this plugin would provide are:

  1. Automatic prefixing of namespace + log level in the output, with the option to have one or both showing (via an enum).
  2. Automatic coloring of the output based on a couple of coloring options (via an enum).
  3. Optional timer output, showing the number of ms / s / mins between this and last log output.

I would also suggesting doing some more research to see what other options might be helpful.

I think the transform interface might look something like this:

type UberFormatOptions = {
    prefixing: "none" | "level" | "namespace" | "all";
    coloring: "none" | "level" | "namespace";
    timing: "none" | "timestamp" | "stopwatch";
};

function UberFormatter(options: Readonly<UberFormatOptions>) {}

// used as follows
Scribe.transform = UberFormatter({
    prefixing: "all",
    coloring: "namespace",
    timing: "stopwatch"
});

const log = Scribe.getLog("myapp:MyModule");
log.debug("a message", data");

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions