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

Missing output of console.error when using override: true #63

Closed
jedrus2000 opened this issue Jun 13, 2020 · 1 comment · Fixed by #65
Closed

Missing output of console.error when using override: true #63

jedrus2000 opened this issue Jun 13, 2020 · 1 comment · Fixed by #65

Comments

@jedrus2000
Copy link
Contributor

jedrus2000 commented Jun 13, 2020

Maybe it is me, not laabr but I've such issue - with laabr option override: true, when i.e. TypeError occurs and is caught, then reported with console.error(error), I see only :

image

My stack is :

Node v10 with Docker (node:10) : https://hub.docker.com/_/node/
hapi: 18.3.1,
laabr: 5.1.6
nodemon: 1.19.4

It started to annoy me more and more, and if error was happening, I had to start server with override set to false.
I looked into source code how console is implemented and found this :

https://github.com/whatwg/console/blob/f276b49ad99c815a17a86b6c6cbc8ca842eb69d3/reference-implementation/Logger.js#L29

so I went to my ❤️ laabr and this

server.log(level, data.length === 1 ? data[0] : data)

I've changed into :

server.log(level, util.format(data))

( with const util = require('util') at source file beginning. )

So after this output looks that :
image

My laabr options are :

      options: {
        override: true, // Override several console logging methods
        formats: {
          log: ':time[iso], :level, :message',
          request: ':time[iso], :level, :message',
          response: ':time[iso], :level, :method, :url, :status, :payload, (:responseTime ms)',
          'request-error': ':time[iso], :level, :method, :url, :error[output.statusCode], :error, :error[stack]',
          onPostStart: ':time[iso], :level, :message',
          onPostStop: ':time[iso], :level, :message',
          uncaught: ':time[iso], :level, :error, :error[stack]'
        },
        pino: { level: 'info' },
        indent: 0,
        colored: true
    }

I must say that I cannot exactly reproduce it at my local Linux (using i.e. Node 14, latest laabr). So with my laabr options, using simple.js I've got this :

image

With my modification in laabr/src/utils.js it looks like this :
image

I think is more readable. @felixheck What do you think ?

@felixheck
Copy link
Owner

Thanks a ton for all the details and opening this issue!
I 100% with you, it’s definitely more readable.

Would you mind creating a PR?
More than happy to release it asap 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants