# log-update-async-hook

> log-update fork that uses async-exit-hook internally

Latest version **2.0.7** (published 2022-05-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install log-update-async-hook
pnpm add log-update-async-hook
yarn add log-update-async-hook
bun add log-update-async-hook
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.7 |
| Published | 2022-05-17 |
| First published | 2017-06-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andrey Belym |
| Maintainers | aleksey_popov, dmitry-ostashev, lavrovartem, miherlosev, belym.a.2105, kirovboris, alexkamaev |
| Keywords | log, logger, logging, cli, terminal, term, console, shell, update, refresh, overwrite, output, stdout, progress, bar, animation |

## Links

- npm: https://www.npmjs.com/package/log-update-async-hook
- Repository: https://github.com/AndreyBelym/log-update-async-hook
- Homepage: https://github.com/AndreyBelym/log-update-async-hook#readme
- Issues: https://github.com/AndreyBelym/log-update-async-hook/issues
- npm.io page: https://npm.io/package/log-update-async-hook

## Dependencies (4)

- [onetime](https://npm.io/package/onetime.md) ^2.0.1
- [wrap-ansi](https://npm.io/package/wrap-ansi.md) ^7.0.0
- [ansi-escapes](https://npm.io/package/ansi-escapes.md) ^4.3.2
- [async-exit-hook](https://npm.io/package/async-exit-hook.md) ^1.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

- 2.0.7 (latest) — 2022-05-17
- 2.0.6 — 2022-03-16
- 2.0.5 — 2022-02-22
- 2.0.4 — 2022-02-18
- 2.0.3 — 2022-02-15
- 2.0.2 — 2017-07-07
- 2.0.1 — 2017-06-28
- 2.0.0 — 2017-06-28

## README

# log-update-async-hook [![Build Status](https://travis-ci.org/AndreyBelym/log-update-async-hook.svg?branch=master)](https://travis-ci.org/AndreyBelym/log-update-async-hook)

This is a fork of the [log-update](https://github.com/sindresorhus/log-update) by Sindre Sorhus, that uses `async-exit-hook` to restore terminal cursor state when the process terminates.
Usage of `exit-hook` or `signal-exit` hook in the original `log-update` prevents execution of asynchronous operations on signals (`SIGTERM`, `SIGHUP`, etc.) in the code of the main application.
So I've replaced them by `async-exit-hook`, rewritten code to allow execution on Node versions below `4.x` and bundled some dependencies into the package.
  
> Log by overwriting the previous output in the terminal.<br>
> Useful for rendering progress bars, animations, etc.

![](screenshot.gif)


## Install

```
$ npm install --save log-update
```


## Usage

```js
const logUpdate = require('log-update');
const frames = ['-', '\\', '|', '/'];
let i = 0;

setInterval(() => {
	const frame = frames[i = ++i % frames.length];

	logUpdate(
`
        ♥♥
   ${frame} unicorns ${frame}
        ♥♥
`
	);
}, 80);
```


## API

### logUpdate(text, ...)

Log to stdout.

### logUpdate.clear()

Clear the logged output.

### logUpdate.done()

Persist the logged output.<br>
Useful if you want to start a new log session below the current one.

### logUpdate.stderr(text, ...)

Log to stderr.

### logUpdate.stderr.clear()
### logUpdate.stderr.done()

### logUpdate.create(stream)

Get a `logUpdate` method that logs to the specified stream.


## Examples

- [listr](https://github.com/SamVerschueren/listr) - Uses this module to render an interactive task list
- [ora](https://github.com/sindresorhus/ora) - Uses this module to render awesome spinners
- [speed-test](https://github.com/sindresorhus/speed-test) - Uses this module to render a [spinner](https://github.com/sindresorhus/elegant-spinner)


## License

MIT © [Sindre Sorhus](https://sindresorhus.com)

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