# @vanillas/console-logger

> A wrapper around the native Console API but which supports top-down threshold (levels) based control

Latest version **1.0.1** (published 2021-09-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @vanillas/console-logger
pnpm add @vanillas/console-logger
yarn add @vanillas/console-logger
bun add @vanillas/console-logger
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-09-13 |
| First published | 2021-07-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=12.17.0 |
| Dependencies | 0 |
| Unpacked size | 9.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | David Nunez |
| Maintainers | developerdave |
| Keywords | log, logging, console, log levels, log thresholds, console logging, threshold logging |

## Links

- npm: https://www.npmjs.com/package/@vanillas/console-logger
- Repository: https://github.com/arizonatribe/vanillas-packages
- Homepage: https://github.com/arizonatribe/vanillas-packages/blob/main/packages/console-logger/README.md
- Issues: https://github.com/arizonatribe/vanillas-packages/issues
- npm.io page: https://npm.io/package/@vanillas/console-logger

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2021-09-13
- 1.0.0 — 2021-07-25

## README

# Console Logger

A wrapper around the native Console API but which supports top-down threshold (levels) based control

## Why?

The functionality in tools like this or other similar libraries out there are to allow you to silence logging statements in your application by a single config change (especially when you have your logging threshold level controlled by an environment variable, this is as easy as a re-deploy without any application code changes).

Why does this matter? Because you can leave logger statements in your application permanently, but not have to remove them when you're done debugging (therefore you can use them again in the future when you have to check production logs).

You control all of this functionality by simply changing the threshold level. That way you can operate at a normal "info" or "warn" level when things are going well, but when there's a problem you can toggle the overall level to
something much lower, which activates all those low-level `logger.trace` or `logger.debug` statements - and redeploy your application with full logging enabled.

Logging events can be expensive for high-traffic applications, so being able to toggle verbose logging on/off with a single config value.

# Installation

```
npm install @vanillas/console-logger
```

# Usage

Try it out in the NodeJs shell either next to a `node_modules/` directory where `@vanillas/console-logger` has been installed, _or_ try using [replem](https://www.npmjs.com/package/replem) as a global NPM package so you can load any NPM package into a NodeJs shell.

```
$ replem @vanillas/console-logger:logger

Installed into REPL context:
 - @vanillas/console-logger@1.0.0 as logger

> logger.level
'info'
> logger.setLevel("trace")
> logger.trace("Some very verbose logging statement")
Some very verbose logging statement
> logger.setLevel("debug")
> logger.trace("Some very verbose logging statement")
> logger.debug("Some slightly less verbose logging statement")
Some slightly less verbose logging statement
> logger.setLevel("warn")
> logger.info("Normal stuff to log to stdout")
> logger.error("something broke"
something broke
```

The only thing happening in this example is writing normal logging statements but the ones _below_ the current logger threshold level never show up.

A NodeJs shell is just a quick way to demonstrate functionality for a simple package like this one, but in a front-end or back-end JavaScript/TypeScript appliction you instead just `import` this package and use it in the same manner demonstrated in the shell.

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