https://github.com/marinerer/diy-log
🌈 Various console log level prefixes with support for color symbols and tags. 📟 自定义控制台各种级别日志输出的前缀,支持颜色符号,标签和时间。
https://github.com/marinerer/diy-log
console log log-symbols logger logging terminal
Last synced: 5 months ago
JSON representation
🌈 Various console log level prefixes with support for color symbols and tags. 📟 自定义控制台各种级别日志输出的前缀,支持颜色符号,标签和时间。
- Host: GitHub
- URL: https://github.com/marinerer/diy-log
- Owner: Marinerer
- Created: 2018-12-14T09:24:04.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-11-28T05:03:46.000Z (over 1 year ago)
- Last Synced: 2025-10-06T01:57:07.656Z (9 months ago)
- Topics: console, log, log-symbols, logger, logging, terminal
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/diy-log
- Size: 135 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# diy-log 🌈
[](https://www.npmjs.com/package/diy-log)
[](https://codecov.io/gh/Marinerer/diy-log)
[](https://github.com/Marinerer/pipflow/releases)
[](https://nodejs.org/en/about/releases/)
[](https://github.com/Marinerer/diy-log)
[](https://www.npmjs.com/package/diy-log)
> Various console log level prefixes with support for color symbols and tags.
自定义控制台各种级别日志输出的前缀,支持颜色符号,标签和时间。

## 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)