Skip to content

servexyz/tacker

Repository files navigation

logo

Console log helpers for your debugging journey

travis-build-status

Getting Started

Install

npm install tacker -S

Add to source

import { printLine, printMirror, printPkgVersion, printPkgProp } from "tacker";

API

printLine(szColor || oColor) - Sync

Where

  • szColor is a string. Color options can be found on chalk's readme or in source here
  • oColor is an object comprised of properties so you can mnaually configure the line
    • color: the color of the line; default is blue
    • character: the character which will make up the line; default is -
    • length: represents the number of characters to repeat; default is 59
    • quantity represents the number of lines to print; default is 1

Examples

  • printLine("blue")
  • printLine({color:"blue", character:"-","length:59",quantity:1})

Output

Both of the above examples produce this identical output printLine output
printMirror({ mVariable }, szKeyColor, szValueColor) - Sync

This will print the variable's name and the variable's value (regardless of variable type).

Where

  • mVariable is an object or a variable you would like to print. If it's an object or an array, it will pretty-print using JSON.stringify.
  • szVariableKeyColor is a string of the variable's key.
  • szVariableValueColor is an object or a variable

Example

const mock = { foo: "bar" }; printMirror({mock}, "blue", "grey")

Output

printMirror output
printPkgVersion(mPkgSource) - Async

This will print the version of the specified package.

Where

  • mPkgSource allows you to specify which package to read from.
    • undefined
    • string
    • object

Example

  • await printPkgVersion()
  • await printPkgVersion("/path")
  • await printPkgVersion("/path/package.json")
  • await printPkgVersion({ name: "tacker", version: "x.y.z", ...})

Output

printPkgVersion
printPkgProp(szProperty, mPkgSource) - Async

This will print any property from the specified package.

Where

  • szProperty
  • allows you to specify the package property.
  • mPkgSource allows you to specify which package to read from.
    • undefined
    • string
    • object

Example

  • await printPkgProp("version")
  • await printPkgProp("version", "/path")
  • await printPkgProp("version", "/path/package.json")
  • await printPkgProp("version", { name: "tacker", version: "x.y.z", ...})

Output

printPkgVersion

FAQ

Name Portmaneau of "tack" and "logger"

In a sailing context, tack means "change course by turning a boat's head into and through the wind"

WhyThere's reasons to use more sophisticated tooling (stack traces, Chrome dev tools, etc). However, when you're getting up-and-running with a project, it's extremely helpful to be able to log values. The issue is before long, your terminal is contaminated with a slew of logs. Tacker exists to solve this
How
  • Make logs prettier (current)
  • Only log things in certain circumstances (future)