From 0881f1807968622c0ffe69116f2ee716455174f3 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Tue, 7 Sep 2021 14:12:48 +0200 Subject: [PATCH] Removed jmespath (#227) * Removed jmespath * removed search from README --- Readme.md | 7 ++----- index.d.ts | 4 ---- index.js | 12 ------------ package.json | 1 - test/basic.test.js | 33 -------------------------------- test/cli.test.js | 25 ------------------------ test/types/pino-pretty.test-d.ts | 2 -- 7 files changed, 2 insertions(+), 82 deletions(-) diff --git a/Readme.md b/Readme.md index 0b8fb5d4..6d353f14 100644 --- a/Readme.md +++ b/Readme.md @@ -81,10 +81,8 @@ node app.js | pino-pretty - Require a `SYS:` prefix to translate time to the local system's time zone. A shortcut `SYS:standard` to translate time to `yyyy-mm-dd HH:MM:ss.l o` in system time zone. -- `--search` (`-s`): Specify a search pattern according to - [jmespath](http://jmespath.org/). -- `--ignore` (`-i`): Ignore one or several keys, nested keys are supported with each property delimited by a dot character (`.`), - keys may be escaped to target property names that contains the delimiter itself: +- `--ignore` (`-i`): Ignore one or several keys, nested keys are supported with each property delimited by a dot character (`.`), + keys may be escaped to target property names that contains the delimiter itself: (`-i time,hostname,req.headers,log\\.domain\\.corp/foo`) - `--hideObject` (`-H`): Hide objects from output (but not error object) - `--singleLine` (`-S`): Print each log message on a single line (errors will still be multi-line) @@ -144,7 +142,6 @@ with keys corresponding to the options described in [CLI Arguments](#cliargs): messageFormat: false, // --messageFormat timestampKey: 'time', // --timestampKey translateTime: false, // --translateTime - search: 'foo == `bar`', // --search ignore: 'pid,hostname', // --ignore hideObject: false, // --hideObject singleLine: false, // --singleLine diff --git a/index.d.ts b/index.d.ts index 2405990e..c606d682 100644 --- a/index.d.ts +++ b/index.d.ts @@ -90,10 +90,6 @@ interface PrettyOptions_ { * @default "" */ errorProps?: string; - /** - * Specify a search pattern according to {@link http://jmespath.org|jmespath} - */ - search?: string; /** * Ignore one or several keys. * @example "time,hostname" diff --git a/index.js b/index.js index 53ef2fd5..51169814 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,6 @@ const { options: coloretteOptions } = require('colorette') const pump = require('pump') const { Transform } = require('readable-stream') const abstractTransport = require('pino-abstract-transport') -const jmespath = require('jmespath') const sonic = require('sonic-boom') const sjs = require('secure-json-parse') @@ -61,9 +60,7 @@ function prettyFactory (options) { const ignoreKeys = opts.ignore ? new Set(opts.ignore.split(',')) : undefined const hideObject = opts.hideObject const singleLine = opts.singleLine - const colorizer = colors(opts.colorize) - const search = opts.search return pretty @@ -80,10 +77,6 @@ function prettyFactory (options) { log = inputData } - if (search && !jmespath.search(log, search)) { - return - } - const prettifiedMessage = prettifyMessage({ log, messageKey, colorizer, messageFormat, levelLabel }) if (ignoreKeys) { @@ -178,11 +171,6 @@ function build (opts = {}) { autoDestroy: true, transform (chunk, enc, cb) { const line = pretty(chunk) - if (line === undefined) { - cb() - return - } - cb(null, line) } }) diff --git a/package.json b/package.json index a3478e12..bf406cca 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,6 @@ "colorette": "^1.3.0", "dateformat": "^4.5.1", "fast-safe-stringify": "^2.0.7", - "jmespath": "^0.15.0", "joycon": "^3.0.0", "pino-abstract-transport": "^0.2.0", "pump": "^3.0.0", diff --git a/test/basic.test.js b/test/basic.test.js index 9521bbda..1fb2c030 100644 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -443,39 +443,6 @@ test('basic prettifier tests', (t) => { log.info('foo') }) - t.test('filter some lines based on jmespath', (t) => { - t.plan(3) - const pretty = prettyFactory({ search: 'foo.bar' }) - const expected = [ - undefined, - undefined, - `[${epoch}] INFO (${pid} on ${hostname}): foo\n foo: {\n "bar": true\n }\n` - ] - const log = pino({}, new Writable({ - write (chunk, enc, cb) { - const formatted = pretty(chunk.toString()) - t.equal( - formatted, - expected.shift() - ) - cb() - } - })) - log.info('foo') - log.info({ something: 'else' }, 'foo') - // only this line will be formatted - log.info({ foo: { bar: true } }, 'foo') - }) - - t.test('handles `undefined` return values', (t) => { - t.plan(2) - const pretty = prettyFactory({ search: 'msg == \'hello world\'' }) - let formatted = pretty(`{"msg":"nope", "time":${epoch}, "level":30}`) - t.equal(formatted, undefined) - formatted = pretty(`{"msg":"hello world", "time":${epoch}, "level":30}`) - t.equal(formatted, `[${epoch}] INFO: hello world\n`) - }) - t.test('formats a line with an undefined field', (t) => { t.plan(1) const pretty = prettyFactory() diff --git a/test/cli.test.js b/test/cli.test.js index a15c7eeb..ec05c142 100644 --- a/test/cli.test.js +++ b/test/cli.test.js @@ -47,31 +47,6 @@ test('cli', (t) => { }) }) - ;['--search', '-s'].forEach((optionName) => { - t.test(`does search via ${optionName}`, (t) => { - t.plan(1) - const child = spawn(process.argv[0], [bin, optionName, 'msg == `hello world`'], { env }) - child.on('error', t.threw) - child.stdout.on('data', (data) => { - t.equal(data.toString(), `[${epoch}] INFO (42 on foo): hello world\n`) - }) - child.stdin.write(logLine) - t.teardown(() => child.kill()) - }) - }) - - t.test('does search but finds only 1 out of 2', (t) => { - t.plan(1) - const child = spawn(process.argv[0], [bin, '-s', 'msg == `hello world`'], { env }) - child.on('error', t.threw) - child.stdout.on('data', (data) => { - t.equal(data.toString(), `[${epoch}] INFO (42 on foo): hello world\n`) - }) - child.stdin.write(logLine.replace('hello world', 'hello universe')) - child.stdin.write(logLine) - t.teardown(() => child.kill()) - }) - ;['--ignore', '-i'].forEach((optionName) => { t.test('does ignore multiple keys', (t) => { t.plan(1) diff --git a/test/types/pino-pretty.test-d.ts b/test/types/pino-pretty.test-d.ts index 902b80f1..21085319 100644 --- a/test/types/pino-pretty.test-d.ts +++ b/test/types/pino-pretty.test-d.ts @@ -22,7 +22,6 @@ const options: PinoPretty.PrettyOptions = { messageKey: "msg", timestampKey: "timestamp", translateTime: "UTC:h:MM:ss TT Z", - search: "foo == `bar`", singleLine: false, customPrettifiers: { key: (value) => { @@ -45,7 +44,6 @@ const options2: PrettyOptions = { messageKey: "msg", timestampKey: "timestamp", translateTime: "UTC:h:MM:ss TT Z", - search: "foo == `bar`", singleLine: false, customPrettifiers: { key: (value) => {