1.1.2 • Published 2 years ago

@debug-ui/debug-console v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Debug UI

Simple UI components for debugging and logging.

Installation

npm install @debug-ui/debug-console

If you want to use the default styles, you need to import styles explicitly.

What's included

With the download you'll find the following directoryies and files, with both compiled and minified versions.

```
debug-console/dist/
├── index.css
├── index.bundle.js
├── index.bundle.js.map
├── index.bundle.min.js
├── index.bundle.min.js.map
├── index.esm.js
├── index.esm.js.map
├── index.esm.min.js
├── index.esm.min.js.map
├── index.js
├── index.js.map
├── index.min.js
└──  index.min.js.map
```

Usage

The components use a simple logging API:

Optional CSS file css

@import "@debug-ui/debug-console/dist/index.css

node app.js/app.ts

import { debug, subscribe, unsubscribe, DebugConsole } from '@debug-ui/debug-console';

let debugConsole = new DebugConsole(document.getElementById('someElementInTheDOM'));

debugConsole.open();
// OR
debugConsole.open(document.getElementById('someElementInTheDOM'));

suscribe('loggerA', (record) => debugConsole.log(record));
suscribe('loggerB', (record) => debugConsole.log(record));

debug('loggerA', 'example log A');
debug('loggerB', 'example log B');

browser indext.html

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <script src="@debug-ui/debug-console/dist/index.bundle.js"></script>
  </head>
  <body>
    <div id="example"></div>
    <script>
      var debug = DebugUI.debug;
      var subscribe = DebugUI.subscribe;
      var debugConsole = new DebugUI.DebugConsole({
        mountTo: document.getElementById('example')
      });

      debugConsole.open()

      subscribe('example', (record) => debugConsole.log(record));

      debug('example', 'example log');
    </script>
  </body>
</html>

Configurable Properties

Debug Console

The Debug Console component supports the following properties:

PropertyPurpose
headerClassNamesCSS class name(s) to append to header element.
logClassNamesCSS class name(s) to append to logger div.
footerClassNamesCSS class name(s) to append to footer element.
headerIdID for header element.
logIdID for logger div.
footerIdID for footer element.
mountToHTMLElement or string to mount component to.
toolbarToolBar: toolbar to use for component.
formatterFormatter: formatter to use for structuring/styling log record.

Formatter

PropertyPurpose
infoCSS class name(s) to append to info log element.
errorCSS class name(s) to append to error log element.
warningCSS class name(s) to append to warning log element.
debugCSS class name(s) to append to debug log element.
logRecordContainerCSS class name(s) to append to log element.
logRecordTimestampCSS class name(s) to append to log element.
logRecordNameCSS class name(s) to append to log element.
logRecordLevelCSS class name(s) to append to log element.
prefixCSS class name(s) to append to log element.
showAbsoluteTimeA boolean to display the current time.
showRelativeTimeA boolean to display the relative time, since the log was created.
showLoggerNameA boolean to display the name of the logger.
showSeverityLevelA boolean to display the log level of the record.

Toolbar

PropertyPurpose
itemClassNamesCSS class name(s) to append to ToolBarItems.
groupClassNamesCSS class name(s) to append to toolbar groups.
itemsToolBarItems to appended to the toolbar component.

Copyright and license

Code copyright 2021–2022. Code released under the MIT License.