mirror of
https://github.com/liriliri/eruda.git
synced 2026-03-24 09:48:37 +08:00
1.9 KiB
1.9 KiB
Tool Api
Each default tool provided by eruda can be accessed by eruda.get('Tool Name').
Console
Displays console logs. Implementation detail follows the console api spec.
Config
| Name | Type | Desc |
|---|---|---|
| catchGlobalErr | boolean | Catch global errors |
| overrideConsole | boolean | Override console |
| displayExtraInfo | boolean | Display extra information |
| displayUnenumerable | boolean | Display unenumerable properties |
| displayGetterVal | boolean | Access getter value |
| viewLogInSources | boolean | View log in sources panel |
| displayIfErr | boolean | Auto display if error occurs |
| maxLogNum | string | Max log number |
var console = eruda.get('console');
console.config.set('catchGlobalErr', true);
log, error, info, warn, dir, time/timeEnd, clear, count, assert, table
All these methods can be used in the same way as window.console object.
var console = eruda.get('console');
console.log('eruda is a console for %s.', 'mobile browsers');
console.table([{test: 1}, {test: 2}, {test2: 3}], 'test');
console.error(new Error('eruda'));
filter
Filters logs.
| Name | Type | Desc |
|---|---|---|
| filter | string regexp function | Custom filter |
console.filter('all'); // String parameter. Log, warn, debug, error is also supported.
console.filter(/^eruda/);
console.filter(function (log)
{
return log.type === 'error';
});
html
Logs out html content.
| Name | Type | Desc |
|---|---|---|
| html | string | Html string |
console.html('<span style="color:red">Red</span>');