# diy-log

> Various console log level prefixes with support for color symbols and tags.

Latest version **2.5.2** (published 2024-11-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install diy-log
pnpm add diy-log
yarn add diy-log
bun add diy-log
```

## 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 | 2.5.2 |
| Published | 2024-11-28 |
| First published | 2018-12-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 2 |
| Unpacked size | 13 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mervin |
| Maintainers | mengqing723 |
| Keywords | log, logger, colors, console, symbols, tags, console.log, log symbols, logging, terminal |

## Links

- npm: https://www.npmjs.com/package/diy-log
- Repository: https://github.com/Marinerer/diy-log
- Homepage: https://github.com/Marinerer/diy-log#readme
- Issues: https://github.com/Marinerer/diy-log/issues
- npm.io page: https://npm.io/package/diy-log

## Dependencies (2)

- [picocolors](https://npm.io/package/picocolors.md) ^1.0.0
- [time-stamp](https://npm.io/package/time-stamp.md) ^2.2.0

## 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.5.2 (latest) — 2024-11-28
- 2.5.1 — 2023-11-16
- 2.5.0 — 2023-11-14
- 2.4.1 — 2023-05-17
- 2.4.0 — 2022-09-21
- 2.3.0 — 2022-09-21
- 2.2.0 — 2022-09-20
- 2.1.0 — 2022-09-20
- 2.0.2 — 2022-09-20
- 2.0.1 — 2022-09-20
- 2.0.0 — 2022-09-19
- 1.0.0 — 2018-12-14

## README

# diy-log 🌈

[![version](https://img.shields.io/npm/v/diy-log?style=flat-square)](https://www.npmjs.com/package/diy-log)
[![Codecov](https://img.shields.io/codecov/c/github/Marinerer/diy-log?token=HYQ5I268HN&style=flat-square&logo=codecov)](https://codecov.io/gh/Marinerer/diy-log)
[![release](https://img.shields.io/github/actions/workflow/status/Marinerer/diy-log/release.yml?style=flat-square)](https://github.com/Marinerer/pipflow/releases)
[![node.js](https://img.shields.io/node/v/diy-log?style=flat-square&logo=nodedotjs)](https://nodejs.org/en/about/releases/)
[![languages](https://img.shields.io/github/languages/top/Marinerer/diy-log?style=flat-square)](https://github.com/Marinerer/diy-log)
[![downloads](https://img.shields.io/npm/dm/diy-log?style=flat-square)](https://www.npmjs.com/package/diy-log)



> Various console log level prefixes with support for color symbols and tags.

自定义控制台各种级别日志输出的前缀，支持颜色符号，标签和时间。


![img](./example/screenshot.png)



## Installation

```bash
npm install diy-log --save-dev
```



## Usage

```js
// for cjs
const logger = require('diy-log')
const { log, symbols, colors, tag } = logger


// for esm
import logger, {
  log,
  colors,
  symbols,
  tag
} from 'diy-log'
```

```js
time('time ...')

info('info ...')
done('done ...')
error('error ...')
warn('warn ...')

log(symbols.info, 'info ...')
log(symbols.done, 'done ...')
log(symbols.error, 'error ...')
log(symbols.warn, 'warn ...')


log(colors.dim('dim:text;'))
log(colors.blue('color: blue;'))
log(colors.bgGreen('bgcolor: green;'))
log(colors.bold('bold:text;'))
log(colors.italic('italic:text;'))
log(colors.underline('underline:text;'))


tag('info message')
tag('success message', 'done', 'success')
tag.warn('warning message')
tag.done('done message')
tag.info(colors.blue('info message'))
tag.error('error message')
```

## Methods

```ts
type Log = (...args: any[]) => void

type TagType = (message: string, label?: string) => void

interface Tag {
  (message: string, tag: 'info' | 'error' | 'done' | 'warn' = 'info', label?: string): void
  info: TagType
  error: TagType
  done: TagType
  warn: TagType
}
```

- `log`: Log;
- `time`: Log;
- `info`: Log;
- `error`: Log;
- `done`: Log;
- `warn`: Log;
- `tag`: Tag;
- `tag.info`: TagType;
- `tag.error`: TagType;
- `tag.done`: TagType;
- `tag.warn`: TagType;


## Thanks

[log-symbols](https://github.com/sindresorhus/log-symbols) , [picocolors](https://github.com/alexeyraspopov/picocolors) , [time-stamp](https://github.com/jonschlinkert/time-stamp)

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