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

Allow to provide custom levels and custom colors #257

Merged
merged 9 commits into from
Jan 20, 2022

Conversation

matteozambon89
Copy link
Contributor

@matteozambon89 matteozambon89 commented Nov 2, 2021

This should provide the possibility to handle custom levels and custom colors, especially through CLI.

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
lib/colors.js Outdated Show resolved Hide resolved
bin.js Outdated Show resolved Hide resolved
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

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.

tests must be re-enabled

@matteozambon89
Copy link
Contributor Author

@mcollina all done! Let me know if you can merge and deploy it please

Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

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

Please update documentation, including the Readme.

lib/colors.js Outdated Show resolved Hide resolved
lib/colors.js Show resolved Hide resolved
lib/utils.js Outdated Show resolved Hide resolved
lib/utils.js Outdated Show resolved Hide resolved
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

@matteozambon89
Copy link
Contributor Author

@mcollina and @jsumners can this be merged to master?

Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

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

Can you perform a rebase?

$ git remote add upstream https://github.com/pinojs/pino-pretty.git
$ git fetch upstream master
$ git rebase upstream/master

package.json Outdated Show resolved Hide resolved
@matteozambon89 matteozambon89 force-pushed the custom-log-levels branch 4 times, most recently from 3186519 to c94f89c Compare December 8, 2021 15:06
@matteozambon89
Copy link
Contributor Author

matteozambon89 commented Dec 8, 2021

@jsumners I've removed package.json from my commits as the changes shouldn't have been committed in the first place and rebased to pinojs:master once again.

Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

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

Looks good to me.

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

@mcollina
Copy link
Member

mcollina commented Dec 9, 2021

can you check CI? It was failing

@dotcore
Copy link

dotcore commented Jan 19, 2022

I am also very interested in this feature, so I looked into why the CI is failing. For some probably non-intentional reason in commit id c94f89c in file test/basic.test.js, following code gets changed to:

    const expectedLines = [
      '    msg: {',
      '      "b": {',
      '        "c": "d"',
      '      },',
      '      "a": "[Circular ~]"',
      '    }'
    ]

instead of:

    const expectedLines = [
      '    msg: {',
      '      "a": "[Circular]",',
      '      "b": {',
      '        "c": "d"',
      '      }',
      '    }'
    ]

After that the tests are all green.
I think this also could use a rebase to upstream again. I could also submit a pull request, if you want.

@matteozambon89
Copy link
Contributor Author

I am also very interested in this feature, so I looked into why the CI is failing. For some probably non-intentional reason in commit id c94f89c in file test/basic.test.js, following code gets changed to:

    const expectedLines = [
      '    msg: {',
      '      "b": {',
      '        "c": "d"',
      '      },',
      '      "a": "[Circular ~]"',
      '    }'
    ]

instead of:

    const expectedLines = [
      '    msg: {',
      '      "a": "[Circular]",',
      '      "b": {',
      '        "c": "d"',
      '      }',
      '    }'
    ]

After that the tests are all green. I think this also could use a rebase to upstream again. I could also submit a pull request, if you want.

Sorry if I've been AWOL, between Xmas holidays and New Year "back to work" I haven't had time to look into this issue.

Thanks @dotcore for your input. The commit was made somewhat intentionally as the local test was failing and wasn't allowing me to push. I'll revert that commit and push again to see if it fixes the issue.

I will also do a rebase to upstream, so we can hopefully close this PR.

@matteozambon89
Copy link
Contributor Author

@mcollina @jsumners @dotcore reverted the test changes and rebased to upstream

@dotcore
Copy link

dotcore commented Jan 19, 2022

@mcollina @jsumners @dotcore reverted the test changes and rebased to upstream

One typo is left.

' "a": "[Circular]",',

instead of

' "a": "[Circular],"',

This causes 1 test to fail.

@matteozambon89
Copy link
Contributor Author

@dotcore I've updated that, although my tests keep failing for the test/basic.test.js as the format is different on my machine.

I'm on MacOS with node 16, which environment are you running the tests from?

@dotcore
Copy link

dotcore commented Jan 19, 2022

@dotcore I've updated that, although my tests keep failing for the test/basic.test.js as the format is different on my machine.

I'm on MacOS with node 16, which environment are you running the tests from?

I'm on MacOS with node 17.4.0, but I also tested on node 16.13.2 and 12.22.9 (Switched with nvm).

@matteozambon89
Copy link
Contributor Author

@dotcore for some reason this is what I see when I run npm run test, can you confirm this doesn't happen to you and all tests are passing?

> [email protected] test
> tap --100 --color

 FAIL  test/basic.test.js
 ✖ should be equal

  test/basic.test.js                                         
  701 |         lines.shift(); lines.pop()                   
  702 |         for (let i = 0; i < lines.length; i += 1) {  
> 703 |           t.equal(lines[i], expectedLines[i])        
      | ------------^                                        
  704 |         }                                            
  705 |         cb()                                         
  706 |       }                                              

  --- expected              
  +++ actual                
  @@ -1,1 +1,1 @@           
  -      "a": "[Circular]", 
  +      "b": {             

  test: test/basic.test.js basic prettifier tests prettifies msg object with
    circular references
  stack: |
    Writable.write [as _write] (test/basic.test.js:703:13)
    doWrite (node_modules/readable-stream/lib/_stream_writable.js:409:139)
    writeOrBuffer (node_modules/readable-stream/lib/_stream_writable.js:398:5)
    Writable.write (node_modules/readable-stream/lib/_stream_writable.js:307:11)
    Pino.write (node_modules/pino/lib/proto.js:190:10)
    Pino.LOG [as info] (node_modules/pino/lib/tools.js:58:21)
    Test.<anonymous> (test/basic.test.js:711:9)
    Test.<anonymous> (test/basic.test.js:685:5)
    Object.<anonymous> (test/basic.test.js:34:1)
    Module.replacementCompile (node_modules/append-transform/index.js:60:13)
    Object.<anonymous> (node_modules/append-transform/index.js:64:4)

 FAIL  test/basic.test.js
 ✖ should be equal

  test/basic.test.js                                         
  701 |         lines.shift(); lines.pop()                   
  702 |         for (let i = 0; i < lines.length; i += 1) {  
> 703 |           t.equal(lines[i], expectedLines[i])        
      | ------------^                                        
  704 |         }                                            
  705 |         cb()                                         
  706 |       }                                              

  --- expected      
  +++ actual        
  @@ -1,1 +1,1 @@   
  -      "b": {     
  +        "c": "d" 

  test: test/basic.test.js basic prettifier tests prettifies msg object with
    circular references
  stack: |
    Writable.write [as _write] (test/basic.test.js:703:13)
    doWrite (node_modules/readable-stream/lib/_stream_writable.js:409:139)
    writeOrBuffer (node_modules/readable-stream/lib/_stream_writable.js:398:5)
    Writable.write (node_modules/readable-stream/lib/_stream_writable.js:307:11)
    Pino.write (node_modules/pino/lib/proto.js:190:10)
    Pino.LOG [as info] (node_modules/pino/lib/tools.js:58:21)
    Test.<anonymous> (test/basic.test.js:711:9)
    Test.<anonymous> (test/basic.test.js:685:5)
    Object.<anonymous> (test/basic.test.js:34:1)
    Module.replacementCompile (node_modules/append-transform/index.js:60:13)
    Object.<anonymous> (node_modules/append-transform/index.js:64:4)

 FAIL  test/basic.test.js
 ✖ should be equal

  test/basic.test.js                                         
  701 |         lines.shift(); lines.pop()                   
  702 |         for (let i = 0; i < lines.length; i += 1) {  
> 703 |           t.equal(lines[i], expectedLines[i])        
      | ------------^                                        
  704 |         }                                            
  705 |         cb()                                         
  706 |       }                                              

  --- expected      
  +++ actual        
  @@ -1,1 +1,1 @@   
  -        "c": "d" 
  +      },         

  test: test/basic.test.js basic prettifier tests prettifies msg object with
    circular references
  stack: |
    Writable.write [as _write] (test/basic.test.js:703:13)
    doWrite (node_modules/readable-stream/lib/_stream_writable.js:409:139)
    writeOrBuffer (node_modules/readable-stream/lib/_stream_writable.js:398:5)
    Writable.write (node_modules/readable-stream/lib/_stream_writable.js:307:11)
    Pino.write (node_modules/pino/lib/proto.js:190:10)
    Pino.LOG [as info] (node_modules/pino/lib/tools.js:58:21)
    Test.<anonymous> (test/basic.test.js:711:9)
    Test.<anonymous> (test/basic.test.js:685:5)
    Object.<anonymous> (test/basic.test.js:34:1)
    Module.replacementCompile (node_modules/append-transform/index.js:60:13)
    Object.<anonymous> (node_modules/append-transform/index.js:64:4)

 FAIL  test/basic.test.js
 ✖ should be equal

  test/basic.test.js                                         
  701 |         lines.shift(); lines.pop()                   
  702 |         for (let i = 0; i < lines.length; i += 1) {  
> 703 |           t.equal(lines[i], expectedLines[i])        
      | ------------^                                        
  704 |         }                                            
  705 |         cb()                                         
  706 |       }                                              

  --- expected               
  +++ actual                 
  @@ -1,1 +1,1 @@            
  -      }                   
  +      "a": "[Circular ~]" 

  test: test/basic.test.js basic prettifier tests prettifies msg object with
    circular references
  stack: |
    Writable.write [as _write] (test/basic.test.js:703:13)
    doWrite (node_modules/readable-stream/lib/_stream_writable.js:409:139)
    writeOrBuffer (node_modules/readable-stream/lib/_stream_writable.js:398:5)
    Writable.write (node_modules/readable-stream/lib/_stream_writable.js:307:11)
    Pino.write (node_modules/pino/lib/proto.js:190:10)
    Pino.LOG [as info] (node_modules/pino/lib/tools.js:58:21)
    Test.<anonymous> (test/basic.test.js:711:9)
    Test.<anonymous> (test/basic.test.js:685:5)
    Object.<anonymous> (test/basic.test.js:34:1)
    Module.replacementCompile (node_modules/append-transform/index.js:60:13)
    Object.<anonymous> (node_modules/append-transform/index.js:64:4)

 FAIL  test/basic.test.js
 ✖ should be equal

  test/basic.test.js                                                             
  931 |     Object.assign(fs, { close, writeSync })                              
  932 |     t.match(chunks.join(''), /INFO .+: this message has been buffered/)  
> 933 |     t.equal(closeCalled, false)                                          
      | ------^                                                                  
  934 |   })                                                                     
  935 |                                                                          
  936 |   t.test('stream usage', async (t) => {                                  

  test: test/basic.test.js basic prettifier tests does not call fs.close on stdout
    stream
  found: true
  wanted: false
  compare: ===
  stack: |
    Test.<anonymous> (test/basic.test.js:933:7)
    Test.<anonymous> (test/basic.test.js:910:5)
    Object.<anonymous> (test/basic.test.js:34:1)
    Module.replacementCompile (node_modules/append-transform/index.js:60:13)
    Object.<anonymous> (node_modules/append-transform/index.js:64:4)

@dotcore
Copy link

dotcore commented Jan 19, 2022

@dotcore for some reason this is what I see when I run npm run test, can you confirm this doesn't happen to you and all tests are passing?

I can confirm that it works for me, also CI didn't fail. No idea why it does not work for you.

@matteozambon89
Copy link
Contributor Author

@dotcore for some reason this is what I see when I run npm run test, can you confirm this doesn't happen to you and all tests are passing?

I can confirm that it works for me, also CI didn't fail. No idea why it does not work for you.

Who knows 😂

@dotcore
Copy link

dotcore commented Jan 19, 2022

@dotcore for some reason this is what I see when I run npm run test, can you confirm this doesn't happen to you and all tests are passing?

I can confirm that it works for me, also CI didn't fail. No idea why it does not work for you.

Who knows 😂

Not sure if this may help, but maybe delete your node_modules and run npm i, in case you have some outdated dependencies.

@matteozambon89
Copy link
Contributor Author

@dotcore nope, that didn't solve the issue. Something between node and MacOS must be configured differently in this machine.

@mcollina can we have this PR merged to master?

@mcollina mcollina merged commit 0c3993a into pinojs:master Jan 20, 2022
@mcollina
Copy link
Member

Done

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