consola icon indicating copy to clipboard operation
consola copied to clipboard

Doesn't handle native console string substitutions.

Open mathieutu opened this issue 5 years ago • 3 comments

Version

v2.10.0

Reproduction link

https://codesandbox.io/embed/fervent-pine-su2ty

Steps to reproduce

Hi folks,

Consola is not handling the native string substitutions of console. https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions

This leads to issues when when using wrapConsole method in code bases where you don't control logs.

Example: there is a problem with all the react errors.

Here an example before/after the wrap:

- Warning: Received `true` for a non-boolean attribute `secondary`.
+ Warning: Received `%s` for a non-boolean attribute `%s`.
  
- If you want to write it to the DOM, pass a string instead: secondary="true" or secondary={value.toString()}.
+ If you want to write it to the DOM, pass a string instead: %s="%s" or %s={value.toString()}.%s true secondary secondary true secondary 
    in h1 (created by App)
    in div (created by App)
    in App

For me, consola should have the same api than console, to be able to replace it properly.

How can we handle that?

Thanks for your work, Matt'.

What is expected ?

Consola should have at least the same api and features than console.

What is actually happening?

Features from console are missing in consola (browser and node).

This bug report is available on Nuxt community (#c57)

mathieutu avatar Aug 06 '19 09:08 mathieutu

and %c too

NomNes avatar Aug 06 '19 17:08 NomNes

Yeah, actually all strings substitutions. Changing the title for more generic.

mathieutu avatar Aug 06 '19 18:08 mathieutu

@d34thwings I think #66 fixed that, right?

mathieutu avatar Sep 01 '19 20:09 mathieutu