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

Making pino-debug compatible with debug v3 #11

Merged
merged 11 commits into from
Jan 3, 2018

Conversation

lukaszewczak
Copy link
Collaborator

Hi @davidmarkclements ,

So this is my first try to make pino-debug compatible with debug v3.

I need to fix situation when someone add namespaces to debug on process.env.DEBUG and after running pino-debug those namespaces was erased, because of the debug package behavior which erases any previous namespaces after call to debug.enable method. This why I add one new test to test this situation, and add new method getNamespaces which retrive namespaces from process.env.DEBUG.

Because debug package erases previous namespaces I put logic into pinoDebug method to collect all namespaces ( to enable and disable) and run only once debug.enable method.

I had problem with running npm run bench script for becnhamrk. After running it I receive this response:

> pino-debug@1.0.5 bench /home/node/pino
> node benchmarks/runbench all

Running BASIC benchmark

Running OBJECT benchmark

Running DEEPOBJECT benchmark

==========
basic averages
==========
==========
object averages
==========
==========
deepobject averages
==========

Without any errors or results, I even make this test on the master branch without mine changes, and the result is the same. So is this a correct situation?

Regards,
Łukasz

@codecov-io
Copy link

codecov-io commented Dec 1, 2017

Codecov Report

Merging #11 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #11   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           2      2           
  Lines          44     48    +4     
=====================================
+ Hits           44     48    +4
Impacted Files Coverage Δ
index.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a981dd8...9088e45. Read the comment docs.

test/index.js Outdated
@@ -303,3 +303,17 @@ test('results in valid syntax when source has trailing comment', (t) => {
t.doesNotThrow(() => require('./fixtures/trailing-comment'))
t.end()
})

test('Set env.DEBUG and captures any calls to `debug` and passes them through pino logger', (t) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rephrase the test: something like

"preserves DEBUG env independently from debug module"

@davidmarkclements
Copy link
Member

hey @lukaszewczak - benchmarks are fixed on master now (we're relying on knowing the debug folder structure, if it changes the benchmarks break, very brittle I know but we have to be able to clear debug module files from the require cache between benchmarks) see #12

@lukaszewczak
Copy link
Collaborator Author

hey @davidmarkclements , I rephrase the test and I merge you changes and change a little code in benchmarks to use special NULL device on Windows platform based on (https://stackoverflow.com/questions/11053977/how-can-i-write-to-the-nul-device-under-windows-from-node-js). Now benchmarks works for me on Windows and on Linux platform run through docker container.

On Windows I got those results:

Running BASIC benchmark

benchPino*10000: 340.299ms
benchDebug*10000: 419.495ms
benchPinoDebug*10000: 240.316ms
benchPinoExtremeDebug*10000: 163.746ms
benchPino*10000: 247.485ms
benchDebug*10000: 356.415ms
benchPinoDebug*10000: 225.428ms
benchPinoExtremeDebug*10000: 143.028ms

Running OBJECT benchmark

benchPinoObj*10000: 343.505ms
benchDebugObj*10000: 1924.199ms
benchPinoDebugObj*10000: 257.297ms
benchPinoExtremeDebugDeepObj*10000: 168.281ms
benchPinoObj*10000: 244.010ms
benchDebugObj*10000: 1671.680ms
benchPinoDebugObj*10000: 231.068ms
benchPinoExtremeDebugDeepObj*10000: 148.491ms

Running DEEPOBJECT benchmark

benchPinoDeepObj*10000: 7783.786ms
benchDebugDeepObj*10000: 37595.973ms
benchPinoDebugDeepObj*10000: 7604.188ms
benchPinoExtremeDebugDeepObj*10000: 7590.150ms
benchPinoDeepObj*10000: 7704.173ms
benchDebugDeepObj*10000: 36803.635ms
benchPinoDebugDeepObj*10000: 7595.744ms
benchPinoExtremeDebugDeepObj*10000: 7659.792ms

==========
basic averages
Pino average: 294
Debug average: 388
PinoDebug average: 233
PinoExtremeDebug average: 153
==========
==========
object averages
PinoObj average: 294
DebugObj average: 1798
PinoDebugObj average: 244
PinoExtremeDebugDeepObj average: 158
==========
==========
deepobject averages
PinoDeepObj average: 7744
DebugDeepObj average: 37200
PinoDebugDeepObj average: 7600
PinoExtremeDebugDeepObj average: 7625
==========

And on Linux using this Dockerfile

FROM node:slim
RUN mkdir -p /home/node/pino
WORKDIR /home/node/pino
COPY package.json /home/node/pino
RUN npm install
COPY . /home/node/pino
CMD ["npm","run","bench"]

I receive those results:

Running BASIC benchmark

benchPino*10000: 446.743ms
benchDebug*10000: 495.135ms
benchPinoDebug*10000: 364.454ms
benchPinoExtremeDebug*10000: 189.778ms
benchPino*10000: 336.118ms
benchDebug*10000: 442.447ms
benchPinoDebug*10000: 358.812ms
benchPinoExtremeDebug*10000: 175.488ms

Running OBJECT benchmark

benchPinoObj*10000: 441.598ms
benchDebugObj*10000: 986.291ms
benchPinoDebugObj*10000: 400.560ms
benchPinoExtremeDebugDeepObj*10000: 207.205ms
benchPinoObj*10000: 375.780ms
benchDebugObj*10000: 815.520ms
benchPinoDebugObj*10000: 386.477ms
benchPinoExtremeDebugDeepObj*10000: 178.686ms

Running DEEPOBJECT benchmark

benchPinoDeepObj*10000: 6958.435ms
benchDebugDeepObj*10000: 10248.101ms
benchPinoDebugDeepObj*10000: 9167.982ms
benchPinoExtremeDebugDeepObj*10000: 7796.194ms
benchPinoDeepObj*10000: 7251.846ms
benchDebugDeepObj*10000: 8723.877ms
benchPinoDebugDeepObj*10000: 7209.208ms
benchPinoExtremeDebugDeepObj*10000: 6937.079ms

==========
basic averages
Pino average: 391
Debug average: 469
PinoDebug average: 362
PinoExtremeDebug average: 183
==========
==========
object averages
PinoObj average: 409
DebugObj average: 901
PinoDebugObj average: 394
PinoExtremeDebugDeepObj average: 193
==========
==========
deepobject averages
PinoDeepObj average: 7105
DebugDeepObj average: 9486
PinoDebugDeepObj average: 8189
PinoExtremeDebugDeepObj average: 7367
==========

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@davidmarkclements davidmarkclements merged commit 9088e45 into pinojs:master Jan 3, 2018
@davidmarkclements
Copy link
Member

@lukaszewczak thanks so much for your efforts on this, I've added as a collaborator - no pressure to accept – just if you'd like to continue maintaining pino-debug we'd love to have you involved as a collaborator

@lukaszewczak
Copy link
Collaborator Author

Thank you @davidmarkclements for this invitation, this will be my first time as collaborator, but i love new challenges and I would like to maintain pino-debug.

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 this pull request may close these issues.

4 participants