ixfx
    Preparing search index...

    Function logger

    • Returns a console logging function which prefixes messages. This is useful for tracing messages from different components. Each prefix is assigned a colour, further helping to distinguish messages.

      Use logSet to get a bundled set.

      // Initialise once
      const log = logger(`a`);
      const error = logger(`a`, `error`);
      const warn = logger(`a`, `warn);

      // And then use
      log(`Hello`); // console.log(`a Hello`);
      error(`Uh-oh`); // console.error(`a Uh-oh`);
      warn(`Eek!`); // console.warn(`a Eeek!`);

      Provide the colourKey parameter to make log messages be coloured the same, even though the prefix is different.

      // Both loggers will use the same colour because they
      // share the colour key `system`
      const log = logger(`a`,`log`,`system`);
      const log2 = logger(`b`, `log`, `system`);

      Parameters

      • prefix: string
      • kind: "error" | "warn" | "log" = ...
      • OptionalcolourKey: string

        Optional key to colour log lines by instead of prefix

      Returns MessageLogger