# @ombro/logger

> Provides preset and custom Node.js log output tools

Latest version **2.0.2** (published 2024-03-19) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 40/100 (D)** — status: abandoned.

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

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2024-03-19 |
| First published | 2021-06-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 9 |
| Unpacked size | 14.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 38 |
| Author | Cphayim |
| Maintainers | cphayim |
| Keywords | log, logger, cli |

## Links

- npm: https://www.npmjs.com/package/@ombro/logger
- Repository: https://github.com/Cphayim/ombro
- Homepage: https://github.com/Cphayim/ombro/
- Issues: https://github.com/Cphayim/ombro/issues
- npm.io page: https://npm.io/package/@ombro/logger

## Dependencies (9)

- [ora](https://npm.io/package/ora.md) ^6.3.1
- [boxen](https://npm.io/package/boxen.md) ^7.1.1
- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [dedent](https://npm.io/package/dedent.md) ^1.5.1
- [figlet](https://npm.io/package/figlet.md) ^1.7.0
- [readline](https://npm.io/package/readline.md) ^1.3.0
- [strip-ansi](https://npm.io/package/strip-ansi.md) ^7.1.0
- [@types/dedent](https://npm.io/package/@types/dedent.md) ^0.7.2
- [@types/figlet](https://npm.io/package/@types/figlet.md) ^1.5.8

## 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.2 (latest) — 2024-03-19
- 2.0.1 — 2023-03-01
- 2.0.0 — 2022-08-31
- 1.5.5 — 2022-02-26
- 1.5.4 — 2022-02-26
- 1.5.2 — 2022-02-20
- 1.5.0 — 2021-11-16
- 1.4.0 — 2021-07-30
- 1.3.0 — 2021-07-21
- 1.2.0 — 2021-07-21
- 1.1.3 — 2021-07-16
- 1.1.2 — 2021-07-03
- 1.1.1 — 2021-07-02
- 1.1.0 — 2021-06-28
- 1.0.0 — 2021-06-27

## README

# @ombro/logger

![npm package](https://badgen.net/npm/v/@ombro/logger)

[简体中文](./README.zh-CN.md)

Provides preset and custom Node.js log output tools

![](./docs/console.png)

## Install

```sh
$ npm install @ombro/logger
```

Note that only ESM module imports are supported since `v2.0.0`, if you need to use `require()` to import `CommonJS` modules, please install `v1.5.5`

```sh
$ npm  install @ombro/logger@1.5.5
```

## Usage

```js
import { logger } from '@ombro/logger'

logger.setLevelValue('verbose')

logger.verbose('verbose message')
logger.debug('debug message')
logger.info('info message')
logger.done('success message')
logger.warn('warning message')
logger.error('error message')

logger.loadding('wait a moment')

setTimeout(() => {
  logger.clearLoadding()
  logger.done('successful!')
}, 2000)
```

## API

### `logger.setLevel(level: string)`

Sets the lowest level at which printing can be output

- **level**
  - Lowest level
  - type: `'verbose' | 'info' | 'notice' | 'warn' | 'error' | 'silent'`
  - default: `'info'`

### `logger.verbose(message: string, tag = '')`

Print a verbose message

- **message**
  - Message content
  - type: `string`
  -
- **tag**
  - Message prefix
  - type: `string`
  - default: `''`

### `logger.debug(message: string, tag = '')`

Print a debug message

- **message**

  - Message content
  - type: `string`

- **tag**
  - Message prefix
  - type: `string`
  - default: `''`

### `logger.info(message: string, tag = '')`

Print a info message

- **message**

  - Message content
  - type: `string`

- **tag**
  - Message prefix
  - type: `string`
  - default: `''`

### `logger.done(message: string, tag = '', plain = false)`

Print a success message

- **message**

  - Message content
  - type: `string`

- **tag**

  - Message prefix
  - type: `string`
  - default: `''`

- **plain**
  - Is `plain` message, which strips the color of the message itself
  - type: `boolean`
  - default: `false`

### `logger.warn(message: string, tag = '', plain = false)`

Print a warnning message

- **message**

  - Message content
  - type: `string`

- **tag**

  - Message prefix
  - type: `string`
  - default: `''`

- **plain**
  - Is `plain` message, which strips the color of the message itself
  - type: `boolean`
  - default: `false`

### `logger.error(message: string, tag = '', plain = false)`

Print a error message

- **message**

  - Message content
  - type: `string`

- **tag**

  - Message prefix
  - type: `string`
  - default: `''`

- **plain**
  - Is `plain` message, which strips the color of the message itself
  - type: `boolean`
  - default: `false`

### `logger.startLoading(message: string): void`

Display wait loading spinner, only one spinner can exist at the same time

- **message**
  - wait message
  - type: `string`

### `logger.stopLoading()`

Stop and clear loading spinner

### `logger.clearConsole(title = '')`

Clear the output of the current console，Only valid under tty (macOS, Linux)

- **title**
  - Optionally output text after cleanup
  - type: `string`
  - default: `''`

## CHANGELOG

[CHANGELOG.md](./CHANGELOG.md)

## LICENSE

MIT

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