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

loglevel=error doesn't supress warnings, such as WARN deprecated and  WARN  Issues with peer dependencies found. #4343

Closed
brillout opened this issue Feb 16, 2022 · 3 comments · Fixed by #4507

Comments

@brillout
Copy link

pnpm version:

6.30.0

Code to reproduce the issue:

See screenshot. Should be trivial to reproduce, but I can provide a step-by-step reproduction if needed.

Expected behavior:

As per the documentation (https://pnpm.io/npmrc#loglevel), warnings shouldn't be shown.

Actual behavior:

Warnings are displayed.

Additional information:

  • node -v prints: v.16.5.0
  • Windows, macOS, or Linux?: Linux

Screenshot 2022-02-16 14 38 06

@2239559319
Copy link
Contributor

reportMisc.ts#L12
error is the smallest in LOG_LEVEL_NUMBER so setting loglevel=error will show error warn info and debug

@brillout
Copy link
Author

Is there a way to supress warnings while still showing errors?

My use case is that I've a examples directory (https://github.com/brillout/vite-plugin-ssr/tree/master/examples):

vite-plugin-ssr/examples/react
vite-plugin-ssr/examples/vue
vite-plugin-ssr/examples/cloudflare-workers
...

So ideally I'd supress specific warnings for all/specific examples. I've no control over the dependencies of the examples and therefore warnings are expected.

@milahu
Copy link
Contributor

milahu commented Mar 30, 2022

same here
pnpm install --loglevel error will produce WARN  deprecated messages

reportMisc.ts#L12
error is the smallest in LOG_LEVEL_NUMBER so setting loglevel=error will show error warn info and debug

no, the condition is

LOG_LEVEL_NUMBER[obj.level] <= maxLogLevel

default level is info which will show info warn error

debug is the most verbose (show all messages)
error is the most quiet (as expected)

packages/default-reporter/src/reporterForClient/reportMisc.ts
// packages/default-reporter/src/reporterForClient/reportMisc.ts

const LOG_LEVEL_NUMBER: Record<LogLevel, number> = {
  error: 0,
  warn: 1,
  info: 2,
  debug: 3,
}

export default (
  ...
) => {
  const maxLogLevel = LOG_LEVEL_NUMBER[opts.logLevel ?? 'info'] ?? LOG_LEVEL_NUMBER['info']
  const reportWarning = makeWarningReporter(opts)
  return Rx.merge(log$.registry, log$.other).pipe(
    filter((obj) => LOG_LEVEL_NUMBER[obj.level] <= maxLogLevel &&
      (obj.level !== 'info' || !obj['prefix'] || obj['prefix'] === opts.cwd)),
    map((obj) => {
      switch (obj.level) {
      case 'warn': {
        return reportWarning(obj)
      }
      case 'error':
        if (obj['prefix'] && obj['prefix'] !== opts.cwd) {
          return Rx.of({
            msg: `${obj['prefix'] as string}:` + os.EOL + reportError(obj, opts.config),
          })
        }
        return Rx.of({ msg: reportError(obj, opts.config) })
      default:
        return Rx.of({ msg: obj['message'] })
      }
    })
  )
}

this works with logger.error logger.warn logger.info logger.debug
... but reportMisc.ts is not responsible here

the WARN  deprecated messages come from
packages/default-reporter/src/reporterForClient/reportDeprecations.ts
and
packages/default-reporter/src/reporterForClient/index.ts

    reportDeprecations(log$.deprecation, { cwd, isRecursive: opts.isRecursive }),

packages/default-reporter/src/index.ts

  const deprecationPushStream = new Rx.Subject<logs.DeprecationLog>()

  const log$ = {
    deprecation: Rx.from(deprecationPushStream),

zkochan added a commit that referenced this issue Apr 17, 2022
zkochan added a commit that referenced this issue Apr 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants