kind-regards
Teaching my Node APIs some manners.
Last updated 9 months ago by harrysolovay .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install kind-regards 
SYNC missed versions from official npm registry.

Kind Regards,

... is the CLI output resulting from the following:

import { Reporter } from "kind-regards";
import { join } from "path";

const report = Reporter({
  verbose: true,
  debug: true,
  documentation: join(__dirname, "DIAGNOSTICS.md"),
});

report.diagnostic({
  category: "warning",
  message: "Warning Log",
  file: __filename,
});

report.diagnostic({
  category: "error",
  message: "Recoverable error log",
  file: __filename,
  recoverable: true,
});

report.info("Info log");
report.verbose("Verbose-mode only log");
report.success("Success log");

const a = {
  b: {
    c: {
      d: () => console.log("e"),
    },
  },
};
// @ts-ignore
a.b.c.f = a;
report.debug(a);

report.diagnostic({
  category: "error",
  message: "Unrecoverable error log",
  file: __filename,
});

Why?

Because it's kind to...

  • be concise when displaying varying kinds of logs to users.
  • offer users silent, verbose, and debug modes.
  • offer serialization, highlighting, and pretty-printing data (circularities included).

Between warnings, errors, one-off console logs, verbose/debug-mode logs, circular-object printing, and their related documentation... there's a lot of complexity to manage. kind-regards takes care of this complexity.

Installation

npm i kind-regards

Instantiation

import { Reporter } from "kind-regards";

const report = Reporter();

Configuration Options

Reporter accepts an optional object with the following properties:

Key Type Default Description
documentation string | Falsy undefined Relative path to API-wide documentation.
silent boolean | Falsy undefined Disables all logging (which is especially useful in publicly-accessible CI/CD environments).
verbose boolean | Falsy undefined When false, report.verbose logs will be hidden.
debug boolean | Falsy undefined When false, report.debug logs will be hidden.

For instance...

import { Reporter } from "kind-regards";
import { join } from "path";

const report = Reporter({
  verbose: true,
  debug: true,
  documentation: join(__dirname, "../README.md"),
});

make sure––when publishing––to include the referenced documentation in your package

Methods

... look at the type definitions ;)

Current Tags

  • 0.0.4                                ...           latest (9 months ago)

4 Versions

  • 0.0.4                                ...           9 months ago
  • 0.0.3                                ...           9 months ago
  • 0.0.2                                ...           9 months ago
  • 0.0.1                                ...           9 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |