# table-log

> CLI logging utility that logs lines as vertically aligned tabular data

Latest version **1.0.1** (published 2021-04-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install table-log
pnpm add table-log
yarn add table-log
bun add table-log
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-04-30 |
| First published | 2021-04-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 13 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Lukas Bach |
| Maintainers | lukasbach |
| Keywords | cli, logging, typescript, typed, table, tabular, log, ink |

## Links

- npm: https://www.npmjs.com/package/table-log
- Repository: https://github.com/lukasbach/table-log
- npm.io page: https://npm.io/package/table-log

## Dependencies (5)

- [ink](https://npm.io/package/ink.md) ^3.0.8
- [react](https://npm.io/package/react.md) ^17.0.2
- [ayemitter](https://npm.io/package/ayemitter.md) ^1.0.2
- [cli-table](https://npm.io/package/cli-table.md) ^0.3.6
- [ayemitter-hook](https://npm.io/package/ayemitter-hook.md) ^1.0.2

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2021-04-30
- 1.0.0 — 2021-04-30

## README

# `table-log`

> NPM utility tool to log lines as vertically aligned tabular data.

![Demo](demo/demo-no-border.gif)

## Get Started

Install the tool via `yarn add table-log` or `npm i table-log --save`. Then import
the utility via

```typescript
import { CliTable } from 'table-log';
```

Then, initialize a new table with `table = CliTable.createNoBorderTable()`,
and invoke `table.log(...lines)` to log a new line. The table is automatically adjusted
whenever a new longest cell is logged.

Complete example:

```typescript
import { CliTable } from 'table-log';

const table = CliTable.createNoBorderTable({
  // Optional column alignments
  colAligns: ['left', 'right', 'left', 'right'],
  
  // Optional maximum column widths
  colWidths: [undefined, undefined, 35, undefined]
});

table.log('Received', 'GET', '/users/obi-wan-kenobi', '(352ms)');
table.log('Received', 'GET', '/users/vader', '(241ms)');
table.log('Received', 'POST', '/lightsabers/red/vader', '(890ms)');
table.log('Received', 'POST', '/lightsabers/blue/obi-wan-kenobi', '(937ms)');
table.log('Received', 'OPTIONS', '/lightsabers/new', '(125ms)');
table.log('Received', 'PUT', '/lightsabers/new', '(11,335ms)');
table.log('Received', 'GET', '/users/yoda', '(452ms)');
table.log('Received', 'POST', '/lightsabers/green/yoda', '(676ms)');

// There may also pass some time between renders
await new Promise(r => setTimeout(r, 2000));

table.log('Received', 'GET', '/lightsabers/green/yoda/handle/material', '(124ms)');

table.unmount();

console.log("Table unmounted!");
```

You can also create a table with a border, by invoking `CliTable.createSingleBorderTable()`
or `CliTable.createDoubleBorderTable()` instead of `CliTable.createNoBorderTable()`.

![Demo](demo/demo-single-border.gif)
![Demo](demo/demo-double-border.gif)

---
_Source: https://npm.io/package/table-log · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
