# tej-logger

> Yet another logging library for Node.js

Latest version **1.3.0** (published 2026-04-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install tej-logger
pnpm add tej-logger
yarn add tej-logger
bun add tej-logger
```

## Health

**Score 50/100 (C)** — status: active.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2026-04-23 |
| First published | 2024-04-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 138.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Hirak Chhatbar |
| Maintainers | dr.hirak |
| Keywords | logger, logging, tej.js, colorful logger, node.js logger, styled logger, console logger |

## Links

- npm: https://www.npmjs.com/package/tej-logger
- Repository: https://github.com/hirakchhatbar/tej-logger
- Homepage: https://github.com/hirakchhatbar/tej-logger#readme
- Issues: https://github.com/hirakchhatbar/tej-logger/issues
- npm.io page: https://npm.io/package/tej-logger

## Dependencies (1)

- [ansi-colors](https://npm.io/package/ansi-colors.md) ^4.1.3

## 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
- [@luma.gl/experimental](https://npm.io/package/@luma.gl/experimental.md) — 77.1K 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

## Recent versions

- 1.3.0 (latest) — 2026-04-23
- 1.2.6 — 2026-03-27
- 1.2.5 — 2024-04-19
- 1.2.3 — 2024-04-19
- 1.2.2 — 2024-04-19
- 1.2.1 — 2024-04-14
- 1.2.0 — 2024-04-13
- 1.0.2 — 2024-04-13
- 1.0.1 — 2024-04-13
- 1.0.0 — 2024-04-13

## README

# <p align="center">Tej-Logger</p>

A minimal yet powerful logger for Node.js applications. It supports log, info, error, debug and warn. It also supports ANSI styles and colors. It also has an express middleware to log every incoming request.

# Table of contents

1. [Features](#-features)
2. [How to Install](#-install)
3. [Express Middleware](#-express-middleware)
4. [Basic Usage](#-basic-usage)
   1. [Log](#-log)
   2. [Info](#-info)
   3. [Error](#-error)
   4. [Debug](#-debug)
   5. [Warn](#-warn)

## 🧐 Features <a id="-features" class="anchor" aria-hidden="true" href="#️-features"></a>

- Simple and minimal
- Express middleware to log every incoming request
- Log based on identifiers
- Supports log, info, error, debug and warn
- Supports ANSI styles and colors
- [UPCOMING] - Configuration for log levels and log file path

## 🛠️ Install <a id="-install" class="anchor" aria-hidden="true" href="#️-install"></a>

```bash
npm install tej-logger
```

<br>

## 🚀 Express Middleware <a id="-express-middleware" class="anchor" aria-hidden="true" href="#️-express-middleware"></a>

```js
import logHttpRequest from "tej-logger/express-middleware";

// Add this middleware to your express app before any other middleware
app.use(logHttpRequest);
```

![screenshot](screenshots/express-middleware.png)

<br>

## 🧑🏻‍💻 Basic Usage <a id="-basic-usage" class="anchor" aria-hidden="true" href="#️-basic-usage"></a>

```js
import TejLogger from "tej-logger";

const logger = new TejLogger("identifier");
logger.log("Hello World!");
```

### Instance Defaults <a id="-instance-defaults" class="anchor" aria-hidden="true" href="#️-instance-defaults"></a>

Pass default metadata that is merged into every log emitted by this instance.
Per-call metadata keys take precedence over instance defaults.

```js
const logger = new TejLogger("PaymentService", {
  defaults: { service: "billing", radar: true },
});

// Hook receives metadata: { service: "billing", radar: true }
logger.info("Invoice created");

// Per-call key overrides the instance default
// Hook receives metadata: { service: "billing", radar: false, invoiceId: "inv_1" }
logger.info("Debug detail", { radar: false, invoiceId: "inv_1" });
```

The `radar` key can also be set as a top-level shortcut:

```js
// Equivalent to { defaults: { radar: true } }
const logger = new TejLogger("PaymentService", { radar: true });
```

When both `radar` and `defaults.radar` are provided, `defaults.radar` wins.

### Log <a id="-log" class="anchor" aria-hidden="true" href="#️-log"></a>

```js
logger.log("This is a log message");
```

![screenshot](screenshots/log-string.png)

### Info <a id="-info" class="anchor" aria-hidden="true" href="#️-info"></a>

```js
logger.info("This is an info message");
```

![screenshot](screenshots/info.png)

### Error <a id="-error" class="anchor" aria-hidden="true" href="#️-error"></a>

```js
logger.error("This is an error");
//or
logger.error(new Error("This is an error"));
```

![screenshot](screenshots/error-obj.png)

### Debug <a id="-debug" class="anchor" aria-hidden="true" href="#️-debug"></a>

```js
logger.debug("This is a debug message");
```

![screenshot](screenshots/debug.png)

### Warning <a id="-warn" class="anchor" aria-hidden="true" href="#️-warn"></a>

```js
logger.debug("This is a debug message");
```

![screenshot](screenshots/warn.png)

<br>

## 🍰 Contributing <a name = "contributing"></a>

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.

<br>

## ❤️ Support

A simple star to this project repo is enough to keep me motivated on this project for days. If you find your self very much excited with this project let me know with a star.

<br>

## 🙇 Author

#### Hirak Chhatbar

- Github: [@hirakchhatbar](https://github.com/hirakchhatbar)

<br>

## ➤ License

Distributed under the MIT License. See [LICENSE](LICENSE) for more information.

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