# @tnotifier/logger

> Pretty-print utility logger for JS/TS

Latest version **1.0.5** (published 2022-02-11) · GPL-3.0-only license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @tnotifier/logger
pnpm add @tnotifier/logger
yarn add @tnotifier/logger
bun add @tnotifier/logger
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2022-02-11 |
| First published | 2021-11-24 |
| Weekly downloads | 0 |
| License | GPL-3.0-only |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 47.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Evil Kiwi Limited |
| Maintainers | oyed |
| Keywords | typescript, vue, logger, log, console, color |

## Links

- npm: https://www.npmjs.com/package/@tnotifier/logger
- Repository: https://github.com/tnotifier/logger
- Issues: https://github.com/tnotifier/logger/issues
- npm.io page: https://npm.io/package/@tnotifier/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.5 (latest) — 2022-02-11
- 1.0.4 — 2022-01-18
- 1.0.3 — 2022-01-18
- 1.0.2 — 2021-12-30
- 1.0.1 — 2021-12-30
- 1.0.0 — 2021-11-24

## README

<div align="center">
    <a href="https://www.npmjs.com/package/@tnotifier/logger" target="_blank">
        <img src="https://img.shields.io/npm/v/@tnotifier/logger?style=flat-square" alt="NPM" />
    </a>
    <a href="https://discord.gg/XMrHXtN" target="_blank">
        <img src="https://img.shields.io/discord/123906549860139008?color=7289DA&label=discord&logo=discord&logoColor=FFFFFF&style=flat-square" alt="Discord" />
    </a>
    <img src="https://img.shields.io/npm/l/@tnotifier/logger?style=flat-square" alt="Apache-2.0" />
    <h3>Pretty-print utility logger for JS/TS</h3>
</div>

`@tnotifier/logger` provides a small interface on top of the existing `console` API and includes things such as:

- Automatic code highlighting via \`template literal\` syntax
- High-precision timestamps
- Namespacing and Instanced Loggers
- Enable/disable logging at runtime

![Preview](https://cdn.tnotifier.app/open-source/logger.png)

## Installation

This package is available via NPM:

```bash
yarn add @tnotifier/logger

# or

npm install @tnotifier/logger
```

## Usage

By default, `@tnotifier/logger` exports traditional logging methods using a shared logger instance. For example:

```typescript
import { debug, error } from '@tnotifier/logger';

try {
    await something();
    debug('success!');
} catch (e) {
    error('failure!', e);
}
```

However, if you'd like to add namespaces and use multiple logger instances within your application, you can instead instantiate a new Logger:

```typescript
import { createLogger } from '@tnotifier/logger';

const loggerA = createLogger({
    name: 'module-a',
    color: '#FF0000',
});
const loggerB = createLogger({
    name: 'module-b',
    color: '#00FF00',
});

loggerA.debug('hello world A!');
loggerA.error('hello world B!');
```

You can also set a global namespace for all Logger instances created via your App. This can be useful if your console displays output from multiple systems, for example an Electron App or when using iFrames.

```typescript
import { setNamespace } from '@tnotifier/logger';

setNamespace({
    name: 'website',
    color: '#0000FF',
});
```

This will be pre-pended to all logging that passes through `@tnotifier/logger`, regardless of whether it was instanced.

## To-do

- Remove side effects to enable tree shaking

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