Skip to content

Commit

Permalink
Merge branch 'pinojs:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfranca committed Jun 22, 2022
2 parents 1d46ccd + ca8a85b commit d28c98c
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 75 deletions.
43 changes: 35 additions & 8 deletions .github/workflows/ci.yml
Expand Up @@ -10,8 +10,29 @@ on:
- 'docs/**'
- '*.md'

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

jobs:
build:
dependency-review:
name: Dependency Review
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out repo
uses: actions/checkout@v3
with:
persist-credentials: false

- name: Dependency review
uses: actions/dependency-review-action@v1

test:
name: Test
runs-on: ${{ matrix.os }}
outputs:
COVERALLS: ${{ steps.coveralls-trigger.outputs.COVERALLS_TRIGGER }}
Expand All @@ -22,10 +43,12 @@ jobs:
node-version: [14, 16, 18]
os: [ubuntu-latest]
steps:
- name: Checkout
- name: Check out repo
uses: actions/checkout@v3
with:
persist-credentials: false

- name: Use Node.js
- name: Setup Node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
Expand All @@ -37,9 +60,9 @@ jobs:
key: node-modules-${{ hashFiles('package.json') }}

- name: Install dependencies
run: npm install
run: npm i --ignore-scripts

- name: Run Tests
- name: Run tests
run: npm run ci

- name: Coveralls Parallel
Expand All @@ -60,7 +83,7 @@ jobs:
echo "::set-output name=COVERALLS_TRIGGER::failure"
coverage:
needs: build
needs: test
runs-on: ubuntu-latest
if: needs.test.outputs.COVERALLS != 'failure'
steps:
Expand All @@ -71,11 +94,15 @@ jobs:
parallel-finished: true

automerge:
needs: build
runs-on: ubuntu-latest
name: Automerge Dependabot PRs
if: >
github.event_name == 'pull_request' &&
github.event.pull_request.user.login == 'dependabot[bot]'
needs: test
permissions:
pull-requests: write
contents: write
runs-on: ubuntu-latest
steps:
- uses: fastify/github-action-merge-dependabot@v3
with:
Expand Down
139 changes: 116 additions & 23 deletions .gitignore
@@ -1,59 +1,152 @@
# Lock files
shrinkwrap.yaml
package-lock.json
yarn.lock
pnpm-lock.yaml

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directory
node_modules
# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# 0x
.__browserify_string_empty.js
profile-*
*.flamegraph
# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# tap --cov
.nyc_output/
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# JetBrains IntelliJ IDEA
.idea/
*.iml
# vuepress build output
.vuepress/dist

# VS Code
.vscode/
# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# Vim swap files
*.swp

# macOS files
.DS_Store

# editor files
.vscode
.idea

# lock files
package-lock.json
pnpm-lock.yaml
yarn.lock

# 0x
.__browserify*
profile-*

# Run Configuration
test/.tmp*

*.tgz
5 changes: 2 additions & 3 deletions Readme.md
Expand Up @@ -3,7 +3,6 @@

[![NPM Package Version](https://img.shields.io/npm/v/pino-pretty)](https://www.npmjs.com/package/pino-pretty)
[![Build Status](https://img.shields.io/github/workflow/status/pinojs/pino-pretty/CI)](https://github.com/pinojs/pino-pretty/actions?query=workflow%3ACI)
[![Known Vulnerabilities](https://snyk.io/test/github/pinojs/pino-pretty/badge.svg)](https://snyk.io/test/github/pinojs/pino-pretty)
[![Coverage Status](https://img.shields.io/coveralls/github/pinojs/pino-pretty)](https://coveralls.io/github/pinojs/pino-pretty?branch=master)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)

Expand Down Expand Up @@ -77,7 +76,7 @@ node app.js | pino-pretty
- `--customLevels` (`-x`): Override default levels with custom levels, e.g. `-x err:99,info:1`
- `--customColors` (`-X`): Override default colors with custom colors, e.g. `-X err:red,info:blue`
- `--useOnlyCustomProps` (`-U`): Only use custom levels and colors (if provided) (default: true); else fallback to default levels and colors, e.g. `-U false`
- `--messageFormat` (`-o`): Format output of message, e.g. `{levelLabel} - {pid} - url:{request.url}` will output message: `INFO - 1123 - url:localhost:3000/test`
- `--messageFormat` (`-o`): Format output of message, e.g. `{levelLabel} - {pid} - url:{req.url}` will output message: `INFO - 1123 - url:localhost:3000/test`
Default: `false`
- `--timestampKey` (`-a`): Define the key that contains the log timestamp.
Default: `time`.
Expand Down Expand Up @@ -327,7 +326,7 @@ const levelPrettifier = logLevel => `LEVEL: ${levelColorize(logLevel)}`

```js
{
messageFormat: '{levelLabel} - {pid} - url:{request.url}'
messageFormat: '{levelLabel} - {pid} - url:{req.url}'
}
```

Expand Down
42 changes: 21 additions & 21 deletions index.js
Expand Up @@ -62,40 +62,40 @@ function prettyFactory (options) {
const useOnlyCustomProps = typeof opts.useOnlyCustomProps === 'boolean' ? opts.useOnlyCustomProps : opts.useOnlyCustomProps === 'true'
const customLevels = opts.customLevels
? opts.customLevels
.split(',')
.reduce((agg, value, idx) => {
const [levelName, levelIdx = idx] = value.split(':')
.split(',')
.reduce((agg, value, idx) => {
const [levelName, levelIdx = idx] = value.split(':')

agg[levelIdx] = levelName.toUpperCase()
agg[levelIdx] = levelName.toUpperCase()

return agg
}, { default: 'USERLVL' })
return agg
}, { default: 'USERLVL' })
: {}
const customLevelNames = opts.customLevels
? opts.customLevels
.split(',')
.reduce((agg, value, idx) => {
const [levelName, levelIdx = idx] = value.split(':')
.split(',')
.reduce((agg, value, idx) => {
const [levelName, levelIdx = idx] = value.split(':')

agg[levelName.toLowerCase()] = levelIdx
agg[levelName.toLowerCase()] = levelIdx

return agg
}, {})
return agg
}, {})
: {}
const customColors = opts.customColors
? opts.customColors
.split(',')
.reduce((agg, value) => {
const [level, color] = value.split(':')
.split(',')
.reduce((agg, value) => {
const [level, color] = value.split(':')

const condition = useOnlyCustomProps ? opts.customLevels : customLevelNames[level] !== undefined
const levelNum = condition ? customLevelNames[level] : LEVEL_NAMES[level]
const colorIdx = levelNum !== undefined ? levelNum : level
const condition = useOnlyCustomProps ? opts.customLevels : customLevelNames[level] !== undefined
const levelNum = condition ? customLevelNames[level] : LEVEL_NAMES[level]
const colorIdx = levelNum !== undefined ? levelNum : level

agg.push([colorIdx, color])
agg.push([colorIdx, color])

return agg
}, [])
return agg
}, [])
: undefined
const customProps = {
customLevels,
Expand Down
16 changes: 8 additions & 8 deletions package.json
Expand Up @@ -9,7 +9,7 @@
"pino-pretty": "./bin.js"
},
"scripts": {
"ci": "standard && tap --color --coverage-report=lcovonly && npm run test-types",
"ci": "standard && tap --coverage-report=lcovonly && npm run test-types",
"lint": "standard | snazzy",
"test": "tap --100 --color",
"test-types": "tsc && tsd"
Expand All @@ -35,27 +35,27 @@
"colorette": "^2.0.7",
"dateformat": "^4.6.3",
"fast-copy": "^2.1.1",
"fast-safe-stringify": "^2.0.7",
"fast-safe-stringify": "^2.1.1",
"joycon": "^3.1.1",
"help-me": "^4.0.1",
"minimist": "^1.2.6",
"on-exit-leak-free": "^1.0.0",
"pino-abstract-transport": "^0.5.0",
"pino-abstract-transport": "^1.0.0",
"pump": "^3.0.0",
"readable-stream": "^3.6.0",
"readable-stream": "^4.0.0",
"secure-json-parse": "^2.4.0",
"sonic-boom": "^3.0.0",
"strip-json-comments": "^3.1.1"
},
"devDependencies": {
"@types/node": "^17.0.0",
"pino": "^7.0.0",
"@types/node": "^18.0.0",
"pino": "^8.0.0",
"pre-commit": "^1.2.2",
"rimraf": "^3.0.2",
"snazzy": "^9.0.0",
"standard": "^16.0.3",
"standard": "^17.0.0",
"tap": "^16.0.0",
"tsd": "^0.20.0",
"tsd": "^0.21.0",
"typescript": "^4.4.3"
},
"tsd": {
Expand Down

0 comments on commit d28c98c

Please sign in to comment.