Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/webpack-contrib/webpack-log

[DEPRECATED] Please use logger API https://github.com/webpack/webpack/pull/9436
https://github.com/webpack-contrib/webpack-log

log logger logging webpack

Last synced: 4 days ago
JSON representation

[DEPRECATED] Please use logger API https://github.com/webpack/webpack/pull/9436

Awesome Lists containing this project

README

        

[DEPRECATED] Plese use logger api https://github.com/webpack/webpack/pull/9436

[![npm][npm]][npm-url]
[![node][node]][node-url]
[![deps][deps]][deps-url]
[![test][test]][test-url]
[![coverage][cover]][cover-url]
[![chat][chat]][chat-url]






webpack Log


A common logging module for the webpack ecosystem


## Install

```bash
npm i -D webpack-log
```

> ⚠️ We do not recommend installing this module globally

## Usage

```js
const log = require('webpack-log');
const logger = log({ name: 'wds' });

logger.info('Server Starting');
```

![output](docs/output.png)

> ℹ️ The logger returned is unique by default, due to the nature of the `webpack` ecosystem. Please reference the [`unique`](#unique) option below for disabling this feature and to **force caching**

## Options

| Name | Type | Default | Description |
| :---------------------------: | :---------: | :------------: | :---------------------- |
| [**`name`**](#name) | `{String}` | `'''` | Log Name (**Required**) |
| [**`level`**](#level) | `{String}` | `'info'` | Log Level |
| [**`unique`**](#unique) | `{Boolean}` | `true` | Log Uniqueness |
| [**`timestamp`**](#timestamp) | `{Boolean}` | `false` | Log Timestamps |

### `name`

Specifies the name of the log to create. **This option is required**, and used to differentiate between loggers when `webpack-log` is used in multiple projects
executing in the same process

```js
const logger = log({ name: 'wds' });
```

### `level`

Specifies the level the logger should use. A logger will not produce output for
any log level _beneath_ the specified level. Available levels and order are:

```js
['info', 'warn', 'error', 'trace', 'debug', 'silent'];
```

```js
const logger = log({ level: 'error' });

logger.error(err);
```

> ℹ️ The level names shown above correspond to the available logging methods,
> with the notable exception of the `silent` level

### `unique`

If `false`, instructs the logger to used cached versions of a log with the same name. Due to the nature of the `webpack` ecosystem and multiple plugin/loader usage in the same process, loggers are created as unique instances by default. By passing `false` for this property, the module is instructed to cache the requested logger

```js
const logger = log({ unique: true });
```

### `timestamp`

If `true`, instructs the logger to display a timestamp for log output, preceding
all other data

```js
const logger = log({ timestamp: true });
```

[npm]: https://img.shields.io/npm/v/webpack-log.svg
[npm-url]: https://npmjs.com/package/webpack-log
[node]: https://img.shields.io/node/v/webpack-log.svg
[node-url]: https://nodejs.org
[deps]: https://david-dm.org/webpack-contrib/webpack-log.svg
[deps-url]: https://david-dm.org/webpack-contrib/webpack-log
[test]: http://img.shields.io/travis/webpack-contrib/webpack-log.svg
[test-url]: https://travis-ci.org/webpack-contrib/webpack-log
[cover]: https://codecov.io/gh/webpack-contrib/webpack-log/branch/master/graph/badge.svg
[cover-url]: https://codecov.io/gh/webpack-contrib/webpack-log
[chat]: https://badges.gitter.im/webpack/webpack.svg
[chat-url]: https://gitter.im/webpack/webpack