# @openstapps/logger

> A cli logger with colors, log-levels and the possibility to use a transport system for errors

Latest version **4.0.2** (published 2025-07-30) · GPL-3.0-only license · 0 weekly downloads

## Install

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

## Health

**Score 40/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.2 |
| Published | 2025-07-30 |
| First published | 2018-11-28 |
| Weekly downloads | 0 |
| License | GPL-3.0-only |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 110.3 KB |
| Known vulnerabilities | 0 (+16 in 2 direct dependencies) |
| Install scripts | no |
| Author | Karl-Philipp Wulfert |
| Maintainers | openstappspublisher, abcdev, jovankrunic |

## Links

- npm: https://www.npmjs.com/package/@openstapps/logger
- Repository: https://gitlab.com/openstapps/logger
- Homepage: https://gitlab.com/openstapps/logger#readme
- Issues: https://gitlab.com/openstapps/logger/issues
- npm.io page: https://npm.io/package/@openstapps/logger

## Dependencies (4)

- [chalk](https://npm.io/package/chalk.md) 5.2.0
- [flatted](https://npm.io/package/flatted.md) 3.2.7
- [nodemailer](https://npm.io/package/nodemailer.md) 6.9.9
- [@types/nodemailer](https://npm.io/package/@types/nodemailer.md) 6.4.7

## Recent versions

- 4.0.2 (latest) — 2025-07-30
- 3.0.0-next.4 (next) — 2023-08-03
- 4.0.0 — 2025-07-01
- 3.0.0 — 2023-10-13
- 1.1.1 — 2022-11-08
- 1.1.0 — 2022-11-01
- 1.0.1 — 2022-10-12
- 1.0.0 — 2022-08-17
- 0.8.1 — 2022-05-27
- 0.8.0 — 2021-12-14
- 0.7.0 — 2021-05-18
- 0.6.0 — 2021-04-06
- 0.5.0 — 2020-03-30
- 0.4.0 — 2019-07-12
- 0.3.1 — 2019-06-05
- … 6 more at https://npm.io/package/@openstapps/logger/versions

## README

# @openstapps/logger

[![pipeline status](https://gitlab.com/openstapps/logger/badges/master/pipeline.svg)](https://gitlab.com/openstapps/logger/commits/master)
[![coverage report](https://gitlab.com/openstapps/logger/badges/master/coverage.svg)](https://gitlab.com/openstapps/logger/commits/master)

This is a simple logger for TypeScript projects with transformations for the log output.

Logs are only printed if their log level is equal or higher than the defined log level.

## Log Levels

Available log levels are:

- 1 - INFO
- 2 - LOG
- 4 - WARN
- 8 - ERROR
- 16 - OK

You can set your log level with the environment variable `STAPPS_LOG_LEVEL`.

To select your desired log levels add the corresponding numbers and set the value of `STAPPS_LOG_LEVEL` to the sum.

For example `STAPPS_LOG_LEVEL=17` is 16 + 1 and would log everything that is `OK` or `INFO`.

If you want to use logger in production (`NODE_ENV=production`) and allow all transports to fail set `ALLOW_NO_TRANSPORT` to `true`.

Additionally setting the environment variable `STAPPS_EXIT_LEVEL` which works in the same manner as `STAPPS_LOG_LEVEL` will terminate your process after logging at the selected level(s) (usefull for integration tests). It will be ignored in afore mentioned productive environments.

## SMTP

This class also provides a simple implementation of an SMTP transport which can be used as a
`TransportWithVerification` for the logger. You can use this to transport errors of the logger or to transport mails
of your own monitoring solution.

### Usage

You can instatiate it with a config or it will check for a config in the environment variables. Environment variables
can overwrite the actual config values.

Environment variables are:

- SMTP_AUTH_USER: SMTP username
- SMTP_AUTH_PASSWORD: SMTP password
- SMTP_HOST: SMTP host
- SMTP_PORT: SMTP port
- SMTP_RECIPIENTS: comma seperated list of recipients
- SMTP_CC: comma seperated list of recipients for the carbon copy (CC)
- SMTP_SENDER_MAIL: sender of the mail
- SMTP_SENDER_NAME: name of the sender
- SMTP_SECURE: `true` to enable tls

## Transformations

By default the logger will only add the log level to the message. It will replace newlines with spaces and might skip some of your choosen Transformers when in production (`NODE_ENV=production`) for compatibility reasons with existing log aggregators and analyzers.

You can change this behavior by setting other Transformers via `Logger.setTransformations`. If you do so, mind the order of the transformers.

You may choose from the following:

- `AddLogLevel`, which prepends the output with the log level
- `Colorize`, which colorizes the output according to the log level
- `Timestamp`, which prepends a timestamp to the output

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