https://github.com/anseki/console-substitute
Polyfill for the String Substitutions by console.
https://github.com/anseki/console-substitute
android browser console console-error console-log console-substitute debug log output polyfill string-substitution
Last synced: about 1 month ago
JSON representation
Polyfill for the String Substitutions by console.
- Host: GitHub
- URL: https://github.com/anseki/console-substitute
- Owner: anseki
- License: mit
- Created: 2015-10-15T18:36:59.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-08-19T02:56:34.000Z (almost 4 years ago)
- Last Synced: 2025-06-14T15:50:05.859Z (12 months ago)
- Topics: android, browser, console, console-error, console-log, console-substitute, debug, log, output, polyfill, string-substitution
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# console-substitute
[](https://www.npmjs.com/package/console-substitute) [](https://github.com/anseki/console-substitute/issues) [](package.json) [](LICENSE)
Polyfill for the String Substitutions by console.
The `console` of web browser supports [the String Substitutions](https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions). It is very useful for debugging, etc.
For example, the multiple variables don't have to be joined by `+`:
```js
console.info('userName: %s, index: %i', userName, index);
```
Output:
```
userName: foo, index: 123
```
But some browsers such as Android browser, etc. don't support it. A big problem is that all arguments except a first argument (i.e. important informations more than first one) are ignored.
This polyfill implements the String Substitutions to the console that does not support it. This does nothing if the console already supports it.
## Usage
```html
```
### Methods
The following methods support the String Substitutions:
- `console.log`
- `console.info`
- `console.error`
- `console.warn`
#### Substitution Strings
The following substitution strings are supported:
- `%o`
- `%d`
- `%i`
- `%s`
- `%f`