Skip to content

Commit

Permalink
[Fix] CLI flag parsing (#2)
Browse files Browse the repository at this point in the history
* Ensure flags are parsed and merged with other config methods

* Update readme section on configuration

* Bump patch version
  • Loading branch information
dnjstrom authored Feb 9, 2021
1 parent e184995 commit 0ba0111
Show file tree
Hide file tree
Showing 9 changed files with 1,690 additions and 3,199 deletions.
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# pino-dev

A simple prettifier for [pino](https://github.com/pinojs/pino) with built-in support for common ecosystem packages. Designed to be clear, unintrusive and to the point with sensible defaults optimized for use during development.
A simple prettifier for [pino](https://github.com/pinojs/pino) with built-in support for common ecosystem packages. Designed to be clear, unintrusive and to the point with sensible defaults optimized for use during development.

![Screenshot](https://github.com/dnjstrom/pino-dev/blob/main/screenshot.png?raw=true)

## Supported packages

* [pino](https://github.com/pinojs/pino)
* [pino-debug](https://github.com/pinojs/pino-debug)
* [pino-http](https://github.com/pinojs/pino-http)
- [pino](https://github.com/pinojs/pino)
- [pino-debug](https://github.com/pinojs/pino-debug)
- [pino-http](https://github.com/pinojs/pino-http)

Is your favorite pino package not yet supported? Request support [here](https://github.com/dnjstrom/pino-dev/issues/new).


## Issues

Discovered a problem with pino-dev? [Report an issue](https://github.com/dnjstrom/pino-dev/issues/new).

## Quickstart

Install using one of the commands below

```bash
npm install --save-dev pino-dev
yarn add --dev pino-dev
Expand All @@ -32,25 +32,27 @@ then pipe the output of your `pino`-enhanced app to the `pino-dev` cli
```

Often it's convenient to add this to your package.json scripts to not have to remember it.

```json
{
"scripts": {
"dev": "./start-your-app | pino-dev"
}
"dev": "./start-your-app | pino-dev"
}
}
```

In some situations using `npx` can also be really convenient:

```bash
yarn start | npx pino-dev
```
```

## Configuration

Configuration is preferably stored as a `pino-dev.config.json` or `pino-dev.config.js` file at the root of your repo. It's also possible to use a `"pino-dev": {...}` key in your `package.json`.

### Default config

```json
{
"newline": "\n",
Expand All @@ -74,32 +76,30 @@ Configuration is preferably stored as a `pino-dev.config.json` or `pino-dev.conf

The newline character used in prettified output. Usually dependent on your operating system, it's either "\n" (default) or "\r\n".

#### time-format
#### time-format

The time format to use (syntax according to https://www.npmjs.com/package/date-fns).

#### propertyMap

This configuration allows you to map arbitrary incoming properties to semantic pino-dev properties using json. For instance,

```echo '{"message": "foobar"}' | pino-dev --property-map '{"msg": "message"}'```
`echo '{"message": "foobar"}' | pino-dev --property-map '{"msg": "message"}'`

would map the `message` property in the incoming json to the semantic property `msg` which enables `pino-dev` to understand how to format the log. For deep properties it's possible to use dot-notation, and mapping to a boolean `false` will disable the default mapping (e.g. `pino-dev --property-map '{"name": false}'` won't display the name in the prettified output).


### Command line arguments

It's also possible to specify/override configuration with command-line arguments:

```
Usage: pino-dev [options]
--color Force color.
-h, --help Output usage information
-n, --newline The newline character used in prettified output. Either "\n" (default) or "\r\n".
--no-color Force no color.
-m, --property-map Map arbitrary incoming properties to semantic pino-dev properties using json.
-t, --time-format The time format to use (syntax according to https://www.npmjs.com/package/date-fns).
-v, --version Output the version number
Usage: pino-dev [options]
--, --color Force color.
-h, --help Output usage information
-n, --newline The newline character used in prettified output. Either "\n" (default) or "\r\n".
--, --no-color Force no color.
-m, --property-map Map arbitrary incoming properties to semantic pino-dev properties using json.
-t, --time-format The time format to use (syntax according to https://www.npmjs.com/package/date-fns).
-v, --version Output the version number
```

Loading

0 comments on commit 0ba0111

Please sign in to comment.