1.0.6 • Published 4 years ago

@koikoder/logger v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Logger

Simple utility to log stuff.

Options

  • prettyPrint (bool): should object be pretty-printed
  • printStatus (bool): should status be printed before message (e.g: INFO)
  • colorAll (bool): should both status and message be colored (when false - only status is colored)
  • base (string): base string for every message
  • separator (string): separator between mutliple items in a single message
  • colorMap (object): defines how different messages are colored
  • statusMap (object): defines which texts are used for which status
// Default values for *colorMap*:
{
    info: "cyan",
    success: "green",
    warn: "yellow",
    error: "red",
    note: "blue",
    base: "magenta",
}

// Default values for *statusMap*:
{
    info: "(info)",
    success: "(success)",
    warn: "(warning)",
    error: "(error)",
    note: "(note)",
}

// Available colors:
["blue", "black", "cyan", "green", "magenta", "red", "white", "yellow"];

Methods

All functions print out a message with a different status and can take any number of arguments:

  • info(...args)
  • success(...args)
  • warn(...args)
  • error(...args)
  • note(..args)
const { Logger } = require("@koikoder/logger");

const logger = new Logger({
  prettyPrint: true,
  printStatus: true,
  colorAll: false,
  base: "[lord crab]: ",
  separator: "\n  ",
  colorMap: {
    base: "magenta",
  },
  statusMap: {
    info: "*INFO*",
    error: "!!ERR",
  },
});

logger.info("Hello crab", [1, 2, 4, 8, 16]);
logger.success(42, "is meaning of life");
logger.warn("something");

logger.note({
  a: [
    { id: 256, isValid: true },
    { id: 512, isValid: false },
  ],
  b: {
    col: [
      "A",
      "B",
      "C",
      {
        label: "D",
        value: 3,
      },
    ],
  },
});

logger.error("Everything crashed");

:crab:

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago