# @haensl/log

> Minimal node.js log service.

Latest version **1.3.14** (published 2024-11-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @haensl/log
pnpm add @haensl/log
yarn add @haensl/log
bun add @haensl/log
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

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

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.14 |
| Published | 2024-11-05 |
| First published | 2018-11-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | HP Dietz |
| Maintainers | haensl |
| Keywords | Node.js, log, service, minimal |

## Links

- npm: https://www.npmjs.com/package/@haensl/log
- Repository: https://github.com/haensl/log
- Homepage: https://github.com/haensl/log#readme
- Issues: https://github.com/haensl/log/issues
- Funding: https://github.com/sponsors/haensl
- npm.io page: https://npm.io/package/@haensl/log

## Dependencies (1)

- [chalk](https://npm.io/package/chalk.md) ^4.1.2

## 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.3.14 (latest) — 2024-11-05
- 1.3.13 — 2024-03-12
- 1.3.12 — 2023-09-25
- 1.3.11 — 2023-05-16
- 1.3.10 — 2023-01-11
- 1.3.9 — 2022-04-05
- 1.3.8 — 2022-02-17
- 1.3.7 — 2022-02-01
- 1.3.6 — 2021-12-19
- 1.3.5 — 2021-05-28
- 1.3.4 — 2021-01-12
- 1.3.3 — 2021-01-12
- 1.3.2 — 2021-01-12
- 1.3.1 — 2021-01-11
- 1.3.0 — 2021-01-11
- … 9 more at https://npm.io/package/@haensl/log/versions

## README

# @haensl/log

[![NPM](https://nodei.co/npm/@haensl%2Flog.png?downloads=true)](https://nodei.co/npm/@haensl%2Flog/)

[![npm version](https://badge.fury.io/js/@haensl%2Flog.svg)](http://badge.fury.io/js/@haensl%2Flog)
[![CircleCI](https://circleci.com/gh/haensl/log.svg?style=svg)](https://circleci.com/gh/haensl/log)

Minimal Node.js log service.

## Installation

Via npm

`npm i --save @haensl/log`

Via yarn

`yarn add @haensl/log`

## Usage

```javascript
const log = require('@haensl/log');

log.debug('Some debug log message');
```

### API

Log exposes five functions:

`debug(...args)` _green output. does not log if_ `NODE_ENV` _is set to production._

`info(...args)` _default terminal color output._

`log(...args)` _default terminal color output._

`warn(...args)` _yellow output._

`error(...args)` _red output._

Each of them maps to the respective `console` function.
The first line of each log is prefixed with timestamp and log level.
If the first argument is a string, it is printed on the first line.
Each other argument is printed on a separate line.
If more than one argument is passed, the block is delimited by dashes.

### Examples

```javascript
const log = require('@haensl/log');

log.info('test');

// 2018-11-10 23:07:16 INFO test
```

```javascript
const log = require('@haensl/log');

log.error({ a: 1 }, 15, new Error('foo'));

// 2018-11-10 23:07:16 ERR
// { a: 1 }
// 15
// Error: foo
//   at Context.beforeEach (/Users/hpdietz/Developer/log/log.test.js:84:39)
//   at callFn (/Users/hpdietz/Developer/log/node_modules/mocha/lib/runnable.js:372:21)
//   at Hook.Runnable.run (/Users/hpdietz/Developer/log/node_modules/mocha/lib/runnable.js:364:7)
//   at next (/Users/hpdietz/Developer/log/node_modules/mocha/lib/runner.js:317:10)
//   at Immediate.<anonymous> (/Users/hpdietz/Developer/log/node_modules/mocha/lib/runner.js:347:5)
//   at runCallback (timers.js:810:20)
//   at tryOnImmediate (timers.js:768:5)
//   at processImmediate [as _immediateCallback] (timers.js:745:5)
// --------------------------------
```

## [Changelog](CHANGELOG.md)

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