# pocket-console

> A sleak & small drop-in-replacement of Console for nicer logging, written in TypeScript

Latest version **0.5.0** (published 2023-02-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install pocket-console
pnpm add pocket-console
yarn add pocket-console
bun add pocket-console
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2023-02-10 |
| First published | 2022-10-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12 |
| Dependencies | 0 |
| Unpacked size | 30.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Thomas Backlund |
| Maintainers | bashlund |

## Links

- npm: https://www.npmjs.com/package/pocket-console
- Repository: https://github.com/bashlund/pocket-console
- Homepage: https://github.com/bashlund/pocket-console#readme
- Issues: https://github.com/bashlund/pocket-console/issues
- npm.io page: https://npm.io/package/pocket-console

## Recent versions

- 0.5.0 (latest) — 2023-02-10
- 0.4.0 — 2023-02-02
- 0.3.1 — 2023-01-17
- 0.3.0 — 2022-12-07
- 0.2.0 — 2022-10-13
- 0.1.0 — 2022-10-12

## README

# pocket-console

Santa Claus came early this year and gifted this sleak little logging lib written in TypeScript.  

It is a drop-in replacement of `console`.  

It got colors, log levels, automatic grouping, and yes also some of those unicode chars if you like.  

0, zero, nada, zip, none, no dependencies.  

Also, controllable via `env` variables.  

Colors are automatically turned off when not outputting to a terminal.  


```sh
// options are optional.
const options = {module: "ModuleName", level: "error" | "warn" | "info" | "debug", format: "%c%M%t %m %l"};

let console = PocketConsole(options);

// aced has same loglevel threshold as info.
console.aced("Oh yeah!");

console.error("Oh, snap!");

console.warn("Hey, hold on!");

console.info("Heads up!");

console.debug("FYI");

console.getConsole().error("Use the original console object to output directly to stderr");

console.log("stdout logging is not formatted in any way");

// Grouped output (secondary lines are indented).
console.aced("BTW: here is the result", {name: "Bobby", callSign: "0xdeadbeef"});

// Console's other functionality is still available.
console.table([{col1: "table", col2: "still works"}], ["col1", "col2"]);
```

An important feature is that options can ge globally set using `env` variables. So if multiple dependencies of your project is using pocket-console then you can steer the loglevel and logformat for all those loggers, like:  
```sh
node -r ts-node/register ./example/example-one.ts

LOG_FORMAT="%c%L" node -r ts-node/register ./example/example-one.ts

LOG_LEVEL=none node -r ts-node/register ./example/example-one.ts
```

It does automatic grouping for you, if you have more than one argument or the single argument is non-string.

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