Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Plain ndjson #58

Merged
merged 34 commits into from Apr 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2b0fcc3
Replace fast-json-parse
jsumners Mar 30, 2019
6e7bf6b
Initial refactor to generic ndjson prettifier
jsumners Mar 30, 2019
20e9107
Merge branch 'master' into plain-ndjson
jsumners Mar 30, 2019
b16e208
Improve support for primitives
jsumners Mar 30, 2019
7a32b52
Move line joiner to utils and apply standard formatting
jsumners Mar 30, 2019
a1cd48c
Move object prettification to utils function
jsumners Mar 31, 2019
ccd2848
Fix split in prettifyObject
jsumners Mar 31, 2019
bf02c96
Move "error" log prettification into utility function
jsumners Mar 31, 2019
572226d
Add support for string levels
jsumners Mar 31, 2019
dd5f386
Add "timestamp" as possible time key
jsumners Mar 31, 2019
64db81d
v3.0.0-rc.1
jsumners Mar 31, 2019
7ef851c
Remove Node 6 from Travis config
jsumners Apr 6, 2019
413d1d2
Add tests for utils.formatTime
jsumners Apr 6, 2019
fda9682
Fix lint issue
jsumners Apr 6, 2019
55e5eab
Add tests for colors.js
jsumners Apr 6, 2019
11c42cc
Add docblock for joinLinesWithIndentation
jsumners Apr 6, 2019
6ebee3c
Add tests for prettifyLevel
jsumners Apr 7, 2019
42e5bc7
Add tests for prettifyMessage
jsumners Apr 7, 2019
438f8fb
Add tests for prettifyTime
jsumners Apr 7, 2019
8bed001
Fix lint error
jsumners Apr 9, 2019
20d9a05
Pino seems to have changed order of some properties in the log. 🤷‍♂️
jsumners Apr 9, 2019
ca7767e
Fix regex for time tests
jsumners Apr 9, 2019
ff3cb0e
Remove Node 12 until release
jsumners Apr 9, 2019
9a997e2
Add tests for prettifyMetadata
jsumners Apr 9, 2019
87b65bf
Added tests (#59)
ovhemert Apr 11, 2019
613d250
Improve prettifyObject test and add docblock
jsumners Apr 13, 2019
b08e946
Add docblock for prettifyErrorLog
jsumners Apr 13, 2019
e5b2176
Update readme
jsumners Apr 13, 2019
af3e853
Update dependencies
jsumners Apr 13, 2019
410c1e8
v3.0.0-rc.2
jsumners Apr 21, 2019
6c38b01
Merge branch 'master' into plain-ndjson
jsumners Apr 21, 2019
1635a78
Remove Node 6 specific tests
jsumners Apr 28, 2019
6c78469
Add back Node 12 to test suite
jsumners Apr 28, 2019
e22b11a
Fix tests for Node 12
jsumners Apr 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
@@ -1,10 +1,9 @@
language: node_js

node_js:
- "11"
- "12"
- "10"
- "8"
- "6"

# before_install:
# - curl -L https://unpkg.com/@pnpm/self-installer | node
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2018 the Pino team
Copyright (c) 2019 the Pino team

Pino team listed at https://github.com/pinojs/pino#the-team

Expand Down
56 changes: 30 additions & 26 deletions Readme.md
@@ -1,16 +1,21 @@
<a id="intro"></a>
# pino-pretty

[![Build Status](https://travis-ci.org/pinojs/pino-pretty.svg?branch=master)](https://travis-ci.org/pinojs/pino-pretty)
[![Coverage Status](https://coveralls.io/repos/github/pinojs/pino-pretty/badge.svg?branch=master)](https://coveralls.io/github/pinojs/pino-pretty?branch=master)

This module provides a basic log prettifier for the [Pino](https://getpino.io/)
logging library. It reads a standard Pino log line like:
This module provides a basic [ndjson](http://ndjson.org/) formatter. If an
incoming line looks like it could be a log line from an ndjson logger, in
particular the [Pino](https://getpino.io/) logging library, then it will apply
extra formatting by considering things like the log level and timestamp.

A standard Pino log line like:

```
{"level":30,"time":1522431328992,"msg":"hello world","pid":42,"hostname":"foo","v":1}
```

And formats it to:
Will format to:

```
[1522431328992] INFO (42 on foo): hello world
Expand All @@ -34,12 +39,11 @@ prettified logs will look like:
$ npm install -g pino-pretty
```


<a id="usage"></a>
## Usage

It's recommended to use `pino-pretty` with `pino`
by piping output to the CLI tool:
It's recommended to use `pino-pretty` with `pino`
by piping output to the CLI tool:

```sh
pino app.js | pino-pretty
Expand All @@ -48,38 +52,38 @@ pino app.js | pino-pretty
<a id="cliargs"></a>
### CLI Arguments

+ `--colorize` (`-c`): Adds terminal color escape sequences to the output.
+ `--crlf` (`-f`): Appends carriage return and line feed, instead of just a line
feed, to the formatted log line.
+ `--errorProps` (`-e`): When formatting an error object, display this list
of properties. The list should be a comma separated list of properties Default: `''`.
+ `--levelFirst` (`-l`): Display the log level name before the logged date and time.
+ `--errorLikeObjectKeys` (`-k`): Define the log keys that are associated with
error like objects. Default: `err,error`.
+ `--messageKey` (`-m`): Define the key that contains the main log message.
Default: `msg`.
+ `--translateTime` (`-t`): Translate the epoch time value into a human readable
date and time string. This flag also can set the format string to apply when
translating the date to human readable format. For a list of available pattern
letters see the [`dateformat` documentation](https://www.npmjs.com/package/dateformat).
- `--colorize` (`-c`): Adds terminal color escape sequences to the output.
- `--crlf` (`-f`): Appends carriage return and line feed, instead of just a line
feed, to the formatted log line.
- `--errorProps` (`-e`): When formatting an error object, display this list
of properties. The list should be a comma separated list of properties Default: `''`.
- `--levelFirst` (`-l`): Display the log level name before the logged date and time.
- `--errorLikeObjectKeys` (`-k`): Define the log keys that are associated with
error like objects. Default: `err,error`.
- `--messageKey` (`-m`): Define the key that contains the main log message.
Default: `msg`.
- `--translateTime` (`-t`): Translate the epoch time value into a human readable
date and time string. This flag also can set the format string to apply when
translating the date to human readable format. For a list of available pattern
letters see the [`dateformat` documentation](https://www.npmjs.com/package/dateformat).
- The default format is `yyyy-mm-dd HH:MM:ss.l o` in UTC.
- Require a `SYS:` prefix to translate time to the local system's timezone. A
shortcut `SYS:standard` to translate time to `yyyy-mm-dd HH:MM:ss.l o` in
system timezone.
+ `--search` (`-s`): Specify a search pattern according to
- `--search` (`-s`): Specify a search pattern according to
[jmespath](http://jmespath.org/).
+ `--ignore` (`-i`): Ignore one or several keys: (`-i time,hostname`)
- `--ignore` (`-i`): Ignore one or several keys: (`-i time,hostname`)

<a id="integration"></a>
## Programmatic Integration
## Programmatic Integration

We recommend against using `pino-pretty` in production, and highly
recommend installing `pino-pretty` as a development dependency.

When installed, `pino-pretty` will be used by `pino` as the default
When installed, `pino-pretty` will be used by `pino` as the default
prettifier.

Install `pino-pretty` alongside `pino` and set the
Install `pino-pretty` alongside `pino` and set the
`prettyPrint` option to `true`:

```js
Expand Down Expand Up @@ -109,7 +113,7 @@ See the [Options](#options) section for all possible options.
### Options

`pino-pretty` exports a factory function that can be used to format log strings.
This factory function is used internally by pino, and accepts an options argument
This factory function is used internally by Pino, and accepts an options argument
with keys corresponding to the options described in [CLI Arguments](#cliargs):

```js
Expand Down