https://github.com/link-intersystems/console-proxy-dom
https://github.com/link-intersystems/console-proxy-dom
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/link-intersystems/console-proxy-dom
- Owner: link-intersystems
- License: mit
- Created: 2021-10-22T08:30:00.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-11-02T08:41:27.000Z (over 4 years ago)
- Last Synced: 2025-02-01T23:32:25.934Z (over 1 year ago)
- Language: TypeScript
- Size: 370 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Console Proxy Dom Library



[](LICENSE.md)
An extension library for [@link-intersystems/console-proxy](https://github.com/link-intersystems/console-proxy) that contains utilities to redirect console logs to dom elements, e.g. a textarea.
## Install
npm i "@link-intersystems/console-proxy-dom"
## Use
import {
createConsoleProxy,
createConsoleTemplate,
} from "@link-intersystems/console-proxy";
import {
valueLogConfig,
defaultLogConfig
} from "@link-intersystems/console-proxy-dom";
const consoleProxy = createConsoleProxy();
const domConsoleLogInterceptor = createDOMConsoleLogInterceptor();
domConsoleLogInterceptor.setLogTargetSelector("#console"); // the default
// The defaultLogConfig redirects logs by appending them to the target's innerHtml.
domConsoleLogInterceptor.setLogConfig(defaultLogConfig); // the default
// The valueLogConfig redirects logs by appending them to the target's value property.
// E.g. can be used for textareas.
// domConsoleLogInterceptor.setLogConfig(valueLogConfig);
consoleProxy.setInterceptor(domConsoleLogInterceptor);
// will be redirected to the dom element selected by the target css selector.
consoleProxy.info("INFO", "Hello", "World");
consoleProxy.debug("DEBUG", "Hellow", "World");
E.g. a div target
Console div
## Live Demo at codepen.io
See [@link-intersystems/console-proxy-dom](https://codepen.io/rene-link/pen/gOxLvgO)