# @rcp/util.createlogger

> Create namespace isomorphic logger

Latest version **2.0.0** (published 2024-02-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rcp/util.createlogger
pnpm add @rcp/util.createlogger
yarn add @rcp/util.createlogger
bun add @rcp/util.createlogger
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2024-02-27 |
| First published | 2018-09-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 2 |
| Unpacked size | 24 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | imcuttle |
| Maintainers | moyuyc |
| Keywords | imcuttle, logger, namespace, isomorphic |

## Links

- npm: https://www.npmjs.com/package/@rcp/util.createlogger
- Repository: https://github.com/imcuttle/rcp
- Homepage: https://github.com/imcuttle/rcp#readme
- Issues: https://github.com/imcuttle/rcp/issues
- npm.io page: https://npm.io/package/@rcp/util.createlogger

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^3.1.0
- [log-symbols](https://npm.io/package/log-symbols.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.0.0 (latest) — 2024-02-27
- 1.1.7 — 2021-09-29
- 1.1.6 — 2020-11-19
- 1.1.5 — 2020-11-19
- 1.1.4 — 2020-07-04
- 1.1.2 — 2020-04-13
- 1.1.1 — 2019-04-16
- 1.1.0 — 2018-09-16
- 1.0.9 — 2018-09-16
- 1.0.8 — 2018-09-14
- 1.0.7 — 2018-09-08
- 1.0.6 — 2018-09-08
- 1.0.5 — 2018-09-07

## README

# @rcp/util.createlogger

[![NPM version](https://img.shields.io/npm/v/@rcp/util.createlogger.svg?style=flat-square)](https://www.npmjs.com/package/@rcp/util.createlogger)
[![NPM Downloads](https://img.shields.io/npm/dm/@rcp/util.createlogger.svg?style=flat-square&maxAge=43200)](https://www.npmjs.com/package/@rcp/util.createlogger)

The internal about common isomorphic logger with namespace.

## Installation

```bash
npm install @rcp/util.createlogger
# or use yarn
yarn add @rcp/util.createlogger
```

## Usage

```javascript
import createLogger from '@rcp/util.createlogger'
const logger = createLogger('@rcp/hoc.i18n')

logger.info('%s abc', 'ok') // alias `log`
logger.success({ a: '222' }, 'ok')
logger.warn({})
logger.debug()
logger.error()
logger.invariant(typeof document !== 'undefined', 'the library should be used in browser environment.')
```

## API

### `createLogger(namespace?: string, opts)`

#### Parameters

##### `namespace`

The namespace of logger.

##### `opts`

- **prefix**: (default: `'('`)

- **suffix**: (default: `')'`)

- **typeMap**: eg

  ```
  {
    Log: "I'm a Log",
    Success: "Wow!",
    Warning: "Warn!",
    Error: "Error happened",
  }
  ```

The formatted string are composed by `{type}{prefix}{namespace}{suffix}: {message}`.

e.g. `Success(foo): Done!`

#### Returns

##### `info`: (alias: `log`)

- Type: `function`

##### `success`

- Type: `function`

##### `warn`

- Type: `function`

##### `debug`

- Type: `function`

##### `error`

- Type: `function`

##### `invariant`

It will throw Error with `message` when `check` is false

- Type: `(check: boolean, message?: string) => void`

## Related

## Authors

This library is written and maintained by imcuttle, <mailto:moyuyc95@gmail.com>.

## License

MIT

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