Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e607925
Quick commit
MechanicalHuman Jan 29, 2019
e6a2b22
Quick commit
MechanicalHuman Jan 30, 2019
5cc5f94
Merge branch 'master' into pulp
MechanicalHuman Jan 30, 2019
8690ec5
Quick commit
MechanicalHuman Feb 4, 2019
c5dc040
feat: Aligned to Pino api
MechanicalHuman Feb 7, 2019
526e4a0
fix: httpFormatter invocation
MechanicalHuman Feb 7, 2019
55bc6de
chore: Depencency cleanup
MechanicalHuman Feb 7, 2019
38ff52a
chore(release): 2.0.8
MechanicalHuman Feb 7, 2019
240962d
Merge branch 'pulp'
MechanicalHuman Feb 7, 2019
527404b
chore(release): 2.1.0
MechanicalHuman Feb 7, 2019
98754f3
chore: package-lock.json
MechanicalHuman Feb 7, 2019
4dfdf0f
chore(release): 2.1.1
MechanicalHuman Feb 7, 2019
b8e0942
fix: corrected bin/pretty path
MechanicalHuman Feb 21, 2019
2f5c94a
chore(release): 2.1.2
MechanicalHuman Feb 21, 2019
1506ec5
Update CHANGELOG.md
MechanicalHuman Feb 21, 2019
aa48e3e
fix: Minor Documentation fixes
MechanicalHuman Feb 22, 2019
7975d32
style: Passing lint rules.
MechanicalHuman Feb 22, 2019
019a17f
fix: returning Writable Stream
MechanicalHuman Feb 22, 2019
88b9f2e
Added tests
MechanicalHuman Feb 22, 2019
01370de
chore(release): 2.2.0
MechanicalHuman Feb 22, 2019
49026e3
test: http tests
MechanicalHuman Feb 26, 2019
1493ca5
feat: exporting default config
MechanicalHuman Feb 26, 2019
da9a881
fix: Http formater reports propper response times
MechanicalHuman Feb 26, 2019
fe3dba2
chore(release): 2.3.0
MechanicalHuman Feb 26, 2019
98d775e
Update head-formatter.js
numso Aug 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ root = true

[*]
indent_style = space
indent_size = 4
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
Expand All @@ -11,5 +11,3 @@ insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

[*.{js,json}]
indent_size = 2
9 changes: 0 additions & 9 deletions .eslintrc.js

This file was deleted.

20 changes: 20 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "hnp",
"rules": {
"lodash-fp/use-fp": "warn",
"lodash-fp/no-chain": "warn",
"lodash-fp/consistent-name": "off",
"header/header": [
2,
"block",
[
"!",
{
"pattern": " \\* Copyright \\d{4} Jorge Proaño.",
"template": " * Copyright 2019 Jorge Proaño."
},
" "
]
]
}
}
5 changes: 0 additions & 5 deletions .lintstagedrc

This file was deleted.

1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

9 changes: 4 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"files.exclude": {
"**/node_modules": true,
"**/*.sublime-workspace": true
},
"eslint.enable": true,
"editor.formatOnSave": true,
"prettier.eslintIntegration": true
"prettier.eslintIntegration": true,
"prettier.tslintIntegration": true,
"cSpell.words": ["ipaddr"],
"npm-intellisense.importES6": false
}
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Jorge Proaño <jorge@hiddennodeproblem.com>
Jorge Proaño <jorge@hiddennodeproblem.com>
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Change Log

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="2.3.0"></a>
# [2.3.0](https://github.com/MechanicalHuman/dev-bunyan-pretty/compare/v2.1.2...v2.3.0) (2019-02-26)


### Bug Fixes

* Http formater reports propper response times ([da9a881](https://github.com/MechanicalHuman/dev-bunyan-pretty/commit/da9a881))
* Minor Documentation fixes ([aa48e3e](https://github.com/MechanicalHuman/dev-bunyan-pretty/commit/aa48e3e))
* returning Writable Stream ([019a17f](https://github.com/MechanicalHuman/dev-bunyan-pretty/commit/019a17f))


### Features

* exporting default config ([1493ca5](https://github.com/MechanicalHuman/dev-bunyan-pretty/commit/1493ca5))



<a name="2.2.0"></a>

# [2.2.0](https://github.com/MechanicalHuman/dev-bunyan-pretty/compare/v2.1.2...v2.2.0) (2019-02-22)

### Bug Fixes

- Minor Documentation fixes ([aa48e3e](https://github.com/MechanicalHuman/dev-bunyan-pretty/commit/aa48e3e))
- returning Writable Stream ([019a17f](https://github.com/MechanicalHuman/dev-bunyan-pretty/commit/019a17f))

<a name="2.1.2"></a>

## [2.1.2](https://github.com/MechanicalHuman/dev-bunyan-pretty/compare/v2.1.1...v2.1.2) (2019-02-21)

### Bug Fixes

- corrected bin/pretty path ([b8e0942](https://github.com/MechanicalHuman/dev-bunyan-pretty/commit/b8e0942)), closes [#1](https://github.com/MechanicalHuman/dev-bunyan-pretty/issues/1)

<a name="2.1.0"></a>

## [2.1.0](https://github.com/MechanicalHuman/dev-bunyan-pretty/compare/v2.0.8...v2.1.0) (2019-02-07)

### Bug Fixes

- httpFormatter invocation ([526e4a0](https://github.com/MechanicalHuman/dev-bunyan-pretty/commit/526e4a0))

### Features

- Aligned to Pino api ([c5dc040](https://github.com/MechanicalHuman/dev-bunyan-pretty/commit/c5dc040))
12 changes: 6 additions & 6 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License
The MIT License (MIT)

Copyright (c) 2018 Jorge Proaño
Copyright (c) 2019 Jorge Proaño

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
118 changes: 63 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,62 @@
<!-- TITLE/ -->
# @mechanicalhuman/bunyan-pretty

<h1>@mechanicalhuman/bunyan-pretty</h1>
![hero image](https://raw.githubusercontent.com/MechanicalHuman/dev-bunyan-pretty/master/img/pretty-nostamps.png)

<!-- /TITLE -->
> Prettifies NDJSON (Newline Delimited JSON) logs, like \`bunyan -o short\` but actually pretty.

<!-- DESCRIPTION/ -->
---

Prettifies NDJSON (Newline Delimited JSON) logs, like `bunyan -o short` but actually pretty.
## Table of Contents

<!-- /DESCRIPTION -->
- [Installation](#installation)

![hero image](https://raw.githubusercontent.com/MechanicalHuman/dev-bunyan-pretty/master/img/pretty-nostamps.png)
- [Usage](#usage)

- [Advanced Usage](#advanced-usage)

- [Programatic Interface](#programatic-interface)

- [Options](#options)

- [Example](#example)

<!-- INSTALL/ -->
- [Changelog](#changelog)

<h2>Install</h2>
- [Maintainers](#maintainers)

<a href="https://npmjs.com" title="npm is a package manager for javascript"><h3>NPM</h3></a><ul>
- [License](#license)

<li>Install: <code>npm install --save @mechanicalhuman/bunyan-pretty</code></li>
<li>Executable: <code>pretty</code></li>
<li>Module: <code>require('@mechanicalhuman/bunyan-pretty')</code></li></ul>
## Installation

<!-- /INSTALL -->
```sh
npm install @mechanicalhuman/bunyan-pretty
```

## Usage

The tool reads from the `STDIN` and is installed as the cmd `pretty` in the shell.

- You can pipe it to the output of a running application:
- You can pipe it to the output of a running application:

```sh
node index.js | pretty [OPTIONS]
```
```sh
node index.js | pretty [OPTIONS]
```

- Or just feed it an already existing file.
- Or just feed it an already existing file.

```sh
pretty [OPTIONS] < input.log
```
```sh
pretty [OPTIONS] < input.log
```

## Options
### Advanced Usage

```txt
pretty --help
___

Usage: ... | pretty [options]

Time Staps
Time Stamps
--time-stamps Print TimeStamps. [boolean][default: true]
--stamps-format, -f TimeStamps format. [YYYY-MM-DD-HH:mm:ss]
--stamps-time-zone, --tz TimeStamps zone offset. [default: "Etc/UTC"]
Expand All @@ -63,15 +72,18 @@ The tool reads from the `STDIN` and is installed as the cmd `pretty` in the shel

Other
--force-color Force color output [boolean][default: false]
```

#### Notes:
![stamps](img/pretty-stamps.png)

- The`boolean` options can be set false using `--no-option`. Example: `--no-time-stamps`
- The`--level` choices are: "trace", "debug", "info", "error", "warn", "fatal"
- The`--stamps-format` value is passed directly to [`moment.format()`](https://momentjs.com/docs/#/displaying/format/)
- You force the colored output using the env variable: `FORCE_COLOR=1`
- You can pass the time stamps zone offset via the env variable: `PRETTY_TZ`
- You can pass the time stamps format via the env variable: `PRETTY_STAMPS_FORMAT`
Notes:

- The`boolean` options can be set false using `--no-option`. Example: `--no-time-stamps`
- The`--level` choices are: "trace", "debug", "info", "error", "warn", "fatal"
- The`--stamps-format` value is passed directly to [`moment.format()`](https://momentjs.com/docs/#/displaying/format/)
- You force the colored output using the env variable: `FORCE_COLOR=1`
- You can pass the time stamps zone offset via the env variable: `PRETTY_TZ`
- You can pass the time stamps format via the env variable: `PRETTY_STAMPS_FORMAT`

## Programatic Interface

Expand All @@ -90,54 +102,50 @@ You can use pretty as a writable stream from inside your NodeJS scripts. Probabl
const pretty = require('@mechanicalhuman/bunyan-pretty')
```

### Default Options:
## Options

The options object passed to `pretty` will merge with the default options.

```js
const defaultOptions = {
level: 0, // Named level or bunyan/pino level value
strict: false,
level: 'trace', // Only print messages >= level.
strict: false, // Only print valid pino/bunyan logs

forceColor: false
termColors: false, // trust the term colors, not the stream ones
colorLevel: 2 // based on your terminal (uses supports-color)
colorize: chalk.supportsColor !== false,

depth: 4,
maxArrayLength: 100,
depth: 4, // (passed to util.inspect)
maxArrayLength: 100, // (passed to util.inspect)

printHost: false,
timeStamps: true,
stampsFormat: 'YYYY-MM-DD-HH:mm:ss',
stampsTimeZone: moment.tz.guess(), // Based on your Locale
printHost: false, // Print Host.
timeStamps: true, // Print TimeStamps.
stampsFormat: 'YYYY-MM-DD-HH:mm:ss',
stampsTimeZone: moment.tz.guess() // TimeStamps zone offset (Based on your Locale)
}
```

### Example:
## Example

```js
const pretty = require('@mechanicalhuman/bunyan-pretty')
const bunyan = require('bunyan')

const log = bunyan.createLogger({
name: 'myapp',
stream: pretty(process.stdout, { timeStamps: false }),
level: 'info'
name: 'app',
stream: pretty(process.stdout, { timeStamps: false }),
level: 'info'
})

log.info('hello world')
```

<!-- LICENSE/ -->

<h2>License</h2>
## Changelog

Unless stated otherwise all works are:
Find the CHANGELOG [here](CHANGELOG.md), generated using Conventional Commits.

<ul><li>Copyright &copy; <a href="http://www.hidden-node-problem.com">Jorge Proaño</a></li></ul>
## Maintainers

and licensed under:
- [Jorge Proaño](mailto:jorge@hiddennodeproblem.com)

<ul><li><a href="http://spdx.org/licenses/MIT.html">MIT License</a></li></ul>
## License

<!-- /LICENSE -->
[MIT](LICENSE) © [Jorge Proaño](http://www.hidden-node-problem.com)
9 changes: 6 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
### TODOs

| Filename | line # | TODO |
| :------------------------------------------- | :----: | :------------------------------------ |
| [lib/utils/Stack.js](lib/utils/Stack.js#L31) | 31 | Make GetStack() Function less complex |
| Filename | line # | TODO |
| :----------------------------------------------------------------------- | :----: | :------------------------------------ |
| [lib/formatters/http-formatter.js](lib/formatters/http-formatter.js#L17) | 17 | Use fp.getOr instead of lo.get |
| [lib/formatters/keys-formatter.js](lib/formatters/keys-formatter.js#L17) | 17 | Refactor to use lodash/fp |
| [lib/formatters/keys-formatter.js](lib/formatters/keys-formatter.js#L66) | 66 | Refactor indent to use lodash/fp |
| [lib/utils/Stack.js](lib/utils/Stack.js#L27) | 27 | Make GetStack() Function less complex |
Loading