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

Print warning on changing log level when using multistream #2030

Open
rluvaton opened this issue Aug 18, 2024 · 4 comments
Open

Print warning on changing log level when using multistream #2030

rluvaton opened this issue Aug 18, 2024 · 4 comments

Comments

@rluvaton
Copy link
Contributor

rluvaton commented Aug 18, 2024

I just spent 3h debugging why no logs output when used the elasticsearch transport with ECS format and stdout transport

And because ECS format change the log level, it did not logged as it's forbidden in multistream

So it would be great if we changed the log level and used multiple transports there will be warning reported


Log level shape should not change when using multiple transports if I understand correctly from here

@mcollina
Copy link
Member

Log level shape should not change when using multiple transports if I understand correctly from here

Yes exactly.


Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@rluvaton
Copy link
Contributor Author

@Tamir-M you wanted to get into open source, here is an easy issue

I can help you if you want as I'm familiar with the codebase

if you are not interested, you can comment here so other people from the community will know and can take it if they are interested

@Tamir-M
Copy link

Tamir-M commented Aug 21, 2024

@Tamir-M you wanted to get into open source, here is an easy issue

I can help you if you want as I'm familiar with the codebase

if you are not interested, you can comment here so other people from the community will know and can take it if they are interested

Hi I'm sure @Livour would love to work on this as he's more familiar with the issue.

@Livour
Copy link

Livour commented Aug 29, 2024

After inspecting the issue I found out that it only occurs when passing a transport stream to the pino function.
for example, the following test would currently fail:

test('throws when custom level formatter is used with a multi-targets transport stream', async ({ throws }) => {
  throws(() => {
    pino({
      level: 'info',
      formatters: {
        level (label) {
          return label
        }
      }
    },
    transport({
      targets: [
        {
          target: 'source1'
        },
        {
          target: 'source2'
        }
      ]
    })
    )
  },
  Error('transport.targets do not allow custom level formatters'))
})

I tried fixing it but I found it rather difficult because it only occurs when we pass a pre-made stream to the function (the transport function returns a ThreadStream), any advice?

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

No branches or pull requests

4 participants