Git Product home page Git Product logo

pino-pretty's People

Contributors

10xlacroixdrinker avatar ademarsj avatar apehead avatar baterson avatar bengale avatar binarybrain avatar coejoder avatar dependabot[bot] avatar dublx avatar fdawgs avatar jasonetco avatar jimmyolo avatar jsumners avatar kibertoad avatar louisvenne avatar marcelfranca avatar mcollina avatar mojavelinux avatar nalexandrov avatar nwoltman avatar ovhemert avatar ronag avatar shogunpanda avatar simon-lorenz avatar simoneb avatar tommydew42 avatar tzewey avatar vladimyr avatar windupbird144 avatar zirak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pino-pretty's Issues

API option `ignore` should accept an array

There are two prettify options that take a list of strings, errorLikeObjectKeys and ignore. The former accepts an array of strings, while the latter wants a comma-separated list.

I actually came here to suggest that ignore should run trim on all values -- ignore: "pid, hostname" is treated as ignore: "pid" because the space in the value causes hostname not to match. But after looking at the docs, and seeing how errorLikeObjectKeys is handled, it would be more consistent to accept an array (while retaining backward compatibility with the CSV version).

Ability to format log string before message is appended

This tool is exactly what I'm after, but I was hoping that it would be a little easier to format the log that's output before the message is appended. I've built a solution and am hoping that it can be adopted into the project. I see room here to provide configuration logic that can allow specifying what keys and delimiters should be rendered.

Rather than make a separate transport, I took a stab at adding a feature that would provide this the flexibility I was looking for. This issue is going to be followed by a PR for review.

My specific use case, was to bind the module and method to each log entry and have them show in a format that's easy to digest. I found a lot of modules that wrap pino and leverage CallSite, but that doesn't help with my minified code. So I went with this approach:

// logger/LoggerFactory.ts
/**
 * @module logger
 */
import * as pino from 'pino';
import * as pkg from '../package.json';

process.env.LOG_LEVEL = (process.env.LOG_LEVEL)? process.env.LOG_LEVEL : 'info';

/**
 * Factory class which will create a pino logger for each class to use.
 */
export default class LoggerFactory {
    /**
     * Pino Logger instance to be shared by all modules in this application
     * 
     * log level defaults to `info` and can be overridden with `$LOG_LEVEL` env variable
     */
    private static logger = pino({
        level: process.env.LOG_LEVEL,
        redact: { paths: ['hostname'], remove: true },
        prettyPrint: {
            translateTime: true,
            format: [
                { delimiter: '[', requiresAll: ['time'] },
                { key: 'time' },
                { delimiter: '] ', requiresAll: ['time'] },
                { key: 'level' },
                { delimiter: ' (' },
                { key: 'pid' },
                { delimiter: ') [' },
                { key: 'app' },
                { delimiter: '] [' },
                { key: 'class' },
                { delimiter: '] ' },
                { delimiter: '[', requiresAll: ['fn'] },
                { key: 'fn' },
                { delimiter: '] ', requiresAll: ['fn'] }
            ]
        }
    });

    /**
     * The module/class path where the logger will be used
     * 
     * @param classPath
     */
    public static getLogger(classPath:string):pino.Logger {
        return LoggerFactory.logger.child({
            app: pkg.logCode,
            class: classPath
        });
    }
}
// api/mqtt/Client.js
/**
 * @module api/mqtt
 */
import LoggerFactory from '../../logger/LoggerFactory'
const logger = LoggerFactory.getLogger('api/http/Client');

export default class Client {
  constructor() {
    let flog =  logger.child({fn: 'constructor'});
    flog.info('Client Created');
  }

  public connect() {
    let flog =  logger.child({fn: 'connect'});
    flog.trace('start');
    // Client connection logic
    flog.trace('end');
  }
}
// server.js
/**
 * @module server
 */
import LoggerFactory from './logger/LoggerFactory';
import Client from './api/mqtt/Client';
const logger = LoggerFactory.getLogger('server');

logger.debug('Start the Application');

let client = new Client();
client.connect

process.on('SIGINT', () => {
    logger.info('SIGINT received, closing process');
    process.exit()
});

I will then take it upon myself and the team to manually bind fn when logging within the context of a specific function. Now I get logs that look like this:

[2019-03-02 13:43:35.942 +0000] DEBUG (61924) [app] [server] Start the Application
[2019-03-02 13:43:35.946 +0000] TRACE (61924) [app] [api/mqtt/Client] [constructor] Client Created
[2019-03-02 13:43:35.947 +0000] TRACE (61924) [app] [api/mqtt/Client] [connect] start
[2019-03-02 13:43:35.947 +0000] TRACE (61924) [app] [api/mqtt/Client] [connect] end
[2019-03-02 13:44:20.324 +0000] INFO (61924) [app] [server] SIGINT received, closing process

Unable to customize "level" key

Pino allows changing the level key via the changeLevelName option.

Pino-Pretty already supports --messageKey, so it should probably also support --changeLevelName.

Allow nested keys in message format

The existing messageFormat does not allow us to print a nested key from an object. i.e:

{
  level: 20,
  pid: 123,
  req: {
    url: "localhost:3000/favicon.ico"
  }
}

With --messageFormat '{level} - {pid} - {req.url}', pino-pretty will print 20 - 123 -
With the proposed change, pino-pretty will print 20 - 123 - localhost:3000/favicon.ico

can we rename `outputStream` to `destination` to match pino v5 parlance

Due to the addition of pino.destination, and that fact SonicBoom kind of is and kind of isn't a stream, the adoption of the term "destination" has become prevalent in the v5 documentation.

For parity with pino, in the next-major branch, are there any arguments against renaming outputStream option to destination.

When an Error is the first parameter, the second and third parameters are not printed

Code is:

try { throw new Error('foo') } catch(error) { logger.info(error, 'something went wrong') }
try { throw new Error('bar') } catch(error) { logger.info(error, 'something broke', 'test string') }

The logger only prints the error for the first argument but not the second or third arguments:

[1535020164640] INFO (94172 on macbook-pro-2.internal.local): foo Error: foo at Object.<anonymous>...
[1535020164642] INFO (94172 on macbook-pro-2.internal.local): bar Error: bar at Object.<anonymous>...

I would expect the second and third parameters to be outputted along with the error.

Versions used are [email protected] and [email protected]

Partial Prettyfier

Just like available in bunyan and winston, I would like to have ability to prettify the console output only, but keep the output to the file as json. Currently I'm using the following way:

const Pino = require('pino');
const multi = require('multi-write-stream');

var logFileStream = fs.createWriteStream('the-path');
var stream = multi([
    process.stdout,
    logFileStream
])

 var pinoOptions = {
    name: this._name,
    prettyPrint: {
        levelFirst: false,
        translateTime: true,
        colorize: true
    },
    prettifier: require('pino-pretty')
}

var logger = Pino(pinoOptions, stream);

P.S. I'm aware of the out-of-process prettyfier. In this particular case need to get console prettification in process.

How to filter the log time?

The --search parameter is great for searching within the JSON content but how would I filter the logs for the timestamp? Let's say I wanted all log entries from 17:10 to 17:19, how would I do that?

TypeError: Cannot read property 'split' of undefined

I'm getting the following error regularly with the latest pino-pretty:

TypeError: Cannot read property 'split' of undefined
    at joinLinesWithIndentation (/home/avery/dev/20songs/node_modules/pino-pretty/index.js:199:27)
    at filterObjects (/home/avery/dev/20songs/node_modules/pino-pretty/index.js:222:13)
    at pretty (/home/avery/dev/20songs/node_modules/pino-pretty/index.js:193:15)
    at Object.write (/home/avery/dev/20songs/node_modules/pino/lib/tools.js:208:25)
    at Pino.write (/home/avery/dev/20songs/node_modules/pino/lib/proto.js:98:15)
    at Pino.LOG [as error] (/home/avery/dev/20songs/node_modules/pino/lib/tools.js:34:21)
    at CachingSoundCloudApi.request (/home/avery/dev/20songs/src/soundcloud/api.js:32:15)
    at <anonymous>

Nothing has changed on my side except updating dependencies.

Crash when logging date

When i directly log JSON.stringified date with console.log without using pino then peno-pretty crashes with the following error message:

/code/node_modules/pino-pretty/lib/utils.js:178
   if ('level' in log === false) return undefined
               ^

 TypeError: Cannot use 'in' operator to search for 'level' in 2019-05-31T00:00:00.000Z
     at prettifyLevel (/code/node_modules/pino-pretty/lib/utils.js:178:15)
     at pretty (/code/node_modules/pino-pretty/index.js:85:29)
     at Transform.transform [as _transform] (/code/node_modules/pino-pretty/bin.js:38:18)
     at Transform._read (/code/node_modules/pino-pretty/node_modules/readable-stream/lib/_stream_transform.js:177:10)
     at Transform._write (/code/node_modules/pino-pretty/node_modules/readable-stream/lib/_stream_transform.js:164:83)
     at doWrite (/code/node_modules/pino-pretty/node_modules/readable-stream/lib/_stream_writable.js:405:139)
     at writeOrBuffer (/code/node_modules/pino-pretty/node_modules/readable-stream/lib/_stream_writable.js:394:5)
     at Transform.Writable.write (/code/node_modules/pino-pretty/node_modules/readable-stream/lib/_stream_writable.js:303:11)
     at Transform.ondata (/code/node_modules/split2/node_modules/readable-stream/lib/_stream_readable.js:662:20)
     at Transform.emit (events.js:196:13)

The following snipped in my code (fastify server) will produde this crash:

const value = JSON.stringify(new Date());
console.log(value);

I have not tested if this only works with stringified dates or if this is a bug when a string with start and end "quotes" gets logged.

I know this is already my second crash report, but apparently I'm a talent for finding crash bugs in pino-pretty πŸ˜…

Filter by level

Maybe I'm obtuse but I don't see a straightforward way to limit output to certain levels, at least not in a user-friendly way. Perhaps -s could be used to do this, but this requires the user remember how the numeric levels map to the friendly names. Coming from bunyan, it was nice to be able to specify -l info and have only messages at least as severe as the info level be displayed (filtering out debug and trace). I feel like this tool could benefit from such an option.

Crash when logging integer

When i directly log a number with console.log without using pino then peno-pretty crashes with the following error message:

/code/node_modules/pino-pretty/lib/utils.js:178
   if ('level' in log === false) return undefined
               ^

 TypeError: Cannot use 'in' operator to search for 'level' in 2
     at prettifyLevel (/code/node_modules/pino-pretty/lib/utils.js:178:15)
     at pretty (/code/node_modules/pino-pretty/index.js:85:29)
     at Transform.transform [as _transform] (/code/node_modules/pino-pretty/bin.js:38:18)
     at Transform._read (/code/node_modules/pino-pretty/node_modules/readable-stream/lib/_stream_transform.js:177:10)
     at Transform._write (/code/node_modules/pino-pretty/node_modules/readable-stream/lib/_stream_transform.js:164:83)
     at doWrite (/code/node_modules/pino-pretty/node_modules/readable-stream/lib/_stream_writable.js:405:139)
     at writeOrBuffer (/code/node_modules/pino-pretty/node_modules/readable-stream/lib/_stream_writable.js:394:5)
     at Transform.Writable.write (/code/node_modules/pino-pretty/node_modules/readable-stream/lib/_stream_writable.js:303:11)
     at Transform.ondata (/code/node_modules/split2/node_modules/readable-stream/lib/_stream_readable.js:662:20)
     at Transform.emit (events.js:196:13)

The following snipped in my code (fastify server) will produde this crash:

console.log(index); // index = 2

Can't use with jest CLI

Currently, our set up is

     "test": "jest"
    - yarn test --all --detectOpenHandles | yarn pino-pretty

Without pipeline from pino-pretty, jest can be colorized. But, if I add pino-pretty pipeline, it will be just black&while

handle msg key wrongly

I use pino-pretty v2.2.0, pino v5.6.1
Origin pino can handle msg key properly, like this

pino().info({ msg: { a: 1 } })
// output includes 'msg: {a: 1}'

But when use pino-pretty, msg is outputted as [object Object], code like this

pino({  prettyPrint: { forceColor: true } }).info({ msg: { a: 1 } })

Log level incorrectly shows up as USERLVL when `useLevelLabels: true`

I created pino with option useLevelLabels: true. When formatting via pino-pretty those log lines show up as

[2019-04-23 13:56:29.560 +0000] USERLVL (runScript): Request did succeed

The log line itself cpontains

{
  "level": "info",
  "time": 1556027789560,
  "name": "runScript",
  "msg": "Request did succeed",
  "v": 1
}

Given that useLevelLabels is a feature built into pino, pino-pretty should be able to understand their corresponding string based levels.

cross platform support: windows

Problem statement:

I am using PowerShell in windows, and the format of pino development is not as expected. This works perfectly in Mac.

Expected: [1522431328992] INFO (42 on foo): hello world
Actual: [1522431328992] <-[32mINFO <-[32m (42 on foo): <-[32m hello world <-[32m

`pino.final` does not work with pino-pretty

When using pino.final with pino-pretty following exception is thrown:

only compatible with loggers with pino.destination and pino.extreme targets

We are using pretty-printing on the dev boxes and it took me quite a while that pino.final works fine without pino-pretty. Below you find code to reproduce the issue.

Best,
Alexander

const pino = require('pino')

const logger = pino({
  prettyPrint: true
})

const run = async () => {
  process.on('SIGTERM', pino.final(logger, (err, finalLogger) => {
    finalLogger.info('Graceful shutdown 1')
    finalLogger.info('Graceful shutdown 2')
    process.exit(0)
  }))

  await delay(30)
}

const delay = (secs) => {
  return new Promise((resolve, reject) => {
    setTimeout(() => resolve(), secs * 1000)
  })
}

run().catch(err => {
  logger.error({ err })
})

logger properties dropped when error object provided

Simple reproduction case (pino 5.8, pino-pretty 2.2.2):

const pino = require('pino');

const pinoLogger = pino();
const log = pinoLogger.child({ project: 'my-project' });

log.error('This case works as expected');

try {
    throw new Error('A thrown error');
} catch (error) {
    log.error(error, 'This case does not work');
}

Then running node example.js | pino-pretty gives this (note the lack of a my-project field in the second log message):

[1540094314133] ERROR (87649 on redacted): This case works as expected
    project: "my-project"
[1540094314134] ERROR (87649 on redacted): This case does not work
    Error: A thrown error
        at Object.<anonymous> (redacted/example.js:9:11)
        at Module._compile (module.js:643:30)
        at Object.Module._extensions..js (module.js:654:10)
        at Module.load (module.js:556:32)
        at tryModuleLoad (module.js:499:12)
        at Function.Module._load (module.js:491:3)
        at Function.Module.runMain (module.js:684:10)
        at startup (bootstrap_node.js:187:16)
        at bootstrap_node.js:608:3

Running just node example.js gives the underlying output that I expect with a my-project field in both json messages:

{"level":50,"time":1540094310116,"msg":"This case works as expected","pid":87638,"hostname":"redacted","project":"my-project","v":1}
{"level":50,"time":1540094310117,"msg":"This case does not work","pid":87638,"hostname":"redacted","project":"my-project","type":"Error","stack":"Error: A thrown error\n    at Object.<anonymous> (redacted/example.js:9:11)\n    at Module._compile (module.js:643:30)\n    at Object.Module._extensions..js (module.js:654:10)\n    at Module.load (module.js:556:32)\n    at tryModuleLoad (module.js:499:12)\n    at Function.Module._load (module.js:491:3)\n    at Function.Module.runMain (module.js:684:10)\n    at startup (bootstrap_node.js:187:16)\n    at bootstrap_node.js:608:3","v":1}

Evaluate for release

@pinojs/pino please evaluate this codebase for release readiness. I'd like at least @mcollina and @davidmarkclements to sign off before I publish it.

@hbarcelos please verify that error stack traces are formatted correctly.

@ilyaztsv please verify that it properly supports defining which properties of an error object to display.

@victor0801x please verify that it outputs localized times as desired.

How would you colorize similarly to console.log?

Printed two errors to console, once with pino.error and once with console.error. This is my prettyPrint options for pino:

logger = pino({
  prettyPrint: {
    colorize: true,
    translateTime: true,
    errorProps: "*"
  }
});

This is console.error:
consolelog
And this is pino.error:
pino

How to avoid new lines when using pretty print ?

My code:

pino( prettyPrint: { crlf : true, colorize: true});

Issue:

I am trying to avoid new lines when using prettyPrint, my output is like the below one,

[ed Jul 17 2019 16:14:53 GMT-0700 (Pacific Daylight Time)] DEBUG: The Correlation ID inside the Service Call One is
correlationId: "offlineContext_requestId_1993731475678433"
label: "Service Call One"

Legitimate data gets interpreted as configuration

I had some logs that printed some business objects (via pino with prettyPrint enabled) that had a name field in the object. When it was printed, the field didn't show up.

Instead, it replaced the "pino" name and instead of the proper name showing up, it had the data field value showing up.

When printing an object without the name field:

[1542282240641] DEBUG (server/11044 on Donut.local)

When printing an object with the name field:

[1542282240642] DEBUG (Fred Smith/11044 on Donut.local)

And then the name field value does NOT show up with the other data from the same object.

As far as what I am passing to the pino call, I'm just passing the raw object.

Circular reference error

I have been experiencing some errors while logging objects with circular references.
This problem is solved in pino by using a safe-stringify library. Could we do the same here?

'use strict';

const pino = require('pino');

const logger = pino({
  prettyPrint: {
    levelFirst: true
  },
  prettifier: require('pino-pretty')
});

const logInfo = { a: 1, b: 2 };
// Circular reference
logInfofo.c = logInfo;

// This throws an error due to the circular reference:
// TypeError: Converting circular structure to JSON
logger.info(logInfo, 'an info log');

I have created #50 to solve this issue.

.pino-prettyrc not being honoured

// Override config with cli options

.pino-prettyrc:

{
  "errorProps": "number,cause,status,statusCode,url"
}

console.logs around referred line (bin.js:72) reveal:

before assign {
  config: { errorProps: 'number,cause,status,statusCode,url' },
  opts: {
    e: '',
    errorProps: '',
    k: 'err,error',
    errorLikeObjectKeys: 'err,error'
  }
}
after assign {
  config: { errorProps: 'number,cause,status,statusCode,url' },
  opts: {
    errorProps: '',
    e: '',
    k: 'err,error',
    errorLikeObjectKeys: 'err,error'
  }
}

doc: error CLI Arguments

v2.x has removed -d, --dateFormat & -n, --localTime options and combinded with -t opt. right?

Log lines with "v":0 is not formatted

Log lines with "v":0 is not formatted:

$ echo '{"level":30,"msg":"test message","time":1567606368094,"v":0}' | pino-pretty
> {"level":30,"msg":"test message","time":1567606368094,"v":0}

Same line with version=1 is formatted as expected:

$ echo '{"level":30,"msg":"test message","time":1567606368094,"v":1}' | pino-pretty
> [1567606368094] INFO : test message

Cannot handle obj within undefined value

When call like this

    log.info({
      app: undefined,
      room: undefined,
    }, 'connect')

, it gives error Cannot read property 'split' of undefined" at pino-pretty/index.js:199:27.
I think pino-pretty should deal with this situation.

timestamp: false results in empty []

Hiya! I'm trying out pino(-pretty) and encountered an unexpected rendering. Here's what I'm seeing in my console:

[] INFO  (my-logger): test

And here's the code to generate it:

const logger = pino({
  base: { name: my-logger },
  prettyPrint: true,
  timestamp: false
})

logger.info('test')

It looks like timestamp being set to false is properly omitting it from the log, but the [<timestamp>] square brackets are still being printed. As a library user, I would expect the square brackets to also be omitted, and to see this as the output:

INFO  (my-logger): test

Let me know if I'm doing something weird or if there's anything I can do to help! ✨

Versions
❯ node -v
v10.13.0

❯ npm list pino pino-pretty
β”œβ”€β”€ [email protected]
└── [email protected]

translateTime option causes TypeError: Invalid date

When using the following options pretty-pino crashes with the error message:

TypeError: Invalid date

(I'm trying to display the logged date/time in a human readable format)
Thanks! :)

pino({
    level: "trace",
    prettyPrint: {
        colorize: true,
        translateTime: true
    }
});
TypeError: Invalid date
    at C:\Work\TypeScript\node_modules\dateformat\lib\dateformat.js:39:17
    at formatTime (C:\Work\TypeScript\node_modules\pino-pretty\index.js:44:10)
    at pretty (C:\Work\TypeScript\node_modules\pino-pretty\index.js:112:18)
    at Object.write (C:\Work\TypeScript\node_modules\pino\lib\tools.js:170:25)
    at Pino.write (C:\Work\TypeScript\node_modules\pino\lib\proto.js:101:15)
    at Pino.LOG [as info] (C:\Work\TypeScript\node_modules\pino\lib\tools.js:32:26)
    at Object.<anonymous> (C:\Work\TypeScript\src\main.ts:16:5)
    at Module._compile (module.js:649:14)
    at Module.m._compile (C:\Work\TypeScript\node_modules\ts-node\src\index.ts:439:23)
    at Module._extensions..js (module.js:663:10)

can't ignore level

Using the new ignore parameter, doesn't seem to work for level:

echo '{"level":30,"time":1522431328992,"msg":"hello world","pid":42,"hostname":"foo","v":1, "name":"pou"}' | node bin.js -ti level
[2018-03-30 17:35:28.992 +0000] USERLVL (pou/42 on foo): hello world

i.e., it displays USERLVL instead of nothing. Here's the line that fails:

levels.hasOwnProperty(log.level)
  ? color[log.level](levels[log.level])
  : color.default(levels.default)

log.level here is undefined, so it falls back to USERLVL.

Also, kind of related - if you tell it to ignore everything before the : it'll still show the :

NaN and Infinity are logged as null

If a value in an object is NaN or Infinity, it is printed as null.

With:

const pino = require('pino')({
  prettyPrint: true,
})

pino.info({
  nan: NaN,
  infinity: Infinity,
})

pino prints:

[1537734467643] INFO (12908 on my-pc):
    nan: null
    infinity: null

With prettyPrint: false, pino prints:

{"level":30,"time":1537734724883,"pid":10064,"hostname":"my-pc","nan":NaN,"infinity":Infinity,"v":1}

Printing NaN and Infinity might actually be a problem for regular pino because JSON.parse() can't parse that JSON, however, it would be nice for pino-pretty to print NaN and Infinity because it is hard to debug things when you think the value is null but it is actually NaN.

It looks like the cause is from using JSON.stringify() here:

result += IDENT + keys[i] + ': ' + joinLinesWithIndentation(JSON.stringify(value[keys[i]], null, 2)) + EOL

Add option for single-line logging of extra attributes

Logs with multiple extra attributes now take too many lines. Personally I prefer buynan formatting.

Example:

logger.info({ id: 22246537, type: 'story' }, 'Saving item.');

Current output with pino-pretty -t -i hostname,pid:

[2020-02-05 13:32:31.528 +0000] INFO : Saving item.
    id: 22246537
    type: "story"

Preferred output:

[2020-02-05 13:32:31.528 +0000] INFO : Saving item. { id: 22246537, type: "story" }

Not managing Apollo Errors

Hi,

We are starting with Apollo, and we were considering moving from bunyan to pino.
But pino-pretty doesn't seem to handle correctly Apollo Error.

We used it in the package.json like this:

{
  // ...
  "start:dev": "npm start | pino-pretty",
  // ...
 }

pino-pretty actuel output:

[1535882503222] ERROR (44 on 92e97466e44b): Invalid token
    undefined

expected output (made with bunyan parser):

[2018-09-02T10:09:09.434Z] ERROR: graphql-poc-api/74 on 92e97466e44b: Invalid token
    err: {
      "message": "Invalid token",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "changeRole"
      ],
      "extensions": {
        "code": "UNAUTHENTICATED",
        "exception": {
          "stacktrace": [
            "AuthenticationError: Invalid token",
            "    at Object.decode (/var/www/src/helpers/token.js:19:11)",
            "    at field.resolve (/var/www/src/directives/Auth.js:23:26)",
            "    at field.resolve (/var/www/node_modules/graphql-extensions/dist/index.js:92:48)",
            "    at resolveFieldValueOrError (/var/www/node_modules/graphql/execution/execute.js:531:18)",
            "    at resolveField (/var/www/node_modules/graphql/execution/execute.js:495:16)",
            "    at /var/www/node_modules/graphql/execution/execute.js:339:18",
            "    at /var/www/node_modules/graphql/jsutils/promiseReduce.js:25:10",
            "    at Array.reduce (<anonymous>)",
            "    at promiseReduce (/var/www/node_modules/graphql/jsutils/promiseReduce.js:22:17)",
            "    at executeFieldsSerially (/var/www/node_modules/graphql/execution/execute.js:336:38)",
            "    at executeOperation (/var/www/node_modules/graphql/execution/execute.js:289:55)",
            "    at executeImpl (/var/www/node_modules/graphql/execution/execute.js:154:14)",
            "    at Object.execute (/var/www/node_modules/graphql/execution/execute.js:131:35)",
            "    at Promise.resolve.then (/var/www/node_modules/apollo-server-core/dist/runQuery.js:127:35)",
            "    at process._tickCallback (internal/process/next_tick.js:68:7)"
          ]
        }
      }
    }

Option to customize timestamp field name

There is already an option for customizing message field name, would be great to have same one for timestamp.

Reason for this -> we'd like to be able to store it as @timestamp for convenience of consumption from Kibana, but currently pino is not aware that this is a timestamp, so during pretty print it displays [undefined] as time.

Windows color

Colorize option does not work on windows and the only choice is to disable it. However on Winston logger I had basic color output just fine. How is that possible? and can we somehow copy whatever Winston is doing to make it work?

Cannot read property 'split' of undefined

3|deepstream  | [1540590387184] FATAL (deepstream/51447 on Roberts-MacBook-Pro.local): error caused exit
3|deepstream  |     err: {
3|deepstream  |       "type": "TypeError",
3|deepstream  |       "message": "Cannot read property 'split' of undefined",
3|deepstream  |       "stack":
3|deepstream  |           TypeError: Cannot read property 'split' of undefined
3|deepstream  |               at joinLinesWithIndentation (/Users/ronagy/GitHub/nxtedition/nxt/deepstream/node_modules/pino-pretty/index.js:199:27)
3|deepstream  |               at filterObjects (/Users/ronagy/GitHub/nxtedition/nxt/deepstream/node_modules/pino-pretty/index.js:226:13)
3|deepstream  |               at pretty (/Users/ronagy/GitHub/nxtedition/nxt/deepstream/node_modules/pino-pretty/index.js:193:15)
3|deepstream  |               at Object.write (/Users/ronagy/GitHub/nxtedition/nxt/deepstream/node_modules/pino/lib/tools.js:261:25)
3|deepstream  |               at Pino.write (/Users/ronagy/GitHub/nxtedition/nxt/deepstream/node_modules/pino/lib/proto.js:99:15)
3|deepstream  |               at Pino.LOG [as error] (/Users/ronagy/GitHub/nxtedition/nxt/deepstream/node_modules/pino/lib/tools.js:39:21)
3|deepstream  |               at _db.put.err (/Users/ronagy/GitHub/nxtedition/nxt/deepstream/src/record/record-handler.js:215:22)
3|deepstream  |               at /Users/ronagy/GitHub/nxtedition/nxt/deepstream/node_modules/levelup/lib/levelup.js:196:5

need correct jmespath search filtering syntax

according to readme I am supposed to use http://jmespath.org/tutorial.html syntax for the search key

I just have a little test logger running with prettyPrint enabled. Runs fine except for search key syntax. All the jmespath examples assume not a single line of json but a key with array of json. In my(our) case there is none just a single line of JSON. like {"level":30,"time":1542136015941,"msg":"this is a logged message","pid":4382}

I followed the suggested syntax here http://getpino.io/#/docs/help?id=filter-logs which would be '.level == 60' where I guess . is supposedly taking the place of a proper parent key but I get this error which is not surprising cause at the jmespath site the . does nothing if I put in for example from above {"level":30,"time":1542136015941,"msg":"this is a logged message","pid":4382} (try it yourself)

So need help. Tried several options to no avail.

# this is log of my prettyPrint options in my `const logger = pino({`
pretty=> { translateTime: true,
  colorize: true,
  levelFirst: true,
  search: '.level == 60' }
# then here is error when it logs
file:///home/david/AllData/hacking/active-dev-repos/uci/lib/uci-logger/node_modules/jmespath/jmespath.js:1
ParserError: Invalid token (Dot): "."
    at Parser._errorToken (file:///home/david/AllData/hacking/active-dev-repos/uci/lib/uci-logger/node_modules/jmespath/jmespath.js:710:23)

Missing error log

I have a strange situation. My code is

try {
   throw new Error('an error');
} catch(e) {
  logger.error(e)
}

If I enable pino-pretty programmatically, the trace of the error is missing and the log line is

[1534924057159] ERROR (16193 on here):

If instead I pipe the output of pino to pino-pretty, the error is correctly shown

[1534924260199] ERROR (16798 on here): an error
    Error: an error
        at REQUEST
 (/test.js:43:13)
        at process._tickCallback (internal/process/next_tick.js:68:7)

crash on keys that resolve to an undefined value.

When logging values that resolve to undefined for example functions or objects with overriden toJSON functions pino-pretty crashes in joinLinesWithIndentation when calling split on undefined.

log.debug({a: { toJSON () {} } })
TypeError: Cannot read property 'split' of undefined
log.debug({a: f => f })
TypeError: Cannot read property 'split' of undefined

I can send a PR to fix?

Error objects aren't logged

Just switched to [email protected] + [email protected] and error objects result in empty logs:

const pino = require('pino')({
  base: {pid: process.pid, hostname: 'my-pc'},
  prettyPrint: {translateTime: true},
})

pino.error(new Error('an error'))

pino

Expected something more like pino@4:

pino2

Node 10.8.0
Windows 10

bad translateTime/localTime output

  1. I clone this repo and run its tests are correct, but use pino-pretty as global cli will get this weird output.
$ echo '{"level":30,"time":1522431328992,"msg":"hello world","pid":42,"hostname":"foo","v":1}' |pino-pretty --colorize --translateTime
[2018-35-30 17:03:28.ththth UTC] INFO (42 on foo): hello world

$ echo '{"level":30,"time":1522431328992,"msg":"hello world","pid":42,"hostname":"foo","v":1}' |pino-pretty --colorize --translateTime --localTime
[2018-35-31 01:03:28.ststst CST] INFO (42 on foo): hello world

$ echo '{"level":30,"time":1522431328992,"msg":"hello world","pid":42,"hostname":"foo","v":1}' |pino-pretty --colorize --translateTime --localTime --dateFormat 'yyyy-mm-dd HH:MM:ss.l o'
[2018-03-31 01:35:28.992 +0800] INFO (42 on foo): hello world

2018-04-07 14-37-20

  1. (not a bug) if we pass dateFormat or localTime args, shoud we implicit enable translateTime ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.